Skip to content

Commit

Permalink
Switch to use new CreateServiceReadyCondition
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
stuggi committed Oct 24, 2024
1 parent 270dd04 commit 542f3b6
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 20 deletions.
2 changes: 2 additions & 0 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions api/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
18 changes: 9 additions & 9 deletions controllers/placementapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand All @@ -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=
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/placementapi_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -510,7 +510,7 @@ var _ = Describe("PlacementAPI controller", func() {
th.ExpectCondition(
names.PlacementAPIName,
ConditionGetterFunc(PlacementConditionGetter),
condition.ExposeServiceReadyCondition,
condition.CreateServiceReadyCondition,
corev1.ConditionUnknown,
)

Expand All @@ -532,7 +532,7 @@ var _ = Describe("PlacementAPI controller", func() {
th.ExpectCondition(
names.PlacementAPIName,
ConditionGetterFunc(PlacementConditionGetter),
condition.ExposeServiceReadyCondition,
condition.CreateServiceReadyCondition,
corev1.ConditionTrue,
)
})
Expand Down
4 changes: 2 additions & 2 deletions tests/kuttl/common/assert_sample_deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions tests/kuttl/tests/placement_deploy_tls/03-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 542f3b6

Please sign in to comment.