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 e24a659 commit 1e99a4b
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 36 deletions.
2 changes: 2 additions & 0 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,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 @@ -96,6 +94,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/novaapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ func (r *NovaAPIReconciler) initConditions(
condition.DeploymentReadyInitMessage,
),
condition.UnknownCondition(
condition.ExposeServiceReadyCondition,
condition.CreateServiceReadyCondition,
condition.InitReason,
condition.ExposeServiceReadyInitMessage,
condition.CreateServiceReadyInitMessage,
),
condition.UnknownCondition(
condition.KeystoneEndpointReadyCondition,
Expand Down Expand Up @@ -664,10 +664,10 @@ func (r *NovaAPIReconciler) 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 nil, ctrl.Result{}, err
Expand Down Expand Up @@ -696,19 +696,19 @@ func (r *NovaAPIReconciler) 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 nil, 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 nil, ctrlResult, nil
}
// create service - end
Expand All @@ -725,7 +725,7 @@ func (r *NovaAPIReconciler) ensureServiceExposed(
return nil, ctrl.Result{}, err
}
}
instance.Status.Conditions.MarkTrue(condition.ExposeServiceReadyCondition, condition.ExposeServiceReadyMessage)
instance.Status.Conditions.MarkTrue(condition.CreateServiceReadyCondition, condition.CreateServiceReadyMessage)

return apiEndpoints, ctrl.Result{}, nil
}
Expand Down
20 changes: 10 additions & 10 deletions controllers/novametadata_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ func (r *NovaMetadataReconciler) Reconcile(ctx context.Context, req ctrl.Request

// We have to wait until our service is fully exposed so that we can
// generate the compute config containing the metadata host
if !instance.Status.Conditions.IsTrue(condition.ExposeServiceReadyCondition) {
if !instance.Status.Conditions.IsTrue(condition.CreateServiceReadyCondition) {
Log.Info("Waiting for the service to be exposed before generating compute configuration")
return ctrl.Result{}, nil
}
Expand Down Expand Up @@ -375,9 +375,9 @@ func (r *NovaMetadataReconciler) initConditions(
condition.DeploymentReadyInitMessage,
),
condition.UnknownCondition(
condition.ExposeServiceReadyCondition,
condition.CreateServiceReadyCondition,
condition.InitReason,
condition.ExposeServiceReadyInitMessage,
condition.CreateServiceReadyInitMessage,
),
condition.UnknownCondition(
condition.NetworkAttachmentsReadyCondition,
Expand Down Expand Up @@ -669,10 +669,10 @@ func (r *NovaMetadataReconciler) 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 "", ctrl.Result{}, err
}
Expand All @@ -686,19 +686,19 @@ func (r *NovaMetadataReconciler) 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 "", 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, err
}
// create service - end
Expand All @@ -715,7 +715,7 @@ func (r *NovaMetadataReconciler) ensureServiceExposed(
return "", ctrl.Result{}, err
}

instance.Status.Conditions.MarkTrue(condition.ExposeServiceReadyCondition, condition.ExposeServiceReadyMessage)
instance.Status.Conditions.MarkTrue(condition.CreateServiceReadyCondition, condition.CreateServiceReadyMessage)

return apiEndpoint, ctrl.Result{}, nil
}
Expand Down
18 changes: 9 additions & 9 deletions controllers/novanovncproxy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ func (r *NovaNoVNCProxyReconciler) initConditions(
condition.DeploymentReadyInitMessage,
),
condition.UnknownCondition(
condition.ExposeServiceReadyCondition,
condition.CreateServiceReadyCondition,
condition.InitReason,
condition.ExposeServiceReadyInitMessage,
condition.CreateServiceReadyInitMessage,
),
condition.UnknownCondition(
condition.NetworkAttachmentsReadyCondition,
Expand Down Expand Up @@ -614,10 +614,10 @@ func (r *NovaNoVNCProxyReconciler) 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 ctrl.Result{}, err
Expand Down Expand Up @@ -646,23 +646,23 @@ func (r *NovaNoVNCProxyReconciler) 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 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
}
// create service - end
instance.Status.Conditions.MarkTrue(condition.ExposeServiceReadyCondition, condition.ExposeServiceReadyMessage)
instance.Status.Conditions.MarkTrue(condition.CreateServiceReadyCondition, condition.CreateServiceReadyMessage)

return ctrl.Result{}, nil
}
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ replace github.com/openstack-k8s-operators/nova-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 @@ -81,8 +81,6 @@ github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20241018085734-6
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20241018085734-6534d4914f87/go.mod h1:J9oUh3eGBvAFfyUMiPxPRBSxAcO8rnwITN4RTh/It+8=
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 Down Expand Up @@ -111,6 +109,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
4 changes: 2 additions & 2 deletions test/functional/nova_metadata_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ var _ = Describe("NovaMetadata controller", func() {
th.ExpectCondition(
novaNames.MetadataName,
ConditionGetterFunc(NovaMetadataConditionGetter),
condition.ExposeServiceReadyCondition,
condition.CreateServiceReadyCondition,
corev1.ConditionTrue,
)
service := th.GetService(novaNames.InternalNovaMetadataServiceName)
Expand Down Expand Up @@ -445,7 +445,7 @@ var _ = Describe("NovaMetadata controller", func() {
th.ExpectCondition(
cell1.MetadataName,
ConditionGetterFunc(NovaMetadataConditionGetter),
condition.ExposeServiceReadyCondition,
condition.CreateServiceReadyCondition,
corev1.ConditionTrue,
)
service := th.GetService(types.NamespacedName{Namespace: cell1.MetadataName.Namespace, Name: "nova-metadata-cell1-internal"})
Expand Down
2 changes: 1 addition & 1 deletion test/functional/nova_novncproxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ var _ = Describe("NovaNoVNCProxy controller", func() {
th.ExpectCondition(
cell1.NoVNCProxyName,
ConditionGetterFunc(NoVNCProxyConditionGetter),
condition.ExposeServiceReadyCondition,
condition.CreateServiceReadyCondition,
corev1.ConditionTrue,
)
service := th.GetService(types.NamespacedName{Namespace: cell1.NoVNCProxyName.Namespace, Name: "nova-novncproxy-cell1-public"})
Expand Down
2 changes: 1 addition & 1 deletion test/functional/novaapi_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ var _ = Describe("NovaAPI controller", func() {
th.ExpectCondition(
novaNames.APIName,
ConditionGetterFunc(NovaAPIConditionGetter),
condition.ExposeServiceReadyCondition,
condition.CreateServiceReadyCondition,
corev1.ConditionTrue,
)
public := th.GetService(novaNames.PublicNovaServiceName)
Expand Down

0 comments on commit 1e99a4b

Please sign in to comment.