Skip to content

Commit 0e0db36

Browse files
nirsBenamarMk
authored andcommitted
Fix PV.Spec.ClaimRef.Kind validation
When comparing PVs, skip comparing unset "Spec.ClaimRef.kind". This breaks validation when using KubeVirt VM, and actual resources in the system do not match the backed up resources in the s3 store. It is correct to ignore unset kind since this is an optional field[1]. Previously we failed with: Failed to restore PVs: failed to restore ClusterData for VolRep (failed to restore PVs and PVCs using profile list ([s3profile-perf8-ocs-storagecluster]): failed to restore all []v1.PersistentVolume. Total/Restored 1/0) And then the VRG will not make any progress. Now we consider unset "kind" as equal and continue the flow normally. [1] https://github.com/kubernetes/api/blob/f3648a53522eb60ea75d70d36a50c799f7e4e23b/core/v1/types.go#L6381 Bug: https://bugzilla.redhat.com/2262455 Signed-off-by: Nir Soffer <[email protected]>
1 parent 6a81939 commit 0e0db36

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

controllers/util/misc.go

+5
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,8 @@ func UpdateStringMap(dst *map[string]string, src map[string]string) {
115115
(*dst)[key] = val
116116
}
117117
}
118+
119+
// OptionalEqual returns True if optional field values are equal, or one of them is unset.
120+
func OptionalEqual(a, b string) bool {
121+
return a == "" || b == "" || a == b
122+
}

controllers/vrg_volrep.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -2162,7 +2162,7 @@ func (v *VRGInstance) pvMatches(x, y *corev1.PersistentVolume) bool {
21622162
"y", y.Spec.PersistentVolumeSource.CSI.FSType)
21632163

21642164
return false
2165-
case x.Spec.ClaimRef.Kind != y.Spec.ClaimRef.Kind:
2165+
case !rmnutil.OptionalEqual(x.Spec.ClaimRef.Kind, y.Spec.ClaimRef.Kind):
21662166
v.log.Info("PVs ClaimRef.Kind mismatch", "x", x.Spec.ClaimRef.Kind, "y", y.Spec.ClaimRef.Kind)
21672167

21682168
return false

0 commit comments

Comments
 (0)