From 542f3b67a006db5695a404f43d5044859d31214a Mon Sep 17 00:00:00 2001 From: Martin Schuppert Date: Thu, 24 Oct 2024 10:26:25 +0200 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 Signed-off-by: Martin Schuppert --- api/go.mod | 2 ++ api/go.sum | 4 ++-- controllers/placementapi_controller.go | 18 +++++++++--------- go.mod | 2 ++ go.sum | 4 ++-- .../functional/placementapi_controller_test.go | 6 +++--- .../kuttl/common/assert_sample_deployment.yaml | 4 ++-- .../tests/placement_deploy_tls/03-assert.yaml | 4 ++-- 8 files changed, 24 insertions(+), 20 deletions(-) diff --git a/api/go.mod b/api/go.mod index a7976e9..ad65bf9 100644 --- a/api/go.mod +++ b/api/go.mod @@ -67,3 +67,5 @@ require ( // mschuppert: map to latest commit from release-4.16 tag // must consistent within modules and service operators replace github.com/openshift/api => github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 //allow-merging + +replace github.com/openstack-k8s-operators/lib-common/modules/common => github.com/stuggi/lib-common/modules/common v0.0.0-20241024081204-572296943a4a diff --git a/api/go.sum b/api/go.sum index cf3b0e6..8a0f5df 100644 --- a/api/go.sum +++ b/api/go.sum @@ -72,8 +72,6 @@ github.com/onsi/ginkgo/v2 v2.20.1 h1:YlVIbqct+ZmnEph770q9Q7NVAz4wwIiVNahee6JyUzo github.com/onsi/ginkgo/v2 v2.20.1/go.mod h1:lG9ey2Z29hR41WMVthyJBGUBcBhGOtoPF2VFMvBXFCI= github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= -github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20241014140317-e5c35d28f3af h1:MNNuYPfaXWf14lfsWGay3WjLjIIu9KN5+iHrLdCMQac= -github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20241014140317-e5c35d28f3af/go.mod h1:EKfyFMU2brJYqR4M2Hwfo5ZLBQxAJXAYfHjpdqX6N5g= 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= @@ -94,6 +92,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stuggi/lib-common/modules/common v0.0.0-20241024081204-572296943a4a h1:EwM7cE7V0YTs4CczUe6vI9ZQl6Yo7dVWeLG5w4M//eE= +github.com/stuggi/lib-common/modules/common v0.0.0-20241024081204-572296943a4a/go.mod h1:tNeup9Xl7j2eaeMslJ/rt59NNEAw7ATf6RuebS/YkSk= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= diff --git a/controllers/placementapi_controller.go b/controllers/placementapi_controller.go index 5f7e524..82ce21a 100644 --- a/controllers/placementapi_controller.go +++ b/controllers/placementapi_controller.go @@ -534,10 +534,10 @@ func (r *PlacementAPIReconciler) ensureServiceExposed( ) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, + condition.CreateServiceReadyErrorMessage, err.Error())) return apiEndpoints, ctrl.Result{}, err @@ -566,19 +566,19 @@ func (r *PlacementAPIReconciler) ensureServiceExposed( ctrlResult, err := svc.CreateOrPatch(ctx, h) if err != nil { instance.Status.Conditions.Set(condition.FalseCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.ErrorReason, condition.SeverityWarning, - condition.ExposeServiceReadyErrorMessage, + condition.CreateServiceReadyErrorMessage, err.Error())) return apiEndpoints, 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 apiEndpoints, ctrlResult, nil } // create service - end @@ -596,7 +596,7 @@ func (r *PlacementAPIReconciler) ensureServiceExposed( } } - instance.Status.Conditions.MarkTrue(condition.ExposeServiceReadyCondition, condition.ExposeServiceReadyMessage) + instance.Status.Conditions.MarkTrue(condition.CreateServiceReadyCondition, condition.CreateServiceReadyMessage) return apiEndpoints, ctrl.Result{}, nil } @@ -747,9 +747,9 @@ func (r *PlacementAPIReconciler) initConditions( condition.DBSyncReadyInitMessage, ), condition.UnknownCondition( - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.InitReason, - condition.ExposeServiceReadyInitMessage, + condition.CreateServiceReadyInitMessage, ), condition.UnknownCondition( condition.InputReadyCondition, diff --git a/go.mod b/go.mod index 96d0bb0..17cc979 100644 --- a/go.mod +++ b/go.mod @@ -86,3 +86,5 @@ replace github.com/openstack-k8s-operators/placement-operator/api => ./api // mschuppert: map to latest commit from release-4.16 tag // must consistent within modules and service operators replace github.com/openshift/api => github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 //allow-merging + +replace github.com/openstack-k8s-operators/lib-common/modules/common => github.com/stuggi/lib-common/modules/common v0.0.0-20241024081204-572296943a4a diff --git a/go.sum b/go.sum index 05ba28a..886e039 100644 --- a/go.sum +++ b/go.sum @@ -79,8 +79,6 @@ github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094 h1:J1wuGhVxpsHykZBa6 github.com/openshift/api v0.0.0-20240830023148-b7d0481c9094/go.mod h1:CxgbWAlvu2iQB0UmKTtRu1YfepRg1/vJ64n2DlIEVz4= github.com/openstack-k8s-operators/keystone-operator/api v0.4.1-0.20241018180515-61e711f07467 h1:AJVVQrnWg2o/dVOgu++oHBMFxFe27R/a52qGGjxviRc= github.com/openstack-k8s-operators/keystone-operator/api v0.4.1-0.20241018180515-61e711f07467/go.mod h1:saoorrsPo3DzDPGM6PJ8sQJBNuNRGCHjRHChRQmkoQ0= -github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20241014140317-e5c35d28f3af h1:MNNuYPfaXWf14lfsWGay3WjLjIIu9KN5+iHrLdCMQac= -github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20241014140317-e5c35d28f3af/go.mod h1:EKfyFMU2brJYqR4M2Hwfo5ZLBQxAJXAYfHjpdqX6N5g= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20241014140317-e5c35d28f3af h1:fevDUHmqcnI4wDTKupKe/CcgVdgNpZXWkJx8u0/xEXs= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.4.1-0.20241014140317-e5c35d28f3af/go.mod h1:djfljx3jfHqywhY3oDvPg/GLKwiFVkds6v7P7/Yg+8g= github.com/openstack-k8s-operators/lib-common/modules/test v0.4.1-0.20241014140317-e5c35d28f3af h1:u5yJ/rV9VBMjKIcsu16/3rhiPcBxZN2sPqxnZHoRrNc= @@ -107,6 +105,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stuggi/lib-common/modules/common v0.0.0-20241024081204-572296943a4a h1:EwM7cE7V0YTs4CczUe6vI9ZQl6Yo7dVWeLG5w4M//eE= +github.com/stuggi/lib-common/modules/common v0.0.0-20241024081204-572296943a4a/go.mod h1:tNeup9Xl7j2eaeMslJ/rt59NNEAw7ATf6RuebS/YkSk= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= diff --git a/tests/functional/placementapi_controller_test.go b/tests/functional/placementapi_controller_test.go index 9c7a168..74d9d88 100644 --- a/tests/functional/placementapi_controller_test.go +++ b/tests/functional/placementapi_controller_test.go @@ -114,7 +114,7 @@ var _ = Describe("PlacementAPI controller", func() { unknownConditions := []condition.Type{ condition.DBReadyCondition, condition.DBSyncReadyCondition, - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, condition.ServiceConfigReadyCondition, condition.DeploymentReadyCondition, condition.KeystoneServiceReadyCondition, @@ -510,7 +510,7 @@ var _ = Describe("PlacementAPI controller", func() { th.ExpectCondition( names.PlacementAPIName, ConditionGetterFunc(PlacementConditionGetter), - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, corev1.ConditionUnknown, ) @@ -532,7 +532,7 @@ var _ = Describe("PlacementAPI controller", func() { th.ExpectCondition( names.PlacementAPIName, ConditionGetterFunc(PlacementConditionGetter), - condition.ExposeServiceReadyCondition, + condition.CreateServiceReadyCondition, corev1.ConditionTrue, ) }) diff --git a/tests/kuttl/common/assert_sample_deployment.yaml b/tests/kuttl/common/assert_sample_deployment.yaml index 821a843..2c71edf 100644 --- a/tests/kuttl/common/assert_sample_deployment.yaml +++ b/tests/kuttl/common/assert_sample_deployment.yaml @@ -36,10 +36,10 @@ status: reason: Ready status: "True" type: DeploymentReady - - message: Exposing service completed + - message: Create service completed reason: Ready status: "True" - type: ExposeServiceReady + type: CreateServiceReady - message: Input data complete reason: Ready status: "True" diff --git a/tests/kuttl/tests/placement_deploy_tls/03-assert.yaml b/tests/kuttl/tests/placement_deploy_tls/03-assert.yaml index c5f4afa..07eaf70 100644 --- a/tests/kuttl/tests/placement_deploy_tls/03-assert.yaml +++ b/tests/kuttl/tests/placement_deploy_tls/03-assert.yaml @@ -43,10 +43,10 @@ status: reason: Ready status: "True" type: DeploymentReady - - message: Exposing service completed + - message: Create service completed reason: Ready status: "True" - type: ExposeServiceReady + type: CreateServiceReady - message: Input data complete reason: Ready status: "True"