Skip to content

Commit

Permalink
Merge pull request #169 from stuggi/common_memcached
Browse files Browse the repository at this point in the history
Use common memcached.GetMemcachedServerListWithInetString()
  • Loading branch information
openshift-merge-bot[bot] authored Mar 12, 2024
2 parents 5c2124f + 76aec54 commit 4019663
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 27 deletions.
26 changes: 2 additions & 24 deletions controllers/swift_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package controllers
import (
"context"
"fmt"
"strings"
"time"

"github.com/go-logr/logr"
Expand All @@ -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"
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 4019663

Please sign in to comment.