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

Depends-On: openstack-k8s-operators/lib-common#572

Signed-off-by: Martin Schuppert <[email protected]>
  • Loading branch information
stuggi committed Oct 30, 2024
1 parent 6458535 commit f6d94d4
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion apis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions apis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
12 changes: 6 additions & 6 deletions controllers/memcached/memcached_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions controllers/network/dnsmasq_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand All @@ -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)
Expand Down
20 changes: 10 additions & 10 deletions controllers/redis/redis_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/dnsmasq_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var _ = Describe("DNSMasq controller", func() {
th.ExpectCondition(
dnsMasqName,
ConditionGetterFunc(DNSMasqConditionGetter),
condition.ExposeServiceReadyCondition,
condition.CreateServiceReadyCondition,
corev1.ConditionTrue,
)

Expand Down
8 changes: 4 additions & 4 deletions tests/kuttl/tests/memcached/03-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions tests/kuttl/tests/redis/01-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions tests/kuttl/tests/redis/02-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions tests/kuttl/tests/redis/06-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit f6d94d4

Please sign in to comment.