From bb3a3a962e79a2cac21311ede9d17aea587d1822 Mon Sep 17 00:00:00 2001 From: liranmauda Date: Sun, 21 Jan 2024 08:43:09 +0200 Subject: [PATCH] Remove upgradeBackingStore Remove upgradeBackingStore Signed-off-by: liranmauda (cherry picked from commit 448a5c67392e6b6ab65ada4266fe0c4805e748a6) --- pkg/backingstore/backingstore.go | 14 +++----- pkg/backingstore/reconciler.go | 56 -------------------------------- 2 files changed, 5 insertions(+), 65 deletions(-) diff --git a/pkg/backingstore/backingstore.go b/pkg/backingstore/backingstore.go index 31524c859..5983f665c 100644 --- a/pkg/backingstore/backingstore.go +++ b/pkg/backingstore/backingstore.go @@ -1051,16 +1051,15 @@ func RunReconcile(cmd *cobra.Command, args []string) { })) } -// MapSecretToBackingStores returns a list of backingstores that uses the secret in their secretRefernce -// used by backingstore_contorller to watch secrets changes +// MapSecretToBackingStores returns a list of backingstores that uses the secret in their secretReference +// used by backingstore_controller to watch secrets changes func MapSecretToBackingStores(secret types.NamespacedName) []reconcile.Request { log := util.Logger() - log.Infof("checking which backingstore to reconcile. mapping secret %v to backingstores", secret) bsList := &nbv1.BackingStoreList{ TypeMeta: metav1.TypeMeta{Kind: "BackingStoreList"}, } if !util.KubeList(bsList, &client.ListOptions{Namespace: secret.Namespace}) { - log.Infof("Cloud not found backingStores in namespace %q, while trying to find Backingstore that uses %s secrte", secret.Namespace, secret.Name) + log.Infof("Could not found backingStores in namespace %q, while trying to find Backingstore that uses %s secret", secret.Namespace, secret.Name) return nil } @@ -1080,21 +1079,19 @@ func MapSecretToBackingStores(secret types.NamespacedName) []reconcile.Request { }) } } - log.Infof("will reconcile these backingstores: %v", reqs) return reqs } // MapNoobaaToBackingStores returns a list of backingstores that are inside Noobaa system -// used by backingstore_contorller to watch Noobaa CR changes +// used by backingstore_controller to watch Noobaa CR changes func MapNoobaaToBackingStores(noobaa types.NamespacedName) []reconcile.Request { log := util.Logger() - log.Infof("checking which backingstore to reconcile. mapping Noobaa %v to backingstores", noobaa) bsList := &nbv1.BackingStoreList{ TypeMeta: metav1.TypeMeta{Kind: "BackingStoreList"}, } if !util.KubeList(bsList, &client.ListOptions{Namespace: noobaa.Namespace}) { - log.Infof("Cloud not found backingStores in namespace %q, while trying to find Backingstore that inside %s Noobaa system", noobaa.Namespace, noobaa.Name) + log.Infof("Could not found backingStores in namespace %q, while trying to find Backingstore that inside %s Noobaa system", noobaa.Namespace, noobaa.Name) return nil } @@ -1108,7 +1105,6 @@ func MapNoobaaToBackingStores(noobaa types.NamespacedName) []reconcile.Request { }, }) } - log.Infof("will reconcile all backingstores: %v", reqs) return reqs } diff --git a/pkg/backingstore/reconciler.go b/pkg/backingstore/reconciler.go index e123804cb..827609eea 100644 --- a/pkg/backingstore/reconciler.go +++ b/pkg/backingstore/reconciler.go @@ -21,7 +21,6 @@ import ( cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" "github.com/sirupsen/logrus" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -177,16 +176,6 @@ func (r *Reconciler) Reconcile() (reconcile.Result, error) { } } - oldStatefulSet := &appsv1.StatefulSet{} - oldStatefulSet.Name = fmt.Sprintf("%s-%s-noobaa", r.BackingStore.Name, options.SystemName) - oldStatefulSet.Namespace = r.Request.Namespace - - if util.KubeCheck(oldStatefulSet) { - if err := r.upgradeBackingStore(oldStatefulSet); err != nil { - return r.completeReconcile(err) - } - } - err := r.ReconcilePhases() return r.completeReconcile(err) } @@ -1349,51 +1338,6 @@ func (r *Reconciler) deletePvPool() error { return nil } -func (r *Reconciler) upgradeBackingStore(sts *appsv1.StatefulSet) error { - r.Logger.Infof("Deleting old statefulset: %s", sts.Name) - envVar := util.GetEnvVariable(&sts.Spec.Template.Spec.Containers[0].Env, "AGENT_CONFIG") - if envVar == nil { - return util.NewPersistentError("NoAgentConfig", "Old BackingStore stateful set not having agent config") - } - agentConfig := envVar.Value - replicas := sts.Spec.Replicas - stsName := sts.Name - util.KubeDelete(sts, client.PropagationPolicy("Orphan")) // delete STS leave pods behind - o := util.KubeObject(bundle.File_deploy_internal_secret_empty_yaml) - secret := o.(*corev1.Secret) - secret.Name = fmt.Sprintf("backing-store-%s-%s", nbv1.StoreTypePVPool, r.BackingStore.Name) - secret.Namespace = options.Namespace - util.KubeCheck(secret) - secret.StringData["AGENT_CONFIG"] = agentConfig // update secret for future pods - util.KubeUpdate(secret) - for i := 0; i < int(*replicas); i++ { - pod := &corev1.Pod{} - pod.Name = fmt.Sprintf("%s-%d", stsName, i) - pod.Namespace = r.BackingStore.Namespace - if util.KubeCheck(pod) { - pod.Spec.Containers[0].Image = r.NooBaa.Status.ActualImage - if r.NooBaa.Spec.ImagePullSecret == nil { - pod.Spec.ImagePullSecrets = - []corev1.LocalObjectReference{} - } else { - pod.Spec.ImagePullSecrets = - []corev1.LocalObjectReference{*r.NooBaa.Spec.ImagePullSecret} - } - pod.Labels = map[string]string{"pool": r.BackingStore.Name} - r.Own(pod) - util.KubeUpdate(pod) - pvc := &corev1.PersistentVolumeClaim{} - pvc.Name = fmt.Sprintf("noobaastorage-%s", pod.Name) - pvc.Namespace = pod.Namespace - util.KubeCheck(pvc) - pvc.Labels = map[string]string{"pool": r.BackingStore.Name} - r.Own(pvc) - util.KubeUpdate(pvc) - } - } - return nil -} - func (r *Reconciler) reconcileResources(src, dst *corev1.ResourceList, minCPU, minMem resource.Quantity) error { cpu := minCPU mem := minMem