Skip to content

Conversation

@hardcoretime
Copy link
Contributor

@hardcoretime hardcoretime commented Dec 1, 2025

Why do we need it, and what problem does it solve?

Some issues, such as a revision error, can occur when virtual disk metadata is updated in the CreatePVCFromVDSnapshotStep, and the original metadata can be lost. To prevent this, the updating block has been moved to its own step.

What is the expected result?

The original virtual disk metadata syncs correctly when restored from a virtual disk snapshot.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: vd
type: fix
summary: "The original virtual disk metadata now syncs correctly when restored from a virtual disk snapshot."

@hardcoretime hardcoretime added this to the v1.3.0 milestone Dec 1, 2025
@hardcoretime hardcoretime marked this pull request as draft December 1, 2025 11:11
@hardcoretime hardcoretime marked this pull request as ready for review December 1, 2025 14:20
Roman Sysoev added 3 commits December 3, 2025 11:41
Signed-off-by: Roman Sysoev <roman.sysoev@flant.com>
Signed-off-by: Roman Sysoev <roman.sysoev@flant.com>
Signed-off-by: Roman Sysoev <roman.sysoev@flant.com>
@hardcoretime hardcoretime force-pushed the fix/vd/move-metadata-sync-to-its-own-step branch from 565b2ce to 706035d Compare December 3, 2025 08:57
@Isteb4k Isteb4k closed this Dec 5, 2025
@Isteb4k Isteb4k deleted the fix/vd/move-metadata-sync-to-its-own-step branch December 5, 2025 09:23
@Isteb4k Isteb4k restored the fix/vd/move-metadata-sync-to-its-own-step branch December 5, 2025 09:24
@Isteb4k Isteb4k reopened this Dec 5, 2025
originalLabelsMap map[string]string
)

if vs.Annotations != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you checking for nil?


var (
isMetadataAdded bool
originalAnnotationsMap map[string]string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Place maps next to the spot where you use them

}
}

if isMetadataAdded {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a detailed comment explaining why we’re making return like this

)

if vs.Annotations != nil {
if vs.Annotations[annotations.AnnVirtualDiskOriginalLabels] != "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move it into two small independent functions:

setOriginalAnnotations(annotations map[string]string, vs *vsv1.VolumeSnapshot) (bool, error)
setOriginalLabels(labels map[string]string, vs *vsv1.VolumeSnapshot) (bool, error)


vs, err := object.FetchObject(ctx, types.NamespacedName{Name: vdSnapshot.Status.VolumeSnapshotName, Namespace: vdSnapshot.Namespace}, s.client, &vsv1.VolumeSnapshot{})
if err != nil {
return nil, fmt.Errorf("fetch volume snapshot: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set the phase to Failed for all errors in this step, and set the corresponding condition as well

}

func (s AddOriginalMetadataStep) Take(ctx context.Context, vd *v1alpha2.VirtualDisk) (*reconcile.Result, error) {
s.recorder.Event(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s have only one event when isMetadataAdded turns out to be true.

So as not to spam events on every reconciliation.

ClusterImageNotFound DatasourceReadyReason = "ClusterImageNotFound"

// AddingOriginalMetadataNotStarted indicates that the adding original metadata process has not started yet.
AddingOriginalMetadataNotStarted ReadyReason = "AddingOriginalMetadataNotStarted"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There’s no need for a reason in the condition. You can use ProvisioningNotStarted. For the event, the reason can be placed in api/core/v1alpha2/events.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants