From f6d94d4cc6396f422acc185e377d08a6a05fdfee Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Tue, 29 Oct 2024 17:25:33 +0100 Subject: [PATCH] Switch to use new CreateServiceReadyCondition The current ExposeServiceReadyCondition can be confusing since it just reflects if the k8s service got created, but not the route to expose the public endpoint. This changes to a new CreateServiceReadyCondition to prevent this. Jira: OSPRH-4164 Depends-On: https://github.com/openstack-k8s-operators/lib-common/pull/572 Signed-off-by: Martin Schuppert --- apis/go.mod | 2 +- apis/go.sum | 4 ++-- controllers/memcached/memcached_controller.go | 12 +++++------ controllers/network/dnsmasq_controller.go | 14 ++++++------- controllers/redis/redis_controller.go | 20 +++++++++---------- go.mod | 2 +- go.sum | 4 ++-- tests/functional/dnsmasq_controller_test.go | 2 +- tests/kuttl/tests/memcached/03-assert.yaml | 8 ++++---- tests/kuttl/tests/redis/01-assert.yaml | 8 ++++---- tests/kuttl/tests/redis/02-assert.yaml | 8 ++++---- tests/kuttl/tests/redis/06-assert.yaml | 8 ++++---- 12 files changed, 46 insertions(+), 46 deletions(-) diff --git a/apis/go.mod b/apis/go.mod index 9343515d..11423555 100644 --- a/apis/go.mod +++ b/apis/go.mod @@ -6,7 +6,7 @@ require ( github.com/go-logr/logr v1.4.2 github.com/onsi/ginkgo/v2 v2.20.1 github.com/onsi/gomega v1.34.1 - github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241025164019-30baa23bf6f1 + github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333 golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 k8s.io/api v0.29.10 k8s.io/apimachinery v0.29.10 diff --git a/apis/go.sum b/apis/go.sum index 83bf0dba..5f2acd10 100644 --- a/apis/go.sum +++ b/apis/go.sum @@ -76,8 +76,8 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6Beb1gQ96Ptej9AE/BvwCBiRj1E= github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4= -github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241025164019-30baa23bf6f1 h1:D4H+BMVKTjgYWptCBs7Qt0rk0K/H8PnjJKoMlozoQ4g= -github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241025164019-30baa23bf6f1/go.mod h1:tNeup9Xl7j2eaeMslJ/rt59NNEAw7ATf6RuebS/YkSk= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333 h1:yejekTWudX5af3mCJQ1MUPLEa0X6sIsklf07o9KilRk= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= diff --git a/controllers/memcached/memcached_controller.go b/controllers/memcached/memcached_controller.go index edf18af5..d6f2243a 100644 --- a/controllers/memcached/memcached_controller.go +++ b/controllers/memcached/memcached_controller.go @@ -167,7 +167,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct // TLS cert secrets condition.UnknownCondition(condition.TLSInputReadyCondition, condition.InitReason, condition.InputReadyInitMessage), // endpoint for adoption redirect - condition.UnknownCondition(condition.ExposeServiceReadyCondition, condition.InitReason, condition.ExposeServiceReadyInitMessage), + condition.UnknownCondition(condition.CreateServiceReadyCondition, condition.InitReason, condition.CreateServiceReadyInitMessage), // configmap generation condition.UnknownCondition(condition.ServiceConfigReadyCondition, condition.InitReason, condition.ServiceConfigReadyInitMessage), // memcache pods ready @@ -315,20 +315,20 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct commonsvc, err := commonservice.NewService(memcached.HeadlessService(instance), time.Duration(5)*time.Second, nil) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, + condition.CreateServiceReadyErrorMessage, err.Error())) return ctrl.Result{}, err } sres, serr := commonsvc.CreateOrPatch(ctx, helper) if serr != nil { instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, + condition.CreateServiceReadyErrorMessage, serr.Error())) return sres, serr } @@ -339,7 +339,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct instance.Status.ServerList = serverList instance.Status.ServerListWithInet = serverListWithInet - instance.Status.Conditions.MarkTrue(condition.ExposeServiceReadyCondition, condition.ExposeServiceReadyMessage) + instance.Status.Conditions.MarkTrue(condition.CreateServiceReadyCondition, condition.CreateServiceReadyMessage) // Statefulset for stable names commonstatefulset := commonstatefulset.NewStatefulSet(memcached.StatefulSet(instance, hashOfHashes), time.Duration(5)*time.Second) diff --git a/controllers/network/dnsmasq_controller.go b/controllers/network/dnsmasq_controller.go index 9d1360ce..bf7c50a9 100644 --- a/controllers/network/dnsmasq_controller.go +++ b/controllers/network/dnsmasq_controller.go @@ -390,10 +390,10 @@ func (r *DNSMasqReconciler) reconcileNormal(ctx context.Context, instance *netwo ) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, + condition.CreateServiceReadyErrorMessage, err.Error())) return ctrl.Result{}, err @@ -406,19 +406,19 @@ func (r *DNSMasqReconciler) reconcileNormal(ctx context.Context, instance *netwo ctrlResult, err := svc.CreateOrPatch(ctx, helper) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, + condition.CreateServiceReadyErrorMessage, err.Error())) return ctrlResult, err } else if (ctrlResult != ctrl.Result{}) { instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.RequestedReason, condition.SeverityInfo, - condition.ExposeServiceReadyRunningMessage)) + condition.CreateServiceReadyRunningMessage)) return ctrlResult, nil } @@ -430,7 +430,7 @@ func (r *DNSMasqReconciler) reconcileNormal(ctx context.Context, instance *netwo // create service - end - instance.Status.Conditions.MarkTrue(condition.ExposeServiceReadyCondition, condition.ExposeServiceReadyMessage) + instance.Status.Conditions.MarkTrue(condition.CreateServiceReadyCondition, condition.CreateServiceReadyMessage) // Define a new Deployment object deplDef := dnsmasq.Deployment(instance, instance.Status.Hash[common.InputHashName], serviceLabels, serviceAnnotations, configMaps) diff --git a/controllers/redis/redis_controller.go b/controllers/redis/redis_controller.go index dd7c5746..6ead9af9 100644 --- a/controllers/redis/redis_controller.go +++ b/controllers/redis/redis_controller.go @@ -167,7 +167,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct // TLS cert secrets condition.UnknownCondition(condition.TLSInputReadyCondition, condition.InitReason, condition.InputReadyInitMessage), // endpoint for adoption redirect - condition.UnknownCondition(condition.ExposeServiceReadyCondition, condition.InitReason, condition.ExposeServiceReadyInitMessage), + condition.UnknownCondition(condition.CreateServiceReadyCondition, condition.InitReason, condition.CreateServiceReadyInitMessage), // configmap generation condition.UnknownCondition(condition.ServiceConfigReadyCondition, condition.InitReason, condition.ServiceConfigReadyInitMessage), // redis pods ready @@ -309,20 +309,20 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct headless, err := commonservice.NewService(redis.HeadlessService(instance), time.Duration(5)*time.Second, nil) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, + condition.CreateServiceReadyErrorMessage, err.Error())) return ctrl.Result{}, err } hlres, hlerr := headless.CreateOrPatch(ctx, helper) if hlerr != nil { instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, + condition.CreateServiceReadyErrorMessage, err.Error())) return hlres, hlerr } @@ -331,24 +331,24 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (result ct commonsvc, err := commonservice.NewService(redis.Service(instance), time.Duration(5)*time.Second, nil) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, + condition.CreateServiceReadyErrorMessage, err.Error())) return ctrl.Result{}, err } sres, serr := commonsvc.CreateOrPatch(ctx, helper) if serr != nil { instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, + condition.CreateServiceReadyErrorMessage, err.Error())) return sres, serr } - instance.Status.Conditions.MarkTrue(condition.ExposeServiceReadyCondition, condition.ExposeServiceReadyMessage) + instance.Status.Conditions.MarkTrue(condition.CreateServiceReadyCondition, condition.CreateServiceReadyMessage) // // Reconstruct the state of the redis resource based on the deployment and its pods diff --git a/go.mod b/go.mod index 2640700d..6dbe4e50 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/onsi/ginkgo/v2 v2.20.1 github.com/onsi/gomega v1.34.1 github.com/openstack-k8s-operators/infra-operator/apis v0.3.0 - github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241025164019-30baa23bf6f1 + github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333 github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241025164019-30baa23bf6f1 github.com/rabbitmq/cluster-operator/v2 v2.9.0 go.uber.org/zap v1.27.0 diff --git a/go.sum b/go.sum index 778cac25..fd7a3a06 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,8 @@ github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6Beb1gQ96Ptej9AE/BvwCBiRj1E= github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4= -github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241025164019-30baa23bf6f1 h1:D4H+BMVKTjgYWptCBs7Qt0rk0K/H8PnjJKoMlozoQ4g= -github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241025164019-30baa23bf6f1/go.mod h1:tNeup9Xl7j2eaeMslJ/rt59NNEAw7ATf6RuebS/YkSk= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333 h1:yejekTWudX5af3mCJQ1MUPLEa0X6sIsklf07o9KilRk= +github.com/openstack-k8s-operators/lib-common/modules/common v0.5.1-0.20241029151503-4878b3fa3333/go.mod h1:YpNTuJhDWhbXM50O3qBkhO7M+OOyRmWkNVmJ4y3cyFs= github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241025164019-30baa23bf6f1 h1:7tlv11dDu2fKxjhbEtrjNAPRE7q0FfmCNX0sxOKdMJs= github.com/openstack-k8s-operators/lib-common/modules/test v0.5.1-0.20241025164019-30baa23bf6f1/go.mod h1:LV0jo5etIsGyINpmB37i4oWR8zU6ApIuh7fsqGGA41o= github.com/openstack-k8s-operators/rabbitmq-cluster-operator/v2 v2.6.1-0.20241017142550-a3524acedd49 h1:/7SnnHfGCH/dwuZFNUx54zw4cnwv2w6hjONq16aoowM= diff --git a/tests/functional/dnsmasq_controller_test.go b/tests/functional/dnsmasq_controller_test.go index 3bd905db..b1e12def 100644 --- a/tests/functional/dnsmasq_controller_test.go +++ b/tests/functional/dnsmasq_controller_test.go @@ -150,7 +150,7 @@ var _ = Describe("DNSMasq controller", func() { th.ExpectCondition( dnsMasqName, ConditionGetterFunc(DNSMasqConditionGetter), - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, corev1.ConditionTrue, ) diff --git a/tests/kuttl/tests/memcached/03-assert.yaml b/tests/kuttl/tests/memcached/03-assert.yaml index f14f14fb..8b44966d 100644 --- a/tests/kuttl/tests/memcached/03-assert.yaml +++ b/tests/kuttl/tests/memcached/03-assert.yaml @@ -11,14 +11,14 @@ status: reason: Ready status: "True" type: Ready - - message: Deployment completed + - message: Create service completed reason: Ready status: "True" - type: DeploymentReady - - message: Exposing service completed + type: CreateServiceReady + - message: Deployment completed reason: Ready status: "True" - type: ExposeServiceReady + type: DeploymentReady - message: RoleBinding created reason: Ready status: "True" diff --git a/tests/kuttl/tests/redis/01-assert.yaml b/tests/kuttl/tests/redis/01-assert.yaml index 69989fa6..2f65f31e 100644 --- a/tests/kuttl/tests/redis/01-assert.yaml +++ b/tests/kuttl/tests/redis/01-assert.yaml @@ -22,14 +22,14 @@ status: reason: Ready status: "True" type: Ready - - message: Deployment completed + - message: Create service completed reason: Ready status: "True" - type: DeploymentReady - - message: Exposing service completed + type: CreateServiceReady + - message: Deployment completed reason: Ready status: "True" - type: ExposeServiceReady + type: DeploymentReady - message: RoleBinding created reason: Ready status: "True" diff --git a/tests/kuttl/tests/redis/02-assert.yaml b/tests/kuttl/tests/redis/02-assert.yaml index 9e4d0517..cf50f209 100644 --- a/tests/kuttl/tests/redis/02-assert.yaml +++ b/tests/kuttl/tests/redis/02-assert.yaml @@ -22,14 +22,14 @@ status: reason: Ready status: "True" type: Ready - - message: Deployment completed + - message: Create service completed reason: Ready status: "True" - type: DeploymentReady - - message: Exposing service completed + type: CreateServiceReady + - message: Deployment completed reason: Ready status: "True" - type: ExposeServiceReady + type: DeploymentReady - message: RoleBinding created reason: Ready status: "True" diff --git a/tests/kuttl/tests/redis/06-assert.yaml b/tests/kuttl/tests/redis/06-assert.yaml index 2c976ecc..2e9e73d6 100644 --- a/tests/kuttl/tests/redis/06-assert.yaml +++ b/tests/kuttl/tests/redis/06-assert.yaml @@ -10,14 +10,14 @@ status: reason: Ready status: "True" type: Ready - - message: Deployment completed + - message: Create service completed reason: Ready status: "True" - type: DeploymentReady - - message: Exposing service completed + type: CreateServiceReady + - message: Deployment completed reason: Ready status: "True" - type: ExposeServiceReady + type: DeploymentReady - message: RoleBinding created reason: Ready status: "True"