Skip to content

Commit

Permalink
volumemgr: update vrs every time vs changes
Browse files Browse the repository at this point in the history
Changes in volume status need to be reflected to the app. This is done
through the volume reference status. So every time the function
doUpdateVol returns we need to check if the volume status has changed
and if so update the volume reference status accordingly.

Signed-off-by: Paul Gaiduk <[email protected]>
  • Loading branch information
europaul authored and eriknordmark committed Dec 29, 2024
1 parent ddc3a94 commit 0566cd7
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions pkg/pillar/cmd/volumemgr/handlevolumeref.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,17 @@ func handleVolumeRefModify(ctxArg interface{}, key string,
vs := ctx.LookupVolumeStatus(config.VolumeKey())
if vs != nil {
if needUpdateVol {
doUpdateVol(ctx, vs)
changed, _ := doUpdateVol(ctx, vs)
if changed {
publishVolumeStatus(ctx, vs)
updateVolumeRefStatus(ctx, vs)
if err := createOrUpdateAppDiskMetrics(ctx, vs); err != nil {
log.Errorf("handleVolumeRefModify(%s): exception while publishing diskmetric. %s",
status.Key(), err.Error())
}
}
}
updateVolumeStatusRefCount(ctx, vs)
publishVolumeStatus(ctx, vs)
if err := createOrUpdateAppDiskMetrics(ctx, vs); err != nil {
log.Errorf("handleVolumeRefModify(%s): exception while publishing diskmetric. %s",
status.Key(), err.Error())
}
}
log.Functionf("handleVolumeRefModify(%s) Done", key)
}
Expand Down Expand Up @@ -167,6 +170,8 @@ func unpublishVolumeRefStatus(ctx *volumemgrContext, key string) {
}

func updateVolumeRefStatus(ctx *volumemgrContext, vs *types.VolumeStatus) {

log.Functionf("updateVolumeRefStatus(%s)", vs.Key())
sub := ctx.subVolumeRefConfig
items := sub.GetAll()
for _, st := range items {
Expand Down Expand Up @@ -217,4 +222,5 @@ func updateVolumeRefStatus(ctx *volumemgrContext, vs *types.VolumeStatus) {
publishVolumeRefStatus(ctx, status)
}
}
log.Functionf("updateVolumeRefStatus(%s) Done", vs.Key())
}

0 comments on commit 0566cd7

Please sign in to comment.