From 76aec54b3773457655a929f9d505a86ad4aa4b7c Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Mon, 11 Mar 2024 17:42:23 +0100 Subject: [PATCH] Use common memcached.GetMemcachedServerListWithInetString() Use common func to retrieve the memcached server list for a memcached instance. --- controllers/swift_controller.go | 26 ++------------------------ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/controllers/swift_controller.go b/controllers/swift_controller.go index e8e4e3af..c30fdc23 100644 --- a/controllers/swift_controller.go +++ b/controllers/swift_controller.go @@ -19,7 +19,6 @@ package controllers import ( "context" "fmt" - "strings" "time" "github.com/go-logr/logr" @@ -29,7 +28,6 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - "k8s.io/apimachinery/pkg/types" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" @@ -230,7 +228,7 @@ func (r *SwiftReconciler) reconcileNormal(ctx context.Context, instance *swiftv1 // // Check for required memcached used for caching // - memcached, err := r.getSwiftMemcached(ctx, helper, instance) + memcached, err := memcachedv1.GetMemcachedByName(ctx, helper, instance.Spec.MemcachedInstance, instance.Namespace) if err != nil { if apierrors.IsNotFound(err) { instance.Status.Conditions.Set(condition.FalseCondition( @@ -264,7 +262,7 @@ func (r *SwiftReconciler) reconcileNormal(ctx context.Context, instance *swiftv1 condition.MemcachedReadyCondition, condition.MemcachedReadyMessage) // run check memcached - end - memcachedServers := strings.Join(memcached.Status.ServerList, ",") + memcachedServers := memcached.GetMemcachedServerListString() // create or update Swift storage swiftStorage, op, err := r.storageCreateOrUpdate(ctx, instance, memcachedServers) @@ -464,23 +462,3 @@ func (r *SwiftReconciler) proxyCreateOrUpdate(ctx context.Context, instance *swi return deployment, op, err } - -// getSwiftMemcached - gets the Memcached instance used for Swift cache backend -func (r *SwiftReconciler) getSwiftMemcached( - ctx context.Context, - h *helper.Helper, - instance *swiftv1.Swift, -) (*memcachedv1.Memcached, error) { - memcached := &memcachedv1.Memcached{} - err := h.GetClient().Get( - ctx, - types.NamespacedName{ - Name: instance.Spec.MemcachedInstance, - Namespace: instance.Namespace, - }, - memcached) - if err != nil { - return nil, err - } - return memcached, err -} diff --git a/go.mod b/go.mod index e7a7d1f6..d4658499 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/onsi/gomega v1.31.1 github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240310115941-5124bc86e50e github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240308201241-e6f2d26d41c4 - github.com/openstack-k8s-operators/infra-operator/apis v0.3.1-0.20240310120756-8b35d05cd24e + github.com/openstack-k8s-operators/infra-operator/apis v0.3.1-0.20240308113717-eaf5876d69c3 github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240310093110-b4b2614f40ba github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240306153230-dc65ab49ebc0 github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240306153230-dc65ab49ebc0 diff --git a/go.sum b/go.sum index ef3d445f..df44f722 100644 --- a/go.sum +++ b/go.sum @@ -85,8 +85,8 @@ github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240310115941-5 github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240310115941-5124bc86e50e/go.mod h1:/cGtVPIqIZY31DvNLVJGIDTn7q0mySia1H9+/uOyKxI= github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240308201241-e6f2d26d41c4 h1:HUoCiTdOdH5JhVuljG0Jh7TTio+55hZVXgwVbMCp6Rw= github.com/openstack-k8s-operators/dataplane-operator/api v0.3.1-0.20240308201241-e6f2d26d41c4/go.mod h1:BLrhsqzkrA8+7ztKBBmBUcJOBthZZcw9UTZs16YrSgk= -github.com/openstack-k8s-operators/infra-operator/apis v0.3.1-0.20240310120756-8b35d05cd24e h1:uHfadgXmCKYwLpLdlV4GRDsnfI5dD13BRUniQsfl8EA= -github.com/openstack-k8s-operators/infra-operator/apis v0.3.1-0.20240310120756-8b35d05cd24e/go.mod h1:qKuzDDDMlAmJn4JWPoUeBEzpAia7J17++hhzR0oPv88= +github.com/openstack-k8s-operators/infra-operator/apis v0.3.1-0.20240308113717-eaf5876d69c3 h1:GJgS/TApDzvNj6lyEr1du6twi539QT2LOu5pqU0dZdA= +github.com/openstack-k8s-operators/infra-operator/apis v0.3.1-0.20240308113717-eaf5876d69c3/go.mod h1:yPqJ+WU8jApuDXNUjpTxMafihuZpX3Yik9ZXqGaxYBQ= github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240310093110-b4b2614f40ba h1:0wfKrQMGwjh/kKTH/UpZGKk91HrnReYieHFG73OC+Vg= github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240310093110-b4b2614f40ba/go.mod h1:gB/IeXuvocAv0yNSf79U1lBHhbx6fdWUB501xFJ0l+A= github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240306153230-dc65ab49ebc0 h1:1Q/9F3SAKvLN9vX+YxwaEB0WvBekj9eakQPoQbI1K6w=