diff --git a/api/go.mod b/api/go.mod index 4656dbf0..7931d0b4 100644 --- a/api/go.mod +++ b/api/go.mod @@ -3,7 +3,7 @@ module github.com/openstack-k8s-operators/placement-operator/api go 1.20 require ( - github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240313084555-12e3d33d7a2d + github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240325204456-ec1f5f6464ee k8s.io/api v0.28.7 k8s.io/apimachinery v0.28.7 sigs.k8s.io/controller-runtime v0.16.5 diff --git a/api/go.sum b/api/go.sum index 74b97b4c..54d2a08b 100644 --- a/api/go.sum +++ b/api/go.sum @@ -64,8 +64,7 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/onsi/ginkgo/v2 v2.16.0 h1:7q1w9frJDzninhXxjZd+Y/x54XNjG/UlRLIYPZafsPM= github.com/onsi/gomega v1.31.1 h1:KYppCUK+bUgAZwHOu7EXVBKyQA6ILvOESHkn/tgoqvo= -github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240313084555-12e3d33d7a2d h1:9KrN+ILfO+BmTbAoXEfRIJd9Exw79oEHOIhsH31L5Ow= -github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240313084555-12e3d33d7a2d/go.mod h1:DL+Ts0k+fzgZmx0XxWArIeAmdKuTkPa1I5DThdybfmE= +github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240325204456-ec1f5f6464ee h1:z92Tw9DJdjLyNLwXEMMgV+9h+VfWRwzn3bsNwXzLI0M= 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/placementapi_controller.go b/controllers/placementapi_controller.go index 3957dab5..af7d7d4b 100644 --- a/controllers/placementapi_controller.go +++ b/controllers/placementapi_controller.go @@ -256,6 +256,10 @@ func (r *PlacementAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request Log.Error(err, "Failed to create lib-common Helper") return ctrl.Result{}, err } + + // Save a copy of the condtions so that we can restore the LastTransitionTime + // when a condition's state doesn't change. + savedConditions := instance.Status.Conditions.DeepCopy() // initialize status fields if err = r.initStatus(ctx, h, instance); err != nil { return ctrl.Result{}, err @@ -263,6 +267,7 @@ func (r *PlacementAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request // Always patch the instance status when exiting this function so we can persist any changes. defer func() { + condition.RestoreLastTransitionTimes(&instance.Status.Conditions, savedConditions) // update the Ready condition based on the sub conditions if instance.Status.Conditions.AllSubConditionIsTrue() { instance.Status.Conditions.MarkTrue( @@ -752,77 +757,77 @@ func (r *PlacementAPIReconciler) initConditions( ) error { if instance.Status.Conditions == nil { instance.Status.Conditions = condition.Conditions{} - // initialize conditions used later as Status=Unknown - cl := condition.CreateList( - condition.UnknownCondition( - condition.DBReadyCondition, - condition.InitReason, - condition.DBReadyInitMessage, - ), - condition.UnknownCondition( - condition.DBSyncReadyCondition, - condition.InitReason, - condition.DBSyncReadyInitMessage, - ), - condition.UnknownCondition( - condition.ExposeServiceReadyCondition, - condition.InitReason, - condition.ExposeServiceReadyInitMessage, - ), - condition.UnknownCondition( - condition.InputReadyCondition, - condition.InitReason, - condition.InputReadyInitMessage, - ), - condition.UnknownCondition( - condition.ServiceConfigReadyCondition, - condition.InitReason, - condition.ServiceConfigReadyInitMessage, - ), - condition.UnknownCondition( - condition.DeploymentReadyCondition, - condition.InitReason, - condition.DeploymentReadyInitMessage, - ), - // right now we have no dedicated KeystoneServiceReadyInitMessage and KeystoneEndpointReadyInitMessage - condition.UnknownCondition( - condition.KeystoneServiceReadyCondition, - condition.InitReason, - "Service registration not started", - ), - condition.UnknownCondition( - condition.KeystoneEndpointReadyCondition, - condition.InitReason, - "KeystoneEndpoint not created", - ), - condition.UnknownCondition( - condition.NetworkAttachmentsReadyCondition, - condition.InitReason, - condition.NetworkAttachmentsReadyInitMessage, - ), - // service account, role, rolebinding conditions - condition.UnknownCondition( - condition.ServiceAccountReadyCondition, - condition.InitReason, - condition.ServiceAccountReadyInitMessage, - ), - condition.UnknownCondition( - condition.RoleReadyCondition, - condition.InitReason, - condition.RoleReadyInitMessage, - ), - condition.UnknownCondition( - condition.RoleBindingReadyCondition, - condition.InitReason, - condition.RoleBindingReadyInitMessage), - condition.UnknownCondition( - condition.TLSInputReadyCondition, - condition.InitReason, - condition.InputReadyInitMessage), - ) - - instance.Status.Conditions.Init(&cl) } + // initialize conditions used later as Status=Unknown + cl := condition.CreateList( + condition.UnknownCondition( + condition.DBReadyCondition, + condition.InitReason, + condition.DBReadyInitMessage, + ), + condition.UnknownCondition( + condition.DBSyncReadyCondition, + condition.InitReason, + condition.DBSyncReadyInitMessage, + ), + condition.UnknownCondition( + condition.ExposeServiceReadyCondition, + condition.InitReason, + condition.ExposeServiceReadyInitMessage, + ), + condition.UnknownCondition( + condition.InputReadyCondition, + condition.InitReason, + condition.InputReadyInitMessage, + ), + condition.UnknownCondition( + condition.ServiceConfigReadyCondition, + condition.InitReason, + condition.ServiceConfigReadyInitMessage, + ), + condition.UnknownCondition( + condition.DeploymentReadyCondition, + condition.InitReason, + condition.DeploymentReadyInitMessage, + ), + // right now we have no dedicated KeystoneServiceReadyInitMessage and KeystoneEndpointReadyInitMessage + condition.UnknownCondition( + condition.KeystoneServiceReadyCondition, + condition.InitReason, + "Service registration not started", + ), + condition.UnknownCondition( + condition.KeystoneEndpointReadyCondition, + condition.InitReason, + "KeystoneEndpoint not created", + ), + condition.UnknownCondition( + condition.NetworkAttachmentsReadyCondition, + condition.InitReason, + condition.NetworkAttachmentsReadyInitMessage, + ), + // service account, role, rolebinding conditions + condition.UnknownCondition( + condition.ServiceAccountReadyCondition, + condition.InitReason, + condition.ServiceAccountReadyInitMessage, + ), + condition.UnknownCondition( + condition.RoleReadyCondition, + condition.InitReason, + condition.RoleReadyInitMessage, + ), + condition.UnknownCondition( + condition.RoleBindingReadyCondition, + condition.InitReason, + condition.RoleBindingReadyInitMessage), + condition.UnknownCondition( + condition.TLSInputReadyCondition, + condition.InitReason, + condition.InputReadyInitMessage), + ) + + instance.Status.Conditions.Init(&cl) return nil } diff --git a/go.mod b/go.mod index ac0dc4d8..cdc0cb4b 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,7 @@ require ( github.com/onsi/ginkgo/v2 v2.16.0 github.com/onsi/gomega v1.31.1 github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240310093110-b4b2614f40ba - github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240313084555-12e3d33d7a2d + github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240325204456-ec1f5f6464ee github.com/openstack-k8s-operators/lib-common/modules/test v0.3.1-0.20240313084555-12e3d33d7a2d github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240308170012-6b04e3e9b9ee github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20240216174613-3d349f26e681 diff --git a/go.sum b/go.sum index 575f57f9..55fc0091 100644 --- a/go.sum +++ b/go.sum @@ -80,8 +80,8 @@ github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7 h1:rncLxJBpFGqBztyxC github.com/openshift/api v0.0.0-20230414143018-3367bc7e6ac7/go.mod h1:ctXNyWanKEjGj8sss1KjjHQ3ENKFm33FFnS5BKaIPh4= github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240310093110-b4b2614f40ba h1:0wfKrQMGwjh/kKTH/UpZGKk91HrnReYieHFG73OC+Vg= github.com/openstack-k8s-operators/keystone-operator/api v0.3.1-0.20240310093110-b4b2614f40ba/go.mod h1:gB/IeXuvocAv0yNSf79U1lBHhbx6fdWUB501xFJ0l+A= -github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240313084555-12e3d33d7a2d h1:9KrN+ILfO+BmTbAoXEfRIJd9Exw79oEHOIhsH31L5Ow= -github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240313084555-12e3d33d7a2d/go.mod h1:DL+Ts0k+fzgZmx0XxWArIeAmdKuTkPa1I5DThdybfmE= +github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240325204456-ec1f5f6464ee h1:z92Tw9DJdjLyNLwXEMMgV+9h+VfWRwzn3bsNwXzLI0M= +github.com/openstack-k8s-operators/lib-common/modules/common v0.3.1-0.20240325204456-ec1f5f6464ee/go.mod h1:DL+Ts0k+fzgZmx0XxWArIeAmdKuTkPa1I5DThdybfmE= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240313084555-12e3d33d7a2d h1:2IhoIsgtz+TCO3zI5x1YAgT0AkGRio82lvdSjbbQcIo= github.com/openstack-k8s-operators/lib-common/modules/openstack v0.3.1-0.20240313084555-12e3d33d7a2d/go.mod h1:ghnFgNIzj4amS897wEto+L+jYzDSg2cJ6y32RNfFGhk= github.com/openstack-k8s-operators/lib-common/modules/test v0.3.1-0.20240313084555-12e3d33d7a2d h1:o8KgOTpuphMyhYIG6xIi2AYvmkAEfeex2riWCfZOnyk=