Skip to content

Commit

Permalink
Remove upgradeBackingStore
Browse files Browse the repository at this point in the history
Remove upgradeBackingStore

Signed-off-by: liranmauda <[email protected]>
(cherry picked from commit 448a5c6)
  • Loading branch information
liranmauda committed Jan 30, 2024
1 parent 0ccb0a2 commit bb3a3a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 65 deletions.
14 changes: 5 additions & 9 deletions pkg/backingstore/backingstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -1108,7 +1105,6 @@ func MapNoobaaToBackingStores(noobaa types.NamespacedName) []reconcile.Request {
},
})
}
log.Infof("will reconcile all backingstores: %v", reqs)

return reqs
}
56 changes: 0 additions & 56 deletions pkg/backingstore/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bb3a3a9

Please sign in to comment.