From b41f6d6110da1f61a0678c9857fe27d6dfbc3c65 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Tue, 20 Feb 2024 15:06:41 +0200 Subject: [PATCH 1/2] Document Go 1.20 requirement Explain why we need Go 1.20 and how to maintain multiple Go versions so ramen can be built and tested while using newer default Go version. Signed-off-by: Nir Soffer (cherry picked from commit 810d897735515d0574c5328401af10db3e5255a4) --- docs/devel-quick-start.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/devel-quick-start.md b/docs/devel-quick-start.md index 212db6fdf..004a46c40 100644 --- a/docs/devel-quick-start.md +++ b/docs/devel-quick-start.md @@ -72,6 +72,22 @@ enough resources: link `venv` for activating the environment. To activate the environment use: +1. Install Go 1.20 + + Ramen requires now Go 1.20 due to backward incompatible changes in Go + 1.21 and later. If your system Go is newer and you don't want to + downgrade it, you can install Go 1.20 according to + [Managing Go installations](https://go.dev/doc/manage-install). + + To use Go 1.20 from the ~/sdk, change the PATH in the shell used to + build ramen: + + ``` + $ export PATH="/home/username/sdk/go1.20.14/bin:$PATH" + $ go version + go version go1.20.14 linux/amd64 + ``` + That's all! You are ready to submit your first pull request! ## Running the tests From dca15a85f56141b952e9c9de0de2df87f16526e9 Mon Sep 17 00:00:00 2001 From: Nir Soffer Date: Tue, 20 Feb 2024 15:58:22 +0200 Subject: [PATCH 2/2] 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/2265147 Signed-off-by: Nir Soffer (cherry picked from commit c05e32b0ef90020200a4387e29aab38dec637d6a) Signed-off-by: Nir Soffer --- controllers/util/misc.go | 5 +++++ controllers/vrg_volrep.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/controllers/util/misc.go b/controllers/util/misc.go index 255c8b1d7..b4ffda446 100644 --- a/controllers/util/misc.go +++ b/controllers/util/misc.go @@ -115,3 +115,8 @@ func UpdateStringMap(dst *map[string]string, src map[string]string) { (*dst)[key] = val } } + +// OptionalEqual returns True if optional field values are equal, or one of them is unset. +func OptionalEqual(a, b string) bool { + return a == "" || b == "" || a == b +} diff --git a/controllers/vrg_volrep.go b/controllers/vrg_volrep.go index cfdeac706..95f3e266d 100644 --- a/controllers/vrg_volrep.go +++ b/controllers/vrg_volrep.go @@ -2162,7 +2162,7 @@ func (v *VRGInstance) pvMatches(x, y *corev1.PersistentVolume) bool { "y", y.Spec.PersistentVolumeSource.CSI.FSType) return false - case x.Spec.ClaimRef.Kind != y.Spec.ClaimRef.Kind: + case !rmnutil.OptionalEqual(x.Spec.ClaimRef.Kind, y.Spec.ClaimRef.Kind): v.log.Info("PVs ClaimRef.Kind mismatch", "x", x.Spec.ClaimRef.Kind, "y", y.Spec.ClaimRef.Kind) return false