Skip to content

Commit

Permalink
empty .spec.volumeName of PVC when it's sent to secondary Mantle
Browse files Browse the repository at this point in the history
Signed-off-by: Ryotaro Banno <ryotaro.banno@gmail.com>
  • Loading branch information
ushitora-anqou committed Oct 22, 2024
1 parent 3de187b commit e8af7f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/controller/mantlebackup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ func (r *MantleBackupReconciler) replicateManifests(
annotRemoteUID: string(pvc.GetUID()),
})
pvcSent.Spec = pvc.Spec
pvcSent.Spec.VolumeName = "" // The VolumeName should be blank.
pvcSentJson, err := json.Marshal(pvcSent)
if err != nil {
return ctrl.Result{}, err
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/multik8s/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

mantlev1 "github.com/cybozu-go/mantle/api/v1"
corev1 "k8s.io/api/core/v1"
)

func TestMtest(t *testing.T) {
Expand Down Expand Up @@ -105,9 +106,15 @@ func replicationTestSuite() {
pvc.Annotations["mantle.cybozu.io/remote-uid"] != string(primaryPVC.GetUID()) {
return errors.New("invalid remote-uid annotation")
}
primaryPVC.Spec.VolumeName = ""
pvc.Spec.VolumeName = ""
if !reflect.DeepEqual(primaryPVC.Spec, pvc.Spec) {
return errors.New("spec not equal")
}
if pvc.Status.Phase != corev1.ClaimBound {
return errors.New("pvc not bound")
}

return nil
}).Should(Succeed())

Expand Down

0 comments on commit e8af7f6

Please sign in to comment.