Skip to content

Commit 4236bcf

Browse files
committed
tests for verify method
Signed-off-by: Yuji Ito <llamerada.jp@gmail.com>
1 parent 0152be1 commit 4236bcf

6 files changed

Lines changed: 658 additions & 4 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ vet: ## Run go vet against code.
8181

8282
.PHONY: mock
8383
mock: mockgen
84+
$(MOCKGEN) -source=internal/ceph/ceph.go -destination=internal/ceph/ceph_mock.go -package=ceph
8485
$(MOCKGEN) -source=internal/ceph/command.go -destination=internal/ceph/command_mock.go -package=ceph
8586
$(MOCKGEN) -source=pkg/controller/proto/controller_grpc.pb.go -destination=pkg/controller/proto/controller_grpc.pb_mock.go -package=proto
8687
$(MOCKGEN) -source=internal/controller/internal/objectstorage/objectstorage.go -destination=internal/controller/internal/objectstorage/objectstorage_mock.go -package=objectstorage

internal/ceph/ceph_mock.go

Lines changed: 169 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/controller/mantlebackup_controller.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ func (r *MantleBackupReconciler) verify(
657657
},
658658
makeVerifyPVName(backup),
659659
labelComponentVerifyVolume,
660+
true,
660661
); err != nil {
661662
return fmt.Errorf("failed to create a static PV with the clone: %w", err)
662663
}
@@ -2070,6 +2071,7 @@ func (r *MantleBackupReconciler) reconcileZeroOutJob(
20702071
snapshotTarget.pv.Spec.Capacity,
20712072
MakeZeroOutPVName(backup),
20722073
labelComponentZeroOutVolume,
2074+
false,
20732075
); err != nil {
20742076
return ctrl.Result{}, err
20752077
}
@@ -2110,6 +2112,7 @@ func (r *MantleBackupReconciler) reconcileZeroOutJob(
21102112
// capacity - resource capacity for the PV
21112113
// newPvName - name for the new or updated PV
21122114
// componentName - label value for the component
2115+
// addFlatten - whether to add deep-flatten feature to the volume attributes
21132116
//
21142117
// Returns an error if creation or update fails.
21152118
func (r *MantleBackupReconciler) createOrUpdateStaticPV(
@@ -2118,6 +2121,7 @@ func (r *MantleBackupReconciler) createOrUpdateStaticPV(
21182121
volume string,
21192122
capacity corev1.ResourceList,
21202123
newPvName, componentName string,
2124+
addFlatten bool,
21212125
) error {
21222126
var pv corev1.PersistentVolume
21232127
pv.SetName(newPvName)
@@ -2149,8 +2153,16 @@ func (r *MantleBackupReconciler) createOrUpdateStaticPV(
21492153
if pv.Spec.CSI.VolumeAttributes == nil {
21502154
pv.Spec.CSI.VolumeAttributes = map[string]string{}
21512155
}
2156+
feature := basePV.Spec.CSI.VolumeAttributes["imageFeatures"]
2157+
if addFlatten {
2158+
if len(feature) > 0 {
2159+
feature = feature + ",deep-flatten"
2160+
} else {
2161+
feature = "deep-flatten"
2162+
}
2163+
}
21522164
pv.Spec.CSI.VolumeAttributes["clusterID"] = basePV.Spec.CSI.VolumeAttributes["clusterID"]
2153-
pv.Spec.CSI.VolumeAttributes["imageFeatures"] = basePV.Spec.CSI.VolumeAttributes["imageFeatures"]
2165+
pv.Spec.CSI.VolumeAttributes["imageFeatures"] = feature
21542166
pv.Spec.CSI.VolumeAttributes["imageFormat"] = basePV.Spec.CSI.VolumeAttributes["imageFormat"]
21552167
pv.Spec.CSI.VolumeAttributes["pool"] = basePV.Spec.CSI.VolumeAttributes["pool"]
21562168
pv.Spec.CSI.VolumeAttributes["staticVolume"] = "true"
@@ -2308,7 +2320,7 @@ func (r *MantleBackupReconciler) createOrUpdateVerifyJob(ctx context.Context, jo
23082320
Name: "verify",
23092321
Image: r.podImage,
23102322
Command: []string{
2311-
"/user/sbin/e2fsck",
2323+
"/usr/sbin/e2fsck",
23122324
"-fn",
23132325
"/dev/verify-rbd",
23142326
},

0 commit comments

Comments
 (0)