Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(CVR): enable REBUILD_ESTIMATES feature gate #1670

Merged
merged 3 commits into from
Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions cmd/cstor-pool-mgmt/controller/replica-controller/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -648,12 +648,11 @@ func (c *CStorVolumeReplicaController) syncCVRStatus(cvr *apis.CStorVolumeReplic
cvr.Status.Capacity = *capacity
}

if os.Getenv(string(common.RebuildEstimates)) == "true" {
err = volumereplica.GetAndUpdateSnapshotInfo(c.clientset, cvr)
if err != nil {
return errors.Wrapf(err, "Unable to update snapshot list details in CVR")
}
err = volumereplica.GetAndUpdateSnapshotInfo(c.clientset, cvr)
if err != nil {
return errors.Wrapf(err, "unable to update snapshot list details in CVR")
}

return nil
}

Expand Down
34 changes: 7 additions & 27 deletions cmd/cstor-pool-mgmt/volumereplica/volumereplica.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ func getAndAddPendingSnapshotList(
}
}

klog.Infof(
klog.V(2).Infof(
"Adding %v pending snapshots and deleting %v pending snapshots on CVR %s",
newSnapshots,
removedSnapshots,
Expand Down Expand Up @@ -871,7 +871,7 @@ func addOrDeleteSnapshotListInfo(
delete(cvr.Status.PendingSnapshots, snapName)
}
}
klog.Infof(
klog.V(2).Infof(
"Adding %v snapshots and deleting %v snapshots on CVR %s",
newSnapshots,
removedSnapshots,
Expand Down Expand Up @@ -900,39 +900,21 @@ func getSnapshotInfo(dsName, snapName string) (apis.CStorSnapshotInfo, error) {
WithScriptedMode(true).
WithParsableMode(true).
WithField("value").
WithProperty("referenced").
WithProperty("written").
WithProperty("logicalreferenced").
WithProperty("used").
WithProperty("compressratio").
WithDataset(dsName + "@" + snapName).
Execute()
if err != nil {
return apis.CStorSnapshotInfo{}, errors.Wrapf(err, "failed to get snapshot properties")
}
valueList := strings.Split(string(ret), "\n")
// Since we made zfs query in following order referenced, written,
// logicalreferenced, used and compressionratio output also will be
// in the same order

// referenced and written values are of type int64
var pInt64 []int64
var valI int64
for _, v := range []string{valueList[0], valueList[1]} {
valI, err = strconv.ParseInt(v, 10, 64)
if err != nil {
break
}
pInt64 = append(pInt64, valI)
}
if err != nil {
return apis.CStorSnapshotInfo{}, errors.Wrapf(err, "failed to parse the snapshot properties")
}
// Since we made zfs query in following order logicalreferenced,
// used output also will be in the same order

// logicalReferenced and Used values are of type uint64
var pUint64 []uint64
var valU uint64
for _, v := range []string{valueList[2], valueList[3]} {
for _, v := range []string{valueList[0], valueList[1]} {
valU, err = strconv.ParseUint(v, 10, 64)
if err != nil {
break
Expand All @@ -944,11 +926,9 @@ func getSnapshotInfo(dsName, snapName string) (apis.CStorSnapshotInfo, error) {
}

snapInfo := apis.CStorSnapshotInfo{
Referenced: pInt64[0],
Written: pInt64[1],
LogicalReferenced: pUint64[0],
Used: pUint64[1],
CompressionRatio: valueList[4],
// TODO: Populate Used value when we are estimating time for rebuild
// Used: pUint64[1],
}
return snapInfo, nil
}
12 changes: 1 addition & 11 deletions pkg/apis/openebs.io/v1alpha1/cstor_volume_replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,8 @@ type CStorSnapshotInfo struct {
// space consumed by metadata.
LogicalReferenced uint64 `json:"logicalReferenced"`

// Written describes the amount of referenced space written to this snapshot
Written int64 `json:"written"`

// CompressionRatio describes the compression factor of snapshot
CompressionRatio string `json:"compression"`

// Referenced describes the amount of data that is accessible
// by this snapshot
Referenced int64 `json:"referenced"`

// Used is the used bytes for given snapshot
Used uint64 `json:"used"`
// Used uint64 `json:"used"`
}

// CStorVolumeCapacityAttr is for storing the volume capacity.
Expand Down