Skip to content

Commit

Permalink
chore(CVR): enable REBUILD_ESTIMATES feature gate (#1670)
Browse files Browse the repository at this point in the history
Signed-off-by: mittachaitu <sai.chaithanya@mayadata.io>
  • Loading branch information
sai chaithanya authored Apr 22, 2020
1 parent 11135d0 commit 21fb1fd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 43 deletions.
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

0 comments on commit 21fb1fd

Please sign in to comment.