From 43153af3cbaaf9b0f8ccb1fe6b23374b3837705d Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Sat, 4 May 2024 18:07:07 -0400 Subject: [PATCH 1/2] Enforce update order for OVN for Ctlplane/EDPM Jira: OSPRH-6732 --- .../core/openstackversion_controller.go | 16 +------ pkg/openstack/barbican.go | 17 +++++++ pkg/openstack/cinder.go | 23 ++++++++++ pkg/openstack/designate.go | 25 +++++++++++ pkg/openstack/dnsmasq.go | 12 +++++ pkg/openstack/galera.go | 13 ++++++ pkg/openstack/glance.go | 13 ++++++ pkg/openstack/heat.go | 17 +++++++ pkg/openstack/horizon.go | 13 ++++++ pkg/openstack/ironic.go | 23 ++++++++++ pkg/openstack/keystone.go | 12 +++++ pkg/openstack/manila.go | 21 +++++++++ pkg/openstack/memcached.go | 13 ++++++ pkg/openstack/neutron.go | 13 ++++++ pkg/openstack/nova.go | 21 +++++++++ pkg/openstack/octavia.go | 22 ++++++++++ pkg/openstack/openstackclient.go | 7 +++ pkg/openstack/ovn.go | 40 +++++++++++++++++ pkg/openstack/placement.go | 12 +++++ pkg/openstack/rabbitmq.go | 13 ++++++ pkg/openstack/swift.go | 19 ++++++++ pkg/openstack/telemetry.go | 32 ++++++++++++++ pkg/openstack/version.go | 44 +++++++++++++++++++ 23 files changed, 427 insertions(+), 14 deletions(-) diff --git a/controllers/core/openstackversion_controller.go b/controllers/core/openstackversion_controller.go index 04b844603..b63c3a6ef 100644 --- a/controllers/core/openstackversion_controller.go +++ b/controllers/core/openstackversion_controller.go @@ -56,16 +56,6 @@ func SetupVersionDefaults() { envContainerImages = localVars } -func compareStringPointers(a, b *string) bool { - if a == nil && b == nil { - return true - } - if a == nil || b == nil { - return false - } - return *a == *b -} - // OpenStackVersionReconciler reconciles a OpenStackVersion object type OpenStackVersionReconciler struct { client.Client @@ -226,7 +216,7 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req // minor update for OVN Controlplane in progress if instance.Status.DeployedVersion != nil && instance.Spec.TargetVersion != *instance.Status.DeployedVersion { - if !compareStringPointers(controlPlane.Status.ContainerImages.OvnControllerImage, instance.Status.ContainerImages.OvnControllerImage) || + if !openstack.OVNControllerImageCheck(controlPlane, instance) || !controlPlane.Status.Conditions.IsTrue(corev1beta1.OpenStackControlPlaneOVNReadyCondition) { instance.Status.Conditions.Set(condition.FalseCondition( corev1beta1.OpenStackVersionMinorUpdateOVNControlplane, @@ -241,9 +231,7 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req corev1beta1.OpenStackVersionMinorUpdateReadyMessage) // minor update for Controlplane in progress - // we only check keystone here as it will only get updated during this phase - // FIXME: add checks to all images on the Controlplane here once conditions and observedGeneration work are finished - if !compareStringPointers(controlPlane.Status.ContainerImages.KeystoneAPIImage, instance.Status.ContainerImages.KeystoneAPIImage) || + if !openstack.ControlplaneContainerImageCheck(controlPlane, instance) || !controlPlane.IsReady() { instance.Status.Conditions.Set(condition.FalseCondition( corev1beta1.OpenStackVersionMinorUpdateControlplane, diff --git a/pkg/openstack/barbican.go b/pkg/openstack/barbican.go index b1fc1a204..f744fa793 100644 --- a/pkg/openstack/barbican.go +++ b/pkg/openstack/barbican.go @@ -33,6 +33,9 @@ func ReconcileBarbican(ctx context.Context, instance *corev1beta1.OpenStackContr } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneBarbicanReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeBarbicanReadyCondition) + instance.Status.ContainerImages.BarbicanAPIImage = nil + instance.Status.ContainerImages.BarbicanWorkerImage = nil + instance.Status.ContainerImages.BarbicanKeystoneListenerImage = nil return ctrl.Result{}, nil } @@ -155,3 +158,17 @@ func ReconcileBarbican(ctx context.Context, instance *corev1beta1.OpenStackContr return ctrl.Result{}, nil } + +// BarbicanImageCheck - return true if the Barbican images match on the ControlPlane and Version, or if Barbican is not enabled +func BarbicanImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Barbican.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.BarbicanAPIImage, version.Status.ContainerImages.BarbicanAPIImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.BarbicanWorkerImage, version.Status.ContainerImages.BarbicanWorkerImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.BarbicanKeystoneListenerImage, version.Status.ContainerImages.BarbicanKeystoneListenerImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/cinder.go b/pkg/openstack/cinder.go index 9b3ea2142..d84c197bf 100644 --- a/pkg/openstack/cinder.go +++ b/pkg/openstack/cinder.go @@ -34,6 +34,10 @@ func ReconcileCinder(ctx context.Context, instance *corev1beta1.OpenStackControl } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneCinderReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeCinderReadyCondition) + instance.Status.ContainerImages.CinderAPIImage = nil + instance.Status.ContainerImages.CinderSchedulerImage = nil + instance.Status.ContainerImages.CinderBackupImage = nil + instance.Status.ContainerImages.CinderVolumeImages = make(map[string]*string) return ctrl.Result{}, nil } Log := GetLogger(ctx) @@ -183,3 +187,22 @@ func ReconcileCinder(ctx context.Context, instance *corev1beta1.OpenStackControl return ctrl.Result{}, nil } + +// CinderImageCheck - return true if the Cinder images match on the ControlPlane and Version, or if Cinder is not enabled +func CinderImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Cinder.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.CinderAPIImage, version.Status.ContainerImages.CinderAPIImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.CinderSchedulerImage, version.Status.ContainerImages.CinderSchedulerImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.CinderBackupImage, version.Status.ContainerImages.CinderBackupImage) { + return false + } + for name, img := range version.Status.ContainerImages.CinderVolumeImages { + if !compareStringPointers(controlPlane.Status.ContainerImages.CinderVolumeImages[name], img) { + return false + } + } + } + + return true +} diff --git a/pkg/openstack/designate.go b/pkg/openstack/designate.go index 3875b0de1..d1cb0c9bc 100644 --- a/pkg/openstack/designate.go +++ b/pkg/openstack/designate.go @@ -34,6 +34,13 @@ func ReconcileDesignate(ctx context.Context, instance *corev1beta1.OpenStackCont } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneDesignateReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeDesignateReadyCondition) + instance.Status.ContainerImages.DesignateAPIImage = nil + instance.Status.ContainerImages.DesignateCentralImage = nil + instance.Status.ContainerImages.DesignateMdnsImage = nil + instance.Status.ContainerImages.DesignateProducerImage = nil + instance.Status.ContainerImages.DesignateWorkerImage = nil + instance.Status.ContainerImages.DesignateBackendbind9Image = nil + instance.Status.ContainerImages.DesignateUnboundImage = nil return ctrl.Result{}, nil } @@ -169,3 +176,21 @@ func ReconcileDesignate(ctx context.Context, instance *corev1beta1.OpenStackCont return ctrl.Result{}, nil } + +// DesignateImageCheck - return true if the Designate images match on the ControlPlane and Version, or if Designate is not enabled +func DesignateImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Designate.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.DesignateAPIImage, version.Status.ContainerImages.DesignateAPIImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.DesignateCentralImage, version.Status.ContainerImages.DesignateCentralImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.DesignateMdnsImage, version.Status.ContainerImages.DesignateMdnsImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.DesignateProducerImage, version.Status.ContainerImages.DesignateProducerImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.DesignateWorkerImage, version.Status.ContainerImages.DesignateWorkerImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.DesignateBackendbind9Image, version.Status.ContainerImages.DesignateBackendbind9Image) || + !compareStringPointers(controlPlane.Status.ContainerImages.DesignateUnboundImage, version.Status.ContainerImages.DesignateUnboundImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/dnsmasq.go b/pkg/openstack/dnsmasq.go index 73bf578e9..515746d72 100644 --- a/pkg/openstack/dnsmasq.go +++ b/pkg/openstack/dnsmasq.go @@ -30,6 +30,7 @@ func ReconcileDNSMasqs(ctx context.Context, instance *corev1beta1.OpenStackContr return res, err } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneDNSReadyCondition) + instance.Status.ContainerImages.InfraDnsmasqImage = nil return ctrl.Result{}, nil } @@ -76,3 +77,14 @@ func ReconcileDNSMasqs(ctx context.Context, instance *corev1beta1.OpenStackContr return ctrl.Result{}, nil } + +// DnsmasqImageCheck - return true if the Dnsmasq images match on the ControlPlane and Version, or if Dnsmasq is not enabled +func DnsmasqImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.DNS.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.InfraDnsmasqImage, version.Status.ContainerImages.InfraDnsmasqImage) { + return false + } + } + return true +} diff --git a/pkg/openstack/galera.go b/pkg/openstack/galera.go index 0c660583d..c57bc3857 100644 --- a/pkg/openstack/galera.go +++ b/pkg/openstack/galera.go @@ -152,6 +152,7 @@ func reconcileGalera( return galeraFailed, err } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneMariaDBReadyCondition) + instance.Status.ContainerImages.MariadbImage = nil return galeraReady, nil } @@ -181,3 +182,15 @@ func reconcileGalera( return galeraCreating, nil } + +// GaleraImageCheck - return true if the Galera images match on the ControlPlane and Version, or if Galera is not enabled +func GaleraImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Galera.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.MariadbImage, version.Status.ContainerImages.MariadbImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/glance.go b/pkg/openstack/glance.go index 1306e0771..8d9d25a1a 100644 --- a/pkg/openstack/glance.go +++ b/pkg/openstack/glance.go @@ -43,6 +43,7 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneGlanceReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeGlanceReadyCondition) + instance.Status.ContainerImages.GlanceAPIImage = nil return ctrl.Result{}, nil } @@ -209,3 +210,15 @@ func getGlanceAPILabelMap(name string, apiName string, apiType string) map[strin svcSelector: apiFilter, } } + +// GlanceImageCheck - return true if the glance images match on the ControlPlane and Version, or if Glance is not enabled +func GlanceImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Glance.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.GlanceAPIImage, version.Status.ContainerImages.GlanceAPIImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/heat.go b/pkg/openstack/heat.go index 5e7046bfc..c1ce46007 100644 --- a/pkg/openstack/heat.go +++ b/pkg/openstack/heat.go @@ -37,6 +37,9 @@ func ReconcileHeat(ctx context.Context, instance *corev1beta1.OpenStackControlPl } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneHeatReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeHeatReadyCondition) + instance.Status.ContainerImages.HeatAPIImage = nil + instance.Status.ContainerImages.HeatCfnapiImage = nil + instance.Status.ContainerImages.HeatEngineImage = nil return ctrl.Result{}, nil } @@ -193,3 +196,17 @@ func ReconcileHeat(ctx context.Context, instance *corev1beta1.OpenStackControlPl return ctrl.Result{}, nil } + +// HeatImageCheck - return true if the heat images match on the ControlPlane and Version, or if Heat is not enabled +func HeatImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Heat.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.HeatAPIImage, version.Status.ContainerImages.HeatAPIImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.HeatCfnapiImage, version.Status.ContainerImages.HeatCfnapiImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.HeatEngineImage, version.Status.ContainerImages.HeatEngineImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/horizon.go b/pkg/openstack/horizon.go index c027c6f0e..317be9757 100644 --- a/pkg/openstack/horizon.go +++ b/pkg/openstack/horizon.go @@ -42,6 +42,7 @@ func ReconcileHorizon(ctx context.Context, instance *corev1beta1.OpenStackContro } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneHorizonReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeHorizonReadyCondition) + instance.Status.ContainerImages.HorizonImage = nil return ctrl.Result{}, nil } @@ -169,3 +170,15 @@ func ReconcileHorizon(ctx context.Context, instance *corev1beta1.OpenStackContro return ctrl.Result{}, nil } + +// HorizonImageCheck - return true if horizon images match on the ControlPlane and Version, or if Horizon is not enabled +func HorizonImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Horizon.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.HorizonImage, version.Status.ContainerImages.HorizonImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/ironic.go b/pkg/openstack/ironic.go index 8c1dbcaee..802a89ca2 100644 --- a/pkg/openstack/ironic.go +++ b/pkg/openstack/ironic.go @@ -34,6 +34,12 @@ func ReconcileIronic(ctx context.Context, instance *corev1beta1.OpenStackControl } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneIronicReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeIronicReadyCondition) + instance.Status.ContainerImages.IronicAPIImage = nil + instance.Status.ContainerImages.IronicConductorImage = nil + instance.Status.ContainerImages.IronicInspectorImage = nil + instance.Status.ContainerImages.IronicNeutronAgentImage = nil + instance.Status.ContainerImages.IronicPxeImage = nil + instance.Status.ContainerImages.IronicPythonAgentImage = nil return ctrl.Result{}, nil } @@ -195,3 +201,20 @@ func ReconcileIronic(ctx context.Context, instance *corev1beta1.OpenStackControl return ctrl.Result{}, nil } + +// IronicImagesCheck - return true if the ironic images match on the ControlPlane and Version, or if Ironic is not enabled +func IronicImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Ironic.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.IronicAPIImage, version.Status.ContainerImages.IronicAPIImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.IronicConductorImage, version.Status.ContainerImages.IronicConductorImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.IronicInspectorImage, version.Status.ContainerImages.IronicInspectorImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.IronicNeutronAgentImage, version.Status.ContainerImages.IronicNeutronAgentImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.IronicPxeImage, version.Status.ContainerImages.IronicPxeImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.IronicPythonAgentImage, version.Status.ContainerImages.IronicPythonAgentImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/keystone.go b/pkg/openstack/keystone.go index f18db0288..acfc5e8bb 100644 --- a/pkg/openstack/keystone.go +++ b/pkg/openstack/keystone.go @@ -147,3 +147,15 @@ func ReconcileKeystoneAPI(ctx context.Context, instance *corev1beta1.OpenStackCo return ctrl.Result{}, nil } + +// KeystoneImageCheck - return true if the keystone images match on the ControlPlane and Version, or if Keystone is not enabled +func KeystoneImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Keystone.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.KeystoneAPIImage, version.Status.ContainerImages.KeystoneAPIImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/manila.go b/pkg/openstack/manila.go index f63f64dcb..d89924d96 100644 --- a/pkg/openstack/manila.go +++ b/pkg/openstack/manila.go @@ -35,6 +35,9 @@ func ReconcileManila(ctx context.Context, instance *corev1beta1.OpenStackControl } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneManilaReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeManilaReadyCondition) + instance.Status.ContainerImages.ManilaAPIImage = nil + instance.Status.ContainerImages.ManilaSchedulerImage = nil + instance.Status.ContainerImages.ManilaShareImages = make(map[string]*string) return ctrl.Result{}, nil } @@ -181,3 +184,21 @@ func ReconcileManila(ctx context.Context, instance *corev1beta1.OpenStackControl return ctrl.Result{}, nil } + +// ManilaImageCheck - return true if the Manila images match on the ControlPlane and Version, or if Manila is not enabled +func ManilaImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Manila.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.ManilaAPIImage, version.Status.ContainerImages.ManilaAPIImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.ManilaSchedulerImage, version.Status.ContainerImages.ManilaSchedulerImage) { + return false + } + for name, img := range version.Status.ContainerImages.ManilaShareImages { + if !compareStringPointers(controlPlane.Status.ContainerImages.ManilaShareImages[name], img) { + return false + } + } + } + + return true +} diff --git a/pkg/openstack/memcached.go b/pkg/openstack/memcached.go index a494723b0..01b95461c 100644 --- a/pkg/openstack/memcached.go +++ b/pkg/openstack/memcached.go @@ -153,6 +153,7 @@ func reconcileMemcached( return memcachedFailed, ctrl.Result{}, err } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneMemcachedReadyCondition) + instance.Status.ContainerImages.InfraMemcachedImage = nil return memcachedReady, ctrl.Result{}, nil } @@ -221,3 +222,15 @@ func reconcileMemcached( return memcachedCreating, ctrl.Result{}, nil } + +// MemcachedImageCheck - return true if the memcached images match on the ControlPlane and Version, or if Memcached is not enabled +func MemcachedImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Memcached.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.InfraMemcachedImage, version.Status.ContainerImages.InfraMemcachedImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/neutron.go b/pkg/openstack/neutron.go index 392aaca93..72b04ce9f 100644 --- a/pkg/openstack/neutron.go +++ b/pkg/openstack/neutron.go @@ -37,6 +37,7 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneNeutronReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeNeutronReadyCondition) + instance.Status.ContainerImages.NeutronAPIImage = nil return ctrl.Result{}, nil } @@ -192,3 +193,15 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro return ctrl.Result{}, nil } + +// NeutronImageCheck - return true if the neutron images match on the ControlPlane and Version, or if Neutron is not enabled +func NeutronImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Neutron.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.NeutronAPIImage, version.Status.ContainerImages.NeutronAPIImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/nova.go b/pkg/openstack/nova.go index b9f7c9188..5392cda8c 100644 --- a/pkg/openstack/nova.go +++ b/pkg/openstack/nova.go @@ -55,6 +55,11 @@ func ReconcileNova(ctx context.Context, instance *corev1beta1.OpenStackControlPl } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneNovaReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeNovaReadyCondition) + instance.Status.ContainerImages.NovaAPIImage = nil + instance.Status.ContainerImages.NovaComputeImage = nil + instance.Status.ContainerImages.NovaConductorImage = nil + instance.Status.ContainerImages.NovaNovncImage = nil + instance.Status.ContainerImages.NovaSchedulerImage = nil return ctrl.Result{}, nil } @@ -396,3 +401,19 @@ func metadataEnabled(metadata novav1.NovaMetadataTemplate) bool { func noVNCProxyEnabled(vncproxy novav1.NovaNoVNCProxyTemplate) bool { return vncproxy.Enabled != nil && *vncproxy.Enabled } + +// NovaImageCheck - return true if the nova images match on the ControlPlane and Version, or if Nova is not enabled +func NovaImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Nova.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.NovaAPIImage, version.Status.ContainerImages.NovaAPIImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.NovaComputeImage, version.Status.ContainerImages.NovaComputeImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.NovaConductorImage, version.Status.ContainerImages.NovaConductorImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.NovaNovncImage, version.Status.ContainerImages.NovaNovncImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.NovaSchedulerImage, version.Status.ContainerImages.NovaSchedulerImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/octavia.go b/pkg/openstack/octavia.go index 081093502..75f828c00 100644 --- a/pkg/openstack/octavia.go +++ b/pkg/openstack/octavia.go @@ -52,6 +52,12 @@ func ReconcileOctavia(ctx context.Context, instance *corev1beta1.OpenStackContro } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneOctaviaReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeOctaviaReadyCondition) + instance.Status.ContainerImages.OctaviaAPIImage = nil + instance.Status.ContainerImages.OctaviaWorkerImage = nil + instance.Status.ContainerImages.OctaviaHealthmanagerImage = nil + instance.Status.ContainerImages.OctaviaHousekeepingImage = nil + //FIXME: (dprince) Octavia should have its own parameter for the apache image (it can share the same image in OpenStackVersion though) + instance.Status.ContainerImages.ApacheImage = nil return ctrl.Result{}, nil } @@ -203,3 +209,19 @@ func ReconcileOctavia(ctx context.Context, instance *corev1beta1.OpenStackContro return ctrl.Result{}, nil } + +// OctaviaImageCheck - return true if the octavia images match on the ControlPlane and Version, or if Octavia is not enabled +func OctaviaImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Octavia.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.OctaviaAPIImage, version.Status.ContainerImages.OctaviaAPIImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.OctaviaWorkerImage, version.Status.ContainerImages.OctaviaWorkerImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.OctaviaHealthmanagerImage, version.Status.ContainerImages.OctaviaHealthmanagerImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.OctaviaHousekeepingImage, version.Status.ContainerImages.OctaviaHousekeepingImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.ApacheImage, version.Status.ContainerImages.ApacheImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/openstackclient.go b/pkg/openstack/openstackclient.go index 56f016022..1f20a0c12 100644 --- a/pkg/openstack/openstackclient.go +++ b/pkg/openstack/openstackclient.go @@ -88,3 +88,10 @@ func ReconcileOpenStackClient(ctx context.Context, instance *corev1.OpenStackCon return ctrl.Result{}, nil } + +// ClientImageCheck - return true if the openstackclient images match on the ControlPlane and Version, or if OpenstackClient is not enabled +func ClientImageCheck(controlPlane *corev1.OpenStackControlPlane, version *corev1.OpenStackVersion) bool { + + //FIXME: (dprince) - OpenStackClientSection should have Enabled? + return compareStringPointers(controlPlane.Status.ContainerImages.OpenstackClientImage, version.Status.ContainerImages.OpenstackClientImage) +} diff --git a/pkg/openstack/ovn.go b/pkg/openstack/ovn.go index d4441b4e4..2867c514b 100644 --- a/pkg/openstack/ovn.go +++ b/pkg/openstack/ovn.go @@ -79,6 +79,8 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack } if !instance.Spec.Ovn.Enabled { + instance.Status.ContainerImages.OvnNbDbclusterImage = nil + instance.Status.ContainerImages.OvnSbDbclusterImage = nil if _, err := EnsureDeleted(ctx, helper, OVNDBCluster); err != nil { return false, err } @@ -192,6 +194,7 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont } if !instance.Spec.Ovn.Enabled { + instance.Status.ContainerImages.OvnNorthdImage = nil if _, err := EnsureDeleted(ctx, helper, OVNNorthd); err != nil { return false, err } @@ -300,6 +303,8 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack } if !instance.Spec.Ovn.Enabled { + instance.Status.ContainerImages.OvnControllerImage = nil + instance.Status.ContainerImages.OvnControllerOvsImage = nil if _, err := EnsureDeleted(ctx, helper, OVNController); err != nil { return false, err } @@ -397,3 +402,38 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack return false, nil } } + +// OVNControllerImageCheck - return true if the OVN Controller images match on the ControlPlane and Version, or if OVN is not enabled +func OVNControllerImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Ovn.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.OvnControllerImage, version.Status.ContainerImages.OvnControllerImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.OvnControllerOvsImage, version.Status.ContainerImages.OvnControllerOvsImage) { + return false + } + } + return true +} + +// OVNDbClusterImageCheck - return true if the OVN DbCluster images match on the ControlPlane and Version, or if OVN is not enabled +func OVNDbClusterImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Ovn.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.OvnNbDbclusterImage, version.Status.ContainerImages.OvnNbDbclusterImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.OvnSbDbclusterImage, version.Status.ContainerImages.OvnSbDbclusterImage) { + return false + } + } + return true +} + +// OVNNorthImageCheck - return true if the OVN North images match on the ControlPlane and Version, or if OVN is not enabled +func OVNNorthImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Ovn.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.OvnNorthdImage, version.Status.ContainerImages.OvnNorthdImage) { + return false + } + } + return true +} diff --git a/pkg/openstack/placement.go b/pkg/openstack/placement.go index a1a0e991c..f70dcc125 100644 --- a/pkg/openstack/placement.go +++ b/pkg/openstack/placement.go @@ -144,3 +144,15 @@ func ReconcilePlacementAPI(ctx context.Context, instance *corev1beta1.OpenStackC return ctrl.Result{}, nil } + +// PlacementImageCheck - return true if the placement images match on the ControlPlane and Version, or if Placement is not enabled +func PlacementImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Placement.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.PlacementAPIImage, version.Status.ContainerImages.PlacementAPIImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/rabbitmq.go b/pkg/openstack/rabbitmq.go index c93d1556b..11909eeb2 100644 --- a/pkg/openstack/rabbitmq.go +++ b/pkg/openstack/rabbitmq.go @@ -112,6 +112,7 @@ func reconcileRabbitMQ( return mqFailed, ctrl.Result{}, err } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneRabbitMQReadyCondition) + instance.Status.ContainerImages.RabbitmqImage = nil return mqReady, ctrl.Result{}, nil } @@ -370,3 +371,15 @@ func reconcileRabbitMQ( return mqCreating, ctrl.Result{}, nil } + +// RabbitmqImageCheck - return true if the rabbitmq images match on the ControlPlane and Version, or if Rabbitmq is not enabled +func RabbitmqImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Rabbitmq.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.RabbitmqImage, version.Status.ContainerImages.RabbitmqImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/swift.go b/pkg/openstack/swift.go index 4b1dcdc64..a26af8040 100644 --- a/pkg/openstack/swift.go +++ b/pkg/openstack/swift.go @@ -35,6 +35,10 @@ func ReconcileSwift(ctx context.Context, instance *corev1beta1.OpenStackControlP } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneSwiftReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeSwiftReadyCondition) + instance.Status.ContainerImages.SwiftAccountImage = nil + instance.Status.ContainerImages.SwiftContainerImage = nil + instance.Status.ContainerImages.SwiftObjectImage = nil + instance.Status.ContainerImages.SwiftProxyImage = nil return ctrl.Result{}, nil } @@ -148,3 +152,18 @@ func ReconcileSwift(ctx context.Context, instance *corev1beta1.OpenStackControlP return ctrl.Result{}, nil } + +// SwiftImageCheck - return true if the swift images match on the ControlPlane and Version, or if Swift is not enabled +func SwiftImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Swift.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.SwiftAccountImage, version.Status.ContainerImages.SwiftAccountImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.SwiftContainerImage, version.Status.ContainerImages.SwiftContainerImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.SwiftObjectImage, version.Status.ContainerImages.SwiftObjectImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.SwiftProxyImage, version.Status.ContainerImages.SwiftProxyImage) { + return false + } + } + + return true +} diff --git a/pkg/openstack/telemetry.go b/pkg/openstack/telemetry.go index bde204daa..d845298b8 100644 --- a/pkg/openstack/telemetry.go +++ b/pkg/openstack/telemetry.go @@ -40,6 +40,16 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont return res, err } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneTelemetryReadyCondition) + instance.Status.ContainerImages.CeilometerCentralImage = nil + instance.Status.ContainerImages.CeilometerComputeImage = nil + instance.Status.ContainerImages.CeilometerIpmiImage = nil + instance.Status.ContainerImages.CeilometerNotificationImage = nil + instance.Status.ContainerImages.CeilometerSgcoreImage = nil + instance.Status.ContainerImages.CeilometerProxyImage = nil + instance.Status.ContainerImages.AodhAPIImage = nil + instance.Status.ContainerImages.AodhEvaluatorImage = nil + instance.Status.ContainerImages.AodhNotifierImage = nil + instance.Status.ContainerImages.AodhListenerImage = nil return ctrl.Result{}, nil } @@ -301,3 +311,25 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont return ctrl.Result{}, nil } + +// TelemetryImageCheck - return true if the telemetry images match on the ControlPlane and Version, or if Telemetry is not enabled +func TelemetryImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if controlPlane.Spec.Telemetry.Enabled { + if !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerCentralImage, version.Status.ContainerImages.CeilometerCentralImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerComputeImage, version.Status.ContainerImages.CeilometerComputeImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerIpmiImage, version.Status.ContainerImages.CeilometerIpmiImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerNotificationImage, version.Status.ContainerImages.CeilometerNotificationImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerSgcoreImage, version.Status.ContainerImages.CeilometerSgcoreImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerProxyImage, version.Status.ContainerImages.CeilometerProxyImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.AodhAPIImage, version.Status.ContainerImages.AodhAPIImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.AodhEvaluatorImage, version.Status.ContainerImages.AodhEvaluatorImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.AodhNotifierImage, version.Status.ContainerImages.AodhNotifierImage) || + !compareStringPointers(controlPlane.Status.ContainerImages.AodhListenerImage, version.Status.ContainerImages.AodhListenerImage) { + + return false + } + } + + return true +} diff --git a/pkg/openstack/version.go b/pkg/openstack/version.go index f92f3d698..9704164e9 100644 --- a/pkg/openstack/version.go +++ b/pkg/openstack/version.go @@ -204,3 +204,47 @@ func ReconcileVersion(ctx context.Context, instance *corev1beta1.OpenStackContro return ctrl.Result{}, version, nil } + +func compareStringPointers(a, b *string) bool { + if a == nil && b == nil { + return true + } + if a == nil || b == nil { + return false + } + return *a == *b +} + +// ControlplaneContainerImageCheck - function to compare the ContainerImages on the controlPlane to the OpenStackVersion +// only enabled services are checked +func ControlplaneContainerImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if BarbicanImageCheck(controlPlane, version) && + CinderImageCheck(controlPlane, version) && + DesignateImageCheck(controlPlane, version) && + DnsmasqImageCheck(controlPlane, version) && + GaleraImageCheck(controlPlane, version) && + GlanceImageCheck(controlPlane, version) && + HeatImageCheck(controlPlane, version) && + HorizonImageCheck(controlPlane, version) && + IronicImageCheck(controlPlane, version) && + KeystoneImageCheck(controlPlane, version) && + ManilaImageCheck(controlPlane, version) && + MemcachedImageCheck(controlPlane, version) && + NeutronImageCheck(controlPlane, version) && + NovaImageCheck(controlPlane, version) && + OctaviaImageCheck(controlPlane, version) && + ClientImageCheck(controlPlane, version) && + OVNControllerImageCheck(controlPlane, version) && + OVNNorthImageCheck(controlPlane, version) && + OVNDbClusterImageCheck(controlPlane, version) && + PlacementImageCheck(controlPlane, version) && + RabbitmqImageCheck(controlPlane, version) && + SwiftImageCheck(controlPlane, version) && + TelemetryImageCheck(controlPlane, version) { + + return true + } + + return false +} From ae9065e442e4f50173d8d2b78f71c9feab0d6f02 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Tue, 7 May 2024 14:46:25 -0400 Subject: [PATCH 2/2] EDPM condition and update order checks --- config/rbac/role.yaml | 8 ++ .../core/openstackcontrolplane_controller.go | 4 +- .../core/openstackversion_controller.go | 76 ++++++++++++++----- pkg/openstack/barbican.go | 10 +-- pkg/openstack/cinder.go | 12 +-- pkg/openstack/dataplane.go | 71 +++++++++++++++++ pkg/openstack/designate.go | 18 ++--- pkg/openstack/dnsmasq.go | 6 +- pkg/openstack/galera.go | 9 ++- pkg/openstack/glance.go | 6 +- pkg/openstack/heat.go | 10 +-- pkg/openstack/horizon.go | 6 +- pkg/openstack/ironic.go | 14 ++-- pkg/openstack/keystone.go | 9 ++- pkg/openstack/manila.go | 10 +-- pkg/openstack/memcached.go | 9 ++- pkg/openstack/neutron.go | 6 +- pkg/openstack/nova.go | 14 ++-- pkg/openstack/octavia.go | 14 ++-- pkg/openstack/openstackclient.go | 7 +- pkg/openstack/ovn.go | 24 +++--- pkg/openstack/placement.go | 6 +- pkg/openstack/rabbitmq.go | 7 +- pkg/openstack/swift.go | 12 +-- pkg/openstack/telemetry.go | 24 +++--- pkg/openstack/version.go | 58 +++++++------- tests/functional/base_test.go | 1 - .../openstackoperator_controller_test.go | 6 +- .../openstackversion_controller_test.go | 12 +-- tests/functional/suite_test.go | 7 ++ 30 files changed, 303 insertions(+), 173 deletions(-) create mode 100644 pkg/openstack/dataplane.go diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 460182909..324676894 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -180,6 +180,14 @@ rules: - get - patch - update +- apiGroups: + - dataplane.openstack.org + resources: + - openstackdataplanenodesets + verbs: + - get + - list + - watch - apiGroups: - designate.openstack.org resources: diff --git a/controllers/core/openstackcontrolplane_controller.go b/controllers/core/openstackcontrolplane_controller.go index b9efde702..9ad97b97c 100644 --- a/controllers/core/openstackcontrolplane_controller.go +++ b/controllers/core/openstackcontrolplane_controller.go @@ -245,7 +245,9 @@ func (r *OpenStackControlPlaneReconciler) Reconcile(ctx context.Context, req ctr } instance.Status.DeployedOVNVersion = &version.Spec.TargetVersion return ctrl.Result{}, nil - } else if !version.Status.Conditions.IsTrue(corev1beta1.OpenStackVersionMinorUpdateControlplane) { + } else if version.Status.Conditions.IsTrue(corev1beta1.OpenStackVersionMinorUpdateOVNDataplane) && + !version.Status.Conditions.IsTrue(corev1beta1.OpenStackVersionMinorUpdateControlplane) { + Log.Info("Minor update on the ControlPlane") ctrlResult, err := r.reconcileNormal(ctx, instance, version, helper) if err != nil { diff --git a/controllers/core/openstackversion_controller.go b/controllers/core/openstackversion_controller.go index b63c3a6ef..c716907d9 100644 --- a/controllers/core/openstackversion_controller.go +++ b/controllers/core/openstackversion_controller.go @@ -32,6 +32,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "github.com/go-logr/logr" + dataplanev1 "github.com/openstack-k8s-operators/dataplane-operator/api/v1beta1" condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition" "github.com/openstack-k8s-operators/lib-common/modules/common/helper" corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" @@ -69,9 +70,11 @@ func (r *OpenStackVersionReconciler) GetLogger(ctx context.Context) logr.Logger return log.FromContext(ctx).WithName("Controllers").WithName("OpenStackVersion") } -//+kubebuilder:rbac:groups=core.openstack.org,resources=openstackversions,verbs=get;list;watch;create;update;patch;delete -//+kubebuilder:rbac:groups=core.openstack.org,resources=openstackversions/status,verbs=get;update;patch -//+kubebuilder:rbac:groups=core.openstack.org,resources=openstackversions/finalizers,verbs=update +// +kubebuilder:rbac:groups=core.openstack.org,resources=openstackversions,verbs=get;list;watch;create;update;patch;delete +// +kubebuilder:rbac:groups=core.openstack.org,resources=openstackversions/status,verbs=get;update;patch +// +kubebuilder:rbac:groups=core.openstack.org,resources=openstackversions/finalizers,verbs=update +// +kubebuilder:rbac:groups=core.openstack.org,resources=openstackcontrolplanes,verbs=get;list;watch +// +kubebuilder:rbac:groups=dataplane.openstack.org,resources=openstackdataplanenodesets,verbs=get;list;watch // Reconcile is part of the main kubernetes reconciliation loop which aims to // move the current state of the cluster closer to the desired state. @@ -149,10 +152,10 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req // no minor update conditions unless we have a deployed version if instance.Status.DeployedVersion != nil && instance.Spec.TargetVersion != *instance.Status.DeployedVersion { cl = append(cl, *condition.UnknownCondition(corev1beta1.OpenStackVersionMinorUpdateOVNControlplane, condition.InitReason, string(corev1beta1.OpenStackVersionMinorUpdateInitMessage)), - *condition.UnknownCondition(corev1beta1.OpenStackVersionMinorUpdateControlplane, condition.InitReason, string(corev1beta1.OpenStackVersionMinorUpdateInitMessage))) - // fixme add dataplane conditions here - //condition.UnknownCondition(corev1beta1.OpenStackVersionMinorUpdateOVNDataplane, condition.InitReason, string(corev1beta1.OpenStackVersionMinorUpdateInitMessage)), - //condition.UnknownCondition(corev1beta1.OpenStackVersionMinorUpdateDataplane, condition.InitReason, string(corev1beta1.OpenStackVersionMinorUpdateInitMessage))) + *condition.UnknownCondition(corev1beta1.OpenStackVersionMinorUpdateOVNDataplane, condition.InitReason, string(corev1beta1.OpenStackVersionMinorUpdateInitMessage)), + *condition.UnknownCondition(corev1beta1.OpenStackVersionMinorUpdateControlplane, condition.InitReason, string(corev1beta1.OpenStackVersionMinorUpdateInitMessage)), + *condition.UnknownCondition(corev1beta1.OpenStackVersionMinorUpdateDataplane, condition.InitReason, string(corev1beta1.OpenStackVersionMinorUpdateInitMessage)), + ) } instance.Status.Conditions.Init(&cl) instance.Status.ObservedGeneration = instance.Generation @@ -172,13 +175,14 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req instance.Status.AvailableVersion = &envAvailableVersion defaults := openstack.InitializeOpenStackVersionImageDefaults(ctx, envContainerImages) - // store the defaults for the currently available version if instance.Status.ContainerImageVersionDefaults == nil { instance.Status.ContainerImageVersionDefaults = make(map[string]*corev1beta1.ContainerDefaults) } + // store the defaults for the currently available version instance.Status.ContainerImageVersionDefaults[envAvailableVersion] = defaults // calculate the container images for the target version + Log.Info("Target version: ", "targetVersion", instance.Spec.TargetVersion) val, ok := instance.Status.ContainerImageVersionDefaults[instance.Spec.TargetVersion] if !ok { Log.Info("Target version not found in defaults", "targetVersion", instance.Spec.TargetVersion) @@ -198,25 +202,30 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req Name: instance.Name, }, controlPlane) if err != nil { - // we ignore not found if k8s_errors.IsNotFound(err) { - Log.Info("No controlplane found.") + Log.Info("Controlplane not found:", "instance name", instance.Name) return ctrl.Result{}, nil } return ctrl.Result{}, err } - // greenfield deployment //FIXME check dataplane here too - if controlPlane.Status.DeployedVersion == nil { - Log.Info("No controlplane or controlplane is not deployed") - return ctrl.Result{}, nil + // lookup nodesets + dataplaneNodesets, err := openstack.GetDataplaneNodesets(ctx, controlPlane, versionHelper) + if err != nil { + Log.Error(err, "Failed to get dataplane nodesets") + return ctrl.Result{}, err } - // TODO minor update for OVN Dataplane in progress + // greenfield deployment + if controlPlane.Status.DeployedVersion == nil && !openstack.DataplaneNodesetsDeployedVersionIsSet(dataplaneNodesets) { + Log.Info("Waiting for controlplane and dataplane nodesets to be deployed.") + return ctrl.Result{}, nil + } - // minor update for OVN Controlplane in progress + // minor update in progress if instance.Status.DeployedVersion != nil && instance.Spec.TargetVersion != *instance.Status.DeployedVersion { - if !openstack.OVNControllerImageCheck(controlPlane, instance) || + + if !openstack.OVNControllerImageMatch(controlPlane, instance) || !controlPlane.Status.Conditions.IsTrue(corev1beta1.OpenStackControlPlaneOVNReadyCondition) { instance.Status.Conditions.Set(condition.FalseCondition( corev1beta1.OpenStackVersionMinorUpdateOVNControlplane, @@ -230,8 +239,22 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req corev1beta1.OpenStackVersionMinorUpdateOVNControlplane, corev1beta1.OpenStackVersionMinorUpdateReadyMessage) + // minor update for Dataplane OVN + if !openstack.DataplaneNodesetsOVNControllerImagesMatch(instance, dataplaneNodesets) { + instance.Status.Conditions.Set(condition.FalseCondition( + corev1beta1.OpenStackVersionMinorUpdateOVNDataplane, + condition.RequestedReason, + condition.SeverityInfo, + corev1beta1.OpenStackVersionMinorUpdateReadyRunningMessage)) + Log.Info("Waiting on OVN Dataplane updates to complete") + return ctrl.Result{}, nil + } + instance.Status.Conditions.MarkTrue( + corev1beta1.OpenStackVersionMinorUpdateOVNDataplane, + corev1beta1.OpenStackVersionMinorUpdateReadyMessage) + // minor update for Controlplane in progress - if !openstack.ControlplaneContainerImageCheck(controlPlane, instance) || + if !openstack.ControlplaneContainerImageMatch(controlPlane, instance) || !controlPlane.IsReady() { instance.Status.Conditions.Set(condition.FalseCondition( corev1beta1.OpenStackVersionMinorUpdateControlplane, @@ -241,11 +264,23 @@ func (r *OpenStackVersionReconciler) Reconcile(ctx context.Context, req ctrl.Req Log.Info("Minor update for Controlplane in progress") return ctrl.Result{}, nil } - // TODO minor update for Dataplane in progress goes here - instance.Status.Conditions.MarkTrue( corev1beta1.OpenStackVersionMinorUpdateControlplane, corev1beta1.OpenStackVersionMinorUpdateReadyMessage) + + if !openstack.DataplaneNodesetsDeployed(instance, dataplaneNodesets) { + instance.Status.Conditions.Set(condition.FalseCondition( + corev1beta1.OpenStackVersionMinorUpdateDataplane, + condition.RequestedReason, + condition.SeverityInfo, + corev1beta1.OpenStackVersionMinorUpdateReadyRunningMessage)) + Log.Info("Waiting on Dataplane update to complete") + return ctrl.Result{}, nil + } + + instance.Status.Conditions.MarkTrue( + corev1beta1.OpenStackVersionMinorUpdateDataplane, + corev1beta1.OpenStackVersionMinorUpdateReadyMessage) } if controlPlane.IsReady() { @@ -289,6 +324,7 @@ func (r *OpenStackVersionReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). Watches(&corev1beta1.OpenStackControlPlane{}, versionFunc). + Watches(&dataplanev1.OpenStackDataPlaneNodeSet{}, versionFunc). For(&corev1beta1.OpenStackVersion{}). Complete(r) } diff --git a/pkg/openstack/barbican.go b/pkg/openstack/barbican.go index f744fa793..5687d63f4 100644 --- a/pkg/openstack/barbican.go +++ b/pkg/openstack/barbican.go @@ -159,13 +159,13 @@ func ReconcileBarbican(ctx context.Context, instance *corev1beta1.OpenStackContr return ctrl.Result{}, nil } -// BarbicanImageCheck - return true if the Barbican images match on the ControlPlane and Version, or if Barbican is not enabled -func BarbicanImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// BarbicanImageMatch - return true if the Barbican images match on the ControlPlane and Version, or if Barbican is not enabled +func BarbicanImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Barbican.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.BarbicanAPIImage, version.Status.ContainerImages.BarbicanAPIImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.BarbicanWorkerImage, version.Status.ContainerImages.BarbicanWorkerImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.BarbicanKeystoneListenerImage, version.Status.ContainerImages.BarbicanKeystoneListenerImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.BarbicanAPIImage, version.Status.ContainerImages.BarbicanAPIImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.BarbicanWorkerImage, version.Status.ContainerImages.BarbicanWorkerImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.BarbicanKeystoneListenerImage, version.Status.ContainerImages.BarbicanKeystoneListenerImage) { return false } } diff --git a/pkg/openstack/cinder.go b/pkg/openstack/cinder.go index d84c197bf..715f20420 100644 --- a/pkg/openstack/cinder.go +++ b/pkg/openstack/cinder.go @@ -188,17 +188,17 @@ func ReconcileCinder(ctx context.Context, instance *corev1beta1.OpenStackControl } -// CinderImageCheck - return true if the Cinder images match on the ControlPlane and Version, or if Cinder is not enabled -func CinderImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// CinderImageMatch - return true if the Cinder images match on the ControlPlane and Version, or if Cinder is not enabled +func CinderImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Cinder.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.CinderAPIImage, version.Status.ContainerImages.CinderAPIImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.CinderSchedulerImage, version.Status.ContainerImages.CinderSchedulerImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.CinderBackupImage, version.Status.ContainerImages.CinderBackupImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.CinderAPIImage, version.Status.ContainerImages.CinderAPIImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.CinderSchedulerImage, version.Status.ContainerImages.CinderSchedulerImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.CinderBackupImage, version.Status.ContainerImages.CinderBackupImage) { return false } for name, img := range version.Status.ContainerImages.CinderVolumeImages { - if !compareStringPointers(controlPlane.Status.ContainerImages.CinderVolumeImages[name], img) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.CinderVolumeImages[name], img) { return false } } diff --git a/pkg/openstack/dataplane.go b/pkg/openstack/dataplane.go new file mode 100644 index 000000000..5758e3e31 --- /dev/null +++ b/pkg/openstack/dataplane.go @@ -0,0 +1,71 @@ +package openstack + +import ( + "context" + + "github.com/openstack-k8s-operators/lib-common/modules/common/helper" + corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1" + + dataplanev1 "github.com/openstack-k8s-operators/dataplane-operator/api/v1beta1" + "sigs.k8s.io/controller-runtime/pkg/client" +) + +// GetDataplaneNodesets - returns the dataplanenodesets in the namespace of the controlplane +func GetDataplaneNodesets(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, helper *helper.Helper) (*dataplanev1.OpenStackDataPlaneNodeSetList, error) { + // Get the dataplane nodesets + dataplaneNodesets := &dataplanev1.OpenStackDataPlaneNodeSetList{} + opts := []client.ListOption{ + client.InNamespace(instance.Namespace), + } + err := helper.GetClient().List(ctx, dataplaneNodesets, opts...) + if err != nil { + return nil, err + } + return dataplaneNodesets, nil +} + +func DataplaneNodesetsDeployedVersionIsSet(dataplaneNodesets *dataplanev1.OpenStackDataPlaneNodeSetList) bool { + for _, nodeset := range dataplaneNodesets.Items { + // FIXME: DeployedVersion on the DataplaneNodeset should be a string pointer to match how Controlplane implements this + if nodeset.Status.DeployedVersion == "" { + return false + } + } + return true +} + +// DataplaneNodesetsOVNControllerImagesMatch returns true if OVNControllers are deployed on all nodesets +func DataplaneNodesetsOVNControllerImagesMatch(version *corev1beta1.OpenStackVersion, dataplaneNodesets *dataplanev1.OpenStackDataPlaneNodeSetList) bool { + for _, nodeset := range dataplaneNodesets.Items { + if nodeset.Generation != nodeset.Status.ObservedGeneration { + return false + } + // we only check nodesets if they deploy OVN + if nodeset.Status.ContainerImages["OvnControllerImage"] != "" { + if !nodeset.IsReady() { + return false + } + if nodeset.Status.ContainerImages["OvnControllerImage"] != *version.Status.ContainerImages.OvnControllerImage { + return false + } + } + } + return true +} + +// DataplaneNodesetsDeployed returns true if all nodesets are deployed with the latest version +func DataplaneNodesetsDeployed(version *corev1beta1.OpenStackVersion, dataplaneNodesets *dataplanev1.OpenStackDataPlaneNodeSetList) bool { + for _, nodeset := range dataplaneNodesets.Items { + if nodeset.Generation != nodeset.Status.ObservedGeneration { + return false + } + if !nodeset.IsReady() { + return false + } + if nodeset.Status.DeployedVersion != version.Spec.TargetVersion { + return false + } + + } + return true +} diff --git a/pkg/openstack/designate.go b/pkg/openstack/designate.go index d1cb0c9bc..6437ce013 100644 --- a/pkg/openstack/designate.go +++ b/pkg/openstack/designate.go @@ -177,17 +177,17 @@ func ReconcileDesignate(ctx context.Context, instance *corev1beta1.OpenStackCont } -// DesignateImageCheck - return true if the Designate images match on the ControlPlane and Version, or if Designate is not enabled -func DesignateImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// DesignateImageMatch - return true if the Designate images match on the ControlPlane and Version, or if Designate is not enabled +func DesignateImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Designate.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.DesignateAPIImage, version.Status.ContainerImages.DesignateAPIImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.DesignateCentralImage, version.Status.ContainerImages.DesignateCentralImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.DesignateMdnsImage, version.Status.ContainerImages.DesignateMdnsImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.DesignateProducerImage, version.Status.ContainerImages.DesignateProducerImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.DesignateWorkerImage, version.Status.ContainerImages.DesignateWorkerImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.DesignateBackendbind9Image, version.Status.ContainerImages.DesignateBackendbind9Image) || - !compareStringPointers(controlPlane.Status.ContainerImages.DesignateUnboundImage, version.Status.ContainerImages.DesignateUnboundImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.DesignateAPIImage, version.Status.ContainerImages.DesignateAPIImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.DesignateCentralImage, version.Status.ContainerImages.DesignateCentralImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.DesignateMdnsImage, version.Status.ContainerImages.DesignateMdnsImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.DesignateProducerImage, version.Status.ContainerImages.DesignateProducerImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.DesignateWorkerImage, version.Status.ContainerImages.DesignateWorkerImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.DesignateBackendbind9Image, version.Status.ContainerImages.DesignateBackendbind9Image) || + !stringPointersEqual(controlPlane.Status.ContainerImages.DesignateUnboundImage, version.Status.ContainerImages.DesignateUnboundImage) { return false } } diff --git a/pkg/openstack/dnsmasq.go b/pkg/openstack/dnsmasq.go index 515746d72..5599f16a7 100644 --- a/pkg/openstack/dnsmasq.go +++ b/pkg/openstack/dnsmasq.go @@ -78,11 +78,11 @@ func ReconcileDNSMasqs(ctx context.Context, instance *corev1beta1.OpenStackContr } -// DnsmasqImageCheck - return true if the Dnsmasq images match on the ControlPlane and Version, or if Dnsmasq is not enabled -func DnsmasqImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// DnsmasqImageMatch - return true if the Dnsmasq images match on the ControlPlane and Version, or if Dnsmasq is not enabled +func DnsmasqImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.DNS.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.InfraDnsmasqImage, version.Status.ContainerImages.InfraDnsmasqImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.InfraDnsmasqImage, version.Status.ContainerImages.InfraDnsmasqImage) { return false } } diff --git a/pkg/openstack/galera.go b/pkg/openstack/galera.go index c57bc3857..0ca0a68df 100644 --- a/pkg/openstack/galera.go +++ b/pkg/openstack/galera.go @@ -34,6 +34,7 @@ func ReconcileGaleras( version *corev1beta1.OpenStackVersion, helper *helper.Helper, ) (ctrl.Result, error) { + Log := GetLogger(ctx) if !instance.Spec.Galera.Enabled { return ctrl.Result{}, nil } @@ -115,12 +116,14 @@ func ReconcileGaleras( return ctrl.Result{}, fmt.Errorf(errors) } else if len(inprogress) > 0 { + Log.Info("Galera in progress") instance.Status.Conditions.Set(condition.FalseCondition( corev1beta1.OpenStackControlPlaneMariaDBReadyCondition, condition.RequestedReason, condition.SeverityInfo, corev1beta1.OpenStackControlPlaneMariaDBReadyRunningMessage)) } else { + Log.Info("Galera ready condition is true") instance.Status.Conditions.MarkTrue( corev1beta1.OpenStackControlPlaneMariaDBReadyCondition, corev1beta1.OpenStackControlPlaneMariaDBReadyMessage, @@ -183,11 +186,11 @@ func reconcileGalera( return galeraCreating, nil } -// GaleraImageCheck - return true if the Galera images match on the ControlPlane and Version, or if Galera is not enabled -func GaleraImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// GaleraImageMatch - return true if the Galera images match on the ControlPlane and Version, or if Galera is not enabled +func GaleraImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Galera.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.MariadbImage, version.Status.ContainerImages.MariadbImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.MariadbImage, version.Status.ContainerImages.MariadbImage) { return false } } diff --git a/pkg/openstack/glance.go b/pkg/openstack/glance.go index 8d9d25a1a..a0b30c0de 100644 --- a/pkg/openstack/glance.go +++ b/pkg/openstack/glance.go @@ -211,11 +211,11 @@ func getGlanceAPILabelMap(name string, apiName string, apiType string) map[strin } } -// GlanceImageCheck - return true if the glance images match on the ControlPlane and Version, or if Glance is not enabled -func GlanceImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// GlanceImageMatch - return true if the glance images match on the ControlPlane and Version, or if Glance is not enabled +func GlanceImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Glance.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.GlanceAPIImage, version.Status.ContainerImages.GlanceAPIImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.GlanceAPIImage, version.Status.ContainerImages.GlanceAPIImage) { return false } } diff --git a/pkg/openstack/heat.go b/pkg/openstack/heat.go index c1ce46007..c7b63bcca 100644 --- a/pkg/openstack/heat.go +++ b/pkg/openstack/heat.go @@ -197,13 +197,13 @@ func ReconcileHeat(ctx context.Context, instance *corev1beta1.OpenStackControlPl return ctrl.Result{}, nil } -// HeatImageCheck - return true if the heat images match on the ControlPlane and Version, or if Heat is not enabled -func HeatImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// HeatImageMatch - return true if the heat images match on the ControlPlane and Version, or if Heat is not enabled +func HeatImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Heat.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.HeatAPIImage, version.Status.ContainerImages.HeatAPIImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.HeatCfnapiImage, version.Status.ContainerImages.HeatCfnapiImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.HeatEngineImage, version.Status.ContainerImages.HeatEngineImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.HeatAPIImage, version.Status.ContainerImages.HeatAPIImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.HeatCfnapiImage, version.Status.ContainerImages.HeatCfnapiImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.HeatEngineImage, version.Status.ContainerImages.HeatEngineImage) { return false } } diff --git a/pkg/openstack/horizon.go b/pkg/openstack/horizon.go index 317be9757..dceb5b871 100644 --- a/pkg/openstack/horizon.go +++ b/pkg/openstack/horizon.go @@ -171,11 +171,11 @@ func ReconcileHorizon(ctx context.Context, instance *corev1beta1.OpenStackContro return ctrl.Result{}, nil } -// HorizonImageCheck - return true if horizon images match on the ControlPlane and Version, or if Horizon is not enabled -func HorizonImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// HorizonImageMatch - return true if horizon images match on the ControlPlane and Version, or if Horizon is not enabled +func HorizonImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Horizon.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.HorizonImage, version.Status.ContainerImages.HorizonImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.HorizonImage, version.Status.ContainerImages.HorizonImage) { return false } } diff --git a/pkg/openstack/ironic.go b/pkg/openstack/ironic.go index 802a89ca2..982af64bf 100644 --- a/pkg/openstack/ironic.go +++ b/pkg/openstack/ironic.go @@ -203,15 +203,15 @@ func ReconcileIronic(ctx context.Context, instance *corev1beta1.OpenStackControl } // IronicImagesCheck - return true if the ironic images match on the ControlPlane and Version, or if Ironic is not enabled -func IronicImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +func IronicImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Ironic.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.IronicAPIImage, version.Status.ContainerImages.IronicAPIImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.IronicConductorImage, version.Status.ContainerImages.IronicConductorImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.IronicInspectorImage, version.Status.ContainerImages.IronicInspectorImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.IronicNeutronAgentImage, version.Status.ContainerImages.IronicNeutronAgentImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.IronicPxeImage, version.Status.ContainerImages.IronicPxeImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.IronicPythonAgentImage, version.Status.ContainerImages.IronicPythonAgentImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.IronicAPIImage, version.Status.ContainerImages.IronicAPIImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.IronicConductorImage, version.Status.ContainerImages.IronicConductorImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.IronicInspectorImage, version.Status.ContainerImages.IronicInspectorImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.IronicNeutronAgentImage, version.Status.ContainerImages.IronicNeutronAgentImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.IronicPxeImage, version.Status.ContainerImages.IronicPxeImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.IronicPythonAgentImage, version.Status.ContainerImages.IronicPythonAgentImage) { return false } } diff --git a/pkg/openstack/keystone.go b/pkg/openstack/keystone.go index acfc5e8bb..678e61ada 100644 --- a/pkg/openstack/keystone.go +++ b/pkg/openstack/keystone.go @@ -35,6 +35,7 @@ func ReconcileKeystoneAPI(ctx context.Context, instance *corev1beta1.OpenStackCo } instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneKeystoneAPIReadyCondition) instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneExposeKeystoneAPIReadyCondition) + instance.Status.ContainerImages.KeystoneAPIImage = nil return ctrl.Result{}, nil } @@ -122,6 +123,7 @@ func ReconcileKeystoneAPI(ctx context.Context, instance *corev1beta1.OpenStackCo }) if err != nil { + Log.Error(err, "Failed to reconcile KeystoneAPI") instance.Status.Conditions.Set(condition.FalseCondition( corev1beta1.OpenStackControlPlaneKeystoneAPIReadyCondition, condition.ErrorReason, @@ -135,6 +137,7 @@ func ReconcileKeystoneAPI(ctx context.Context, instance *corev1beta1.OpenStackCo } if keystoneAPI.Status.ObservedGeneration == keystoneAPI.Generation && keystoneAPI.IsReady() { + Log.Info("KeystoneAPI ready condition is true") instance.Status.ContainerImages.KeystoneAPIImage = version.Status.ContainerImages.KeystoneAPIImage instance.Status.Conditions.MarkTrue(corev1beta1.OpenStackControlPlaneKeystoneAPIReadyCondition, corev1beta1.OpenStackControlPlaneKeystoneAPIReadyMessage) } else { @@ -148,11 +151,11 @@ func ReconcileKeystoneAPI(ctx context.Context, instance *corev1beta1.OpenStackCo return ctrl.Result{}, nil } -// KeystoneImageCheck - return true if the keystone images match on the ControlPlane and Version, or if Keystone is not enabled -func KeystoneImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// KeystoneImageMatch - return true if the keystone images match on the ControlPlane and Version, or if Keystone is not enabled +func KeystoneImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Keystone.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.KeystoneAPIImage, version.Status.ContainerImages.KeystoneAPIImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.KeystoneAPIImage, version.Status.ContainerImages.KeystoneAPIImage) { return false } } diff --git a/pkg/openstack/manila.go b/pkg/openstack/manila.go index d89924d96..023333dfe 100644 --- a/pkg/openstack/manila.go +++ b/pkg/openstack/manila.go @@ -185,16 +185,16 @@ func ReconcileManila(ctx context.Context, instance *corev1beta1.OpenStackControl return ctrl.Result{}, nil } -// ManilaImageCheck - return true if the Manila images match on the ControlPlane and Version, or if Manila is not enabled -func ManilaImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// ManilaImageMatch - return true if the Manila images match on the ControlPlane and Version, or if Manila is not enabled +func ManilaImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Manila.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.ManilaAPIImage, version.Status.ContainerImages.ManilaAPIImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.ManilaSchedulerImage, version.Status.ContainerImages.ManilaSchedulerImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.ManilaAPIImage, version.Status.ContainerImages.ManilaAPIImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.ManilaSchedulerImage, version.Status.ContainerImages.ManilaSchedulerImage) { return false } for name, img := range version.Status.ContainerImages.ManilaShareImages { - if !compareStringPointers(controlPlane.Status.ContainerImages.ManilaShareImages[name], img) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.ManilaShareImages[name], img) { return false } } diff --git a/pkg/openstack/memcached.go b/pkg/openstack/memcached.go index 01b95461c..6596e65a4 100644 --- a/pkg/openstack/memcached.go +++ b/pkg/openstack/memcached.go @@ -43,6 +43,7 @@ func ReconcileMemcacheds( listOpts := []client.ListOption{ client.InNamespace(instance.Namespace), } + Log := GetLogger(ctx) if err := helper.GetClient().List(ctx, memcacheds, listOpts...); err != nil { instance.Status.Conditions.Set(condition.FalseCondition( corev1beta1.OpenStackControlPlaneMemcachedReadyCondition, @@ -121,6 +122,7 @@ func ReconcileMemcacheds( condition.SeverityInfo, corev1beta1.OpenStackControlPlaneMemcachedReadyRunningMessage)) } else { + Log.Info("Memcached ready condition is true") instance.Status.Conditions.MarkTrue( corev1beta1.OpenStackControlPlaneMemcachedReadyCondition, corev1beta1.OpenStackControlPlaneMemcachedReadyMessage, @@ -161,6 +163,7 @@ func reconcileMemcached( tlsCert := "" if instance.Spec.TLS.PodLevel.Enabled { + Log.Info("Reconciling Memcached TLS", "Memcached.Namespace", instance.Namespace, "Memcached.Name", name) certRequest := certmanager.CertificateRequest{ IssuerName: instance.GetInternalIssuer(), CertName: fmt.Sprintf("%s-svc", memcached.Name), @@ -223,11 +226,11 @@ func reconcileMemcached( return memcachedCreating, ctrl.Result{}, nil } -// MemcachedImageCheck - return true if the memcached images match on the ControlPlane and Version, or if Memcached is not enabled -func MemcachedImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// MemcachedImageMatch - return true if the memcached images match on the ControlPlane and Version, or if Memcached is not enabled +func MemcachedImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Memcached.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.InfraMemcachedImage, version.Status.ContainerImages.InfraMemcachedImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.InfraMemcachedImage, version.Status.ContainerImages.InfraMemcachedImage) { return false } } diff --git a/pkg/openstack/neutron.go b/pkg/openstack/neutron.go index 72b04ce9f..5e3aee831 100644 --- a/pkg/openstack/neutron.go +++ b/pkg/openstack/neutron.go @@ -194,11 +194,11 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro } -// NeutronImageCheck - return true if the neutron images match on the ControlPlane and Version, or if Neutron is not enabled -func NeutronImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// NeutronImageMatch - return true if the neutron images match on the ControlPlane and Version, or if Neutron is not enabled +func NeutronImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Neutron.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.NeutronAPIImage, version.Status.ContainerImages.NeutronAPIImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.NeutronAPIImage, version.Status.ContainerImages.NeutronAPIImage) { return false } } diff --git a/pkg/openstack/nova.go b/pkg/openstack/nova.go index 5392cda8c..4d70b9e96 100644 --- a/pkg/openstack/nova.go +++ b/pkg/openstack/nova.go @@ -402,15 +402,15 @@ func noVNCProxyEnabled(vncproxy novav1.NovaNoVNCProxyTemplate) bool { return vncproxy.Enabled != nil && *vncproxy.Enabled } -// NovaImageCheck - return true if the nova images match on the ControlPlane and Version, or if Nova is not enabled -func NovaImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// NovaImageMatch - return true if the nova images match on the ControlPlane and Version, or if Nova is not enabled +func NovaImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Nova.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.NovaAPIImage, version.Status.ContainerImages.NovaAPIImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.NovaComputeImage, version.Status.ContainerImages.NovaComputeImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.NovaConductorImage, version.Status.ContainerImages.NovaConductorImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.NovaNovncImage, version.Status.ContainerImages.NovaNovncImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.NovaSchedulerImage, version.Status.ContainerImages.NovaSchedulerImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.NovaAPIImage, version.Status.ContainerImages.NovaAPIImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.NovaComputeImage, version.Status.ContainerImages.NovaComputeImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.NovaConductorImage, version.Status.ContainerImages.NovaConductorImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.NovaNovncImage, version.Status.ContainerImages.NovaNovncImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.NovaSchedulerImage, version.Status.ContainerImages.NovaSchedulerImage) { return false } } diff --git a/pkg/openstack/octavia.go b/pkg/openstack/octavia.go index 75f828c00..4785404ee 100644 --- a/pkg/openstack/octavia.go +++ b/pkg/openstack/octavia.go @@ -210,15 +210,15 @@ func ReconcileOctavia(ctx context.Context, instance *corev1beta1.OpenStackContro return ctrl.Result{}, nil } -// OctaviaImageCheck - return true if the octavia images match on the ControlPlane and Version, or if Octavia is not enabled -func OctaviaImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// OctaviaImageMatch - return true if the octavia images match on the ControlPlane and Version, or if Octavia is not enabled +func OctaviaImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Octavia.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.OctaviaAPIImage, version.Status.ContainerImages.OctaviaAPIImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.OctaviaWorkerImage, version.Status.ContainerImages.OctaviaWorkerImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.OctaviaHealthmanagerImage, version.Status.ContainerImages.OctaviaHealthmanagerImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.OctaviaHousekeepingImage, version.Status.ContainerImages.OctaviaHousekeepingImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.ApacheImage, version.Status.ContainerImages.ApacheImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.OctaviaAPIImage, version.Status.ContainerImages.OctaviaAPIImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.OctaviaWorkerImage, version.Status.ContainerImages.OctaviaWorkerImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.OctaviaHealthmanagerImage, version.Status.ContainerImages.OctaviaHealthmanagerImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.OctaviaHousekeepingImage, version.Status.ContainerImages.OctaviaHousekeepingImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.ApacheImage, version.Status.ContainerImages.ApacheImage) { return false } } diff --git a/pkg/openstack/openstackclient.go b/pkg/openstack/openstackclient.go index 1f20a0c12..cad9f2817 100644 --- a/pkg/openstack/openstackclient.go +++ b/pkg/openstack/openstackclient.go @@ -61,6 +61,7 @@ func ReconcileOpenStackClient(ctx context.Context, instance *corev1.OpenStackCon }) if err != nil { + Log.Error(err, "Failed to reconcile OpenStackClient") instance.Status.Conditions.Set(condition.FalseCondition( corev1.OpenStackControlPlaneClientReadyCondition, condition.ErrorReason, @@ -89,9 +90,9 @@ func ReconcileOpenStackClient(ctx context.Context, instance *corev1.OpenStackCon return ctrl.Result{}, nil } -// ClientImageCheck - return true if the openstackclient images match on the ControlPlane and Version, or if OpenstackClient is not enabled -func ClientImageCheck(controlPlane *corev1.OpenStackControlPlane, version *corev1.OpenStackVersion) bool { +// ClientImageMatch - return true if the openstackclient images match on the ControlPlane and Version, or if OpenstackClient is not enabled +func ClientImageMatch(controlPlane *corev1.OpenStackControlPlane, version *corev1.OpenStackVersion) bool { //FIXME: (dprince) - OpenStackClientSection should have Enabled? - return compareStringPointers(controlPlane.Status.ContainerImages.OpenstackClientImage, version.Status.ContainerImages.OpenstackClientImage) + return stringPointersEqual(controlPlane.Status.ContainerImages.OpenstackClientImage, version.Status.ContainerImages.OpenstackClientImage) } diff --git a/pkg/openstack/ovn.go b/pkg/openstack/ovn.go index 2867c514b..0d279895a 100644 --- a/pkg/openstack/ovn.go +++ b/pkg/openstack/ovn.go @@ -53,6 +53,7 @@ func ReconcileOVN(ctx context.Context, instance *corev1beta1.OpenStackControlPla // Expect all services (dbclusters, northd, ovn-controller) ready if OVNDBClustersReady && OVNNorthdReady && OVNControllerReady { + Log.Info("OVN is ready") instance.Status.Conditions.MarkTrue(corev1beta1.OpenStackControlPlaneOVNReadyCondition, corev1beta1.OpenStackControlPlaneOVNReadyMessage) } else if !instance.Spec.Ovn.Enabled { instance.Status.Conditions.Remove(corev1beta1.OpenStackControlPlaneOVNReadyCondition) @@ -395,6 +396,7 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack } if OVNController.Status.ObservedGeneration == OVNController.Generation && OVNController.IsReady() { + Log.Info("OVN Controller ready condition is true") instance.Status.ContainerImages.OvnControllerImage = version.Status.ContainerImages.OvnControllerImage instance.Status.ContainerImages.OvnControllerOvsImage = version.Status.ContainerImages.OvnControllerOvsImage return true, nil @@ -403,35 +405,35 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack } } -// OVNControllerImageCheck - return true if the OVN Controller images match on the ControlPlane and Version, or if OVN is not enabled -func OVNControllerImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// OVNControllerImageMatch - return true if the OVN Controller images match on the ControlPlane and Version, or if OVN is not enabled +func OVNControllerImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Ovn.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.OvnControllerImage, version.Status.ContainerImages.OvnControllerImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.OvnControllerOvsImage, version.Status.ContainerImages.OvnControllerOvsImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.OvnControllerImage, version.Status.ContainerImages.OvnControllerImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.OvnControllerOvsImage, version.Status.ContainerImages.OvnControllerOvsImage) { return false } } return true } -// OVNDbClusterImageCheck - return true if the OVN DbCluster images match on the ControlPlane and Version, or if OVN is not enabled -func OVNDbClusterImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// OVNDbClusterImageMatch - return true if the OVN DbCluster images match on the ControlPlane and Version, or if OVN is not enabled +func OVNDbClusterImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Ovn.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.OvnNbDbclusterImage, version.Status.ContainerImages.OvnNbDbclusterImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.OvnSbDbclusterImage, version.Status.ContainerImages.OvnSbDbclusterImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.OvnNbDbclusterImage, version.Status.ContainerImages.OvnNbDbclusterImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.OvnSbDbclusterImage, version.Status.ContainerImages.OvnSbDbclusterImage) { return false } } return true } -// OVNNorthImageCheck - return true if the OVN North images match on the ControlPlane and Version, or if OVN is not enabled -func OVNNorthImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// OVNNorthImageMatch - return true if the OVN North images match on the ControlPlane and Version, or if OVN is not enabled +func OVNNorthImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Ovn.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.OvnNorthdImage, version.Status.ContainerImages.OvnNorthdImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.OvnNorthdImage, version.Status.ContainerImages.OvnNorthdImage) { return false } } diff --git a/pkg/openstack/placement.go b/pkg/openstack/placement.go index f70dcc125..2763dbdb9 100644 --- a/pkg/openstack/placement.go +++ b/pkg/openstack/placement.go @@ -145,11 +145,11 @@ func ReconcilePlacementAPI(ctx context.Context, instance *corev1beta1.OpenStackC } -// PlacementImageCheck - return true if the placement images match on the ControlPlane and Version, or if Placement is not enabled -func PlacementImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// PlacementImageMatch - return true if the placement images match on the ControlPlane and Version, or if Placement is not enabled +func PlacementImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Placement.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.PlacementAPIImage, version.Status.ContainerImages.PlacementAPIImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.PlacementAPIImage, version.Status.ContainerImages.PlacementAPIImage) { return false } } diff --git a/pkg/openstack/rabbitmq.go b/pkg/openstack/rabbitmq.go index 11909eeb2..018083eb9 100644 --- a/pkg/openstack/rabbitmq.go +++ b/pkg/openstack/rabbitmq.go @@ -363,6 +363,7 @@ func reconcileRabbitMQ( // Forced to hardcode "ClusterAvailable" here because linter will not allow // us to import "github.com/rabbitmq/cluster-operator/internal/status" if string(oldCond.Type) == "ClusterAvailable" && oldCond.Status == corev1.ConditionTrue { + Log.Info("RabbitMQ ready condition is true") instance.Status.ContainerImages.RabbitmqImage = version.Status.ContainerImages.RabbitmqImage return mqReady, ctrl.Result{}, nil } @@ -372,11 +373,11 @@ func reconcileRabbitMQ( return mqCreating, ctrl.Result{}, nil } -// RabbitmqImageCheck - return true if the rabbitmq images match on the ControlPlane and Version, or if Rabbitmq is not enabled -func RabbitmqImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// RabbitmqImageMatch - return true if the rabbitmq images match on the ControlPlane and Version, or if Rabbitmq is not enabled +func RabbitmqImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Rabbitmq.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.RabbitmqImage, version.Status.ContainerImages.RabbitmqImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.RabbitmqImage, version.Status.ContainerImages.RabbitmqImage) { return false } } diff --git a/pkg/openstack/swift.go b/pkg/openstack/swift.go index a26af8040..6891bc0d9 100644 --- a/pkg/openstack/swift.go +++ b/pkg/openstack/swift.go @@ -153,14 +153,14 @@ func ReconcileSwift(ctx context.Context, instance *corev1beta1.OpenStackControlP return ctrl.Result{}, nil } -// SwiftImageCheck - return true if the swift images match on the ControlPlane and Version, or if Swift is not enabled -func SwiftImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// SwiftImageMatch - return true if the swift images match on the ControlPlane and Version, or if Swift is not enabled +func SwiftImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Swift.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.SwiftAccountImage, version.Status.ContainerImages.SwiftAccountImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.SwiftContainerImage, version.Status.ContainerImages.SwiftContainerImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.SwiftObjectImage, version.Status.ContainerImages.SwiftObjectImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.SwiftProxyImage, version.Status.ContainerImages.SwiftProxyImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.SwiftAccountImage, version.Status.ContainerImages.SwiftAccountImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.SwiftContainerImage, version.Status.ContainerImages.SwiftContainerImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.SwiftObjectImage, version.Status.ContainerImages.SwiftObjectImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.SwiftProxyImage, version.Status.ContainerImages.SwiftProxyImage) { return false } } diff --git a/pkg/openstack/telemetry.go b/pkg/openstack/telemetry.go index d845298b8..97f1c7cfb 100644 --- a/pkg/openstack/telemetry.go +++ b/pkg/openstack/telemetry.go @@ -312,20 +312,20 @@ func ReconcileTelemetry(ctx context.Context, instance *corev1beta1.OpenStackCont return ctrl.Result{}, nil } -// TelemetryImageCheck - return true if the telemetry images match on the ControlPlane and Version, or if Telemetry is not enabled -func TelemetryImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { +// TelemetryImageMatch - return true if the telemetry images match on the ControlPlane and Version, or if Telemetry is not enabled +func TelemetryImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { if controlPlane.Spec.Telemetry.Enabled { - if !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerCentralImage, version.Status.ContainerImages.CeilometerCentralImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerComputeImage, version.Status.ContainerImages.CeilometerComputeImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerIpmiImage, version.Status.ContainerImages.CeilometerIpmiImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerNotificationImage, version.Status.ContainerImages.CeilometerNotificationImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerSgcoreImage, version.Status.ContainerImages.CeilometerSgcoreImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.CeilometerProxyImage, version.Status.ContainerImages.CeilometerProxyImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.AodhAPIImage, version.Status.ContainerImages.AodhAPIImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.AodhEvaluatorImage, version.Status.ContainerImages.AodhEvaluatorImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.AodhNotifierImage, version.Status.ContainerImages.AodhNotifierImage) || - !compareStringPointers(controlPlane.Status.ContainerImages.AodhListenerImage, version.Status.ContainerImages.AodhListenerImage) { + if !stringPointersEqual(controlPlane.Status.ContainerImages.CeilometerCentralImage, version.Status.ContainerImages.CeilometerCentralImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.CeilometerComputeImage, version.Status.ContainerImages.CeilometerComputeImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.CeilometerIpmiImage, version.Status.ContainerImages.CeilometerIpmiImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.CeilometerNotificationImage, version.Status.ContainerImages.CeilometerNotificationImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.CeilometerSgcoreImage, version.Status.ContainerImages.CeilometerSgcoreImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.CeilometerProxyImage, version.Status.ContainerImages.CeilometerProxyImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.AodhAPIImage, version.Status.ContainerImages.AodhAPIImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.AodhEvaluatorImage, version.Status.ContainerImages.AodhEvaluatorImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.AodhNotifierImage, version.Status.ContainerImages.AodhNotifierImage) || + !stringPointersEqual(controlPlane.Status.ContainerImages.AodhListenerImage, version.Status.ContainerImages.AodhListenerImage) { return false } diff --git a/pkg/openstack/version.go b/pkg/openstack/version.go index 9704164e9..f3904fc4f 100644 --- a/pkg/openstack/version.go +++ b/pkg/openstack/version.go @@ -23,7 +23,7 @@ func InitializeOpenStackVersionImageDefaults(ctx context.Context, envImages map[ d := reflect.ValueOf(defaults).Elem() for key, val := range envImages { - Log.Info(fmt.Sprintf("Initialize OpenStackVersion Image Defaults: %s", key)) + //Log.Info(fmt.Sprintf("Initialize OpenStackVersion Image Defaults: %s", key)) r := regexp.MustCompile(`[A-Za-z0-9]+`) matches := r.FindAllString(key, -1) @@ -40,7 +40,7 @@ func InitializeOpenStackVersionImageDefaults(ctx context.Context, envImages map[ // format API so we adhere to go linting standards fieldName = strings.Replace(fieldName, "Api", "API", -1) } - Log.Info(fmt.Sprintf("Initialize Field name: %s", fieldName)) + //Log.Info(fmt.Sprintf("Initialize Field name: %s", fieldName)) field := d.FieldByName(fieldName) if field.IsValid() && field.CanSet() { field.Set(reflect.ValueOf(val)) @@ -205,7 +205,7 @@ func ReconcileVersion(ctx context.Context, instance *corev1beta1.OpenStackContro return ctrl.Result{}, version, nil } -func compareStringPointers(a, b *string) bool { +func stringPointersEqual(a, b *string) bool { if a == nil && b == nil { return true } @@ -215,33 +215,33 @@ func compareStringPointers(a, b *string) bool { return *a == *b } -// ControlplaneContainerImageCheck - function to compare the ContainerImages on the controlPlane to the OpenStackVersion +// ControlplaneContainerImageMatch - function to compare the ContainerImages on the controlPlane to the OpenStackVersion // only enabled services are checked -func ControlplaneContainerImageCheck(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { - - if BarbicanImageCheck(controlPlane, version) && - CinderImageCheck(controlPlane, version) && - DesignateImageCheck(controlPlane, version) && - DnsmasqImageCheck(controlPlane, version) && - GaleraImageCheck(controlPlane, version) && - GlanceImageCheck(controlPlane, version) && - HeatImageCheck(controlPlane, version) && - HorizonImageCheck(controlPlane, version) && - IronicImageCheck(controlPlane, version) && - KeystoneImageCheck(controlPlane, version) && - ManilaImageCheck(controlPlane, version) && - MemcachedImageCheck(controlPlane, version) && - NeutronImageCheck(controlPlane, version) && - NovaImageCheck(controlPlane, version) && - OctaviaImageCheck(controlPlane, version) && - ClientImageCheck(controlPlane, version) && - OVNControllerImageCheck(controlPlane, version) && - OVNNorthImageCheck(controlPlane, version) && - OVNDbClusterImageCheck(controlPlane, version) && - PlacementImageCheck(controlPlane, version) && - RabbitmqImageCheck(controlPlane, version) && - SwiftImageCheck(controlPlane, version) && - TelemetryImageCheck(controlPlane, version) { +func ControlplaneContainerImageMatch(controlPlane *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion) bool { + + if BarbicanImageMatch(controlPlane, version) && + CinderImageMatch(controlPlane, version) && + DesignateImageMatch(controlPlane, version) && + DnsmasqImageMatch(controlPlane, version) && + GaleraImageMatch(controlPlane, version) && + GlanceImageMatch(controlPlane, version) && + HeatImageMatch(controlPlane, version) && + HorizonImageMatch(controlPlane, version) && + IronicImageMatch(controlPlane, version) && + KeystoneImageMatch(controlPlane, version) && + ManilaImageMatch(controlPlane, version) && + MemcachedImageMatch(controlPlane, version) && + NeutronImageMatch(controlPlane, version) && + NovaImageMatch(controlPlane, version) && + OctaviaImageMatch(controlPlane, version) && + ClientImageMatch(controlPlane, version) && + OVNControllerImageMatch(controlPlane, version) && + OVNNorthImageMatch(controlPlane, version) && + OVNDbClusterImageMatch(controlPlane, version) && + PlacementImageMatch(controlPlane, version) && + RabbitmqImageMatch(controlPlane, version) && + SwiftImageMatch(controlPlane, version) && + TelemetryImageMatch(controlPlane, version) { return true } diff --git a/tests/functional/base_test.go b/tests/functional/base_test.go index 388f9df4e..214091541 100644 --- a/tests/functional/base_test.go +++ b/tests/functional/base_test.go @@ -259,7 +259,6 @@ func OpenStackVersionRemoveFinalizer(ctx context.Context, name types.NamespacedN instance := GetOpenStackVersion(name) instance.SetFinalizers([]string{}) g.Expect(th.K8sClient.Update(ctx, instance)).Should(Succeed()) - }, timeout, interval).Should(Succeed()) } diff --git a/tests/functional/openstackoperator_controller_test.go b/tests/functional/openstackoperator_controller_test.go index b9b31b680..ccbd2725b 100644 --- a/tests/functional/openstackoperator_controller_test.go +++ b/tests/functional/openstackoperator_controller_test.go @@ -660,7 +660,7 @@ var _ = Describe("OpenStackOperator controller", func() { g.Expect(osversion).Should(Not(BeNil())) th.ExpectCondition( - names.OpenStackControlplaneName, + names.OpenStackVersionName, ConditionGetterFunc(OpenStackVersionConditionGetter), corev1.OpenStackVersionInitialized, k8s_corev1.ConditionTrue, @@ -883,7 +883,7 @@ var _ = Describe("OpenStackOperator controller", func() { g.Expect(osversion).Should(Not(BeNil())) th.ExpectCondition( - names.OpenStackControlplaneName, + names.OpenStackVersionName, ConditionGetterFunc(OpenStackVersionConditionGetter), corev1.OpenStackVersionInitialized, k8s_corev1.ConditionTrue, @@ -1639,7 +1639,7 @@ var _ = Describe("OpenStackOperator controller", func() { g.Expect(osversion.OwnerReferences).Should(HaveLen(1)) th.ExpectCondition( - names.OpenStackControlplaneName, + names.OpenStackVersionName, ConditionGetterFunc(OpenStackVersionConditionGetter), corev1.OpenStackVersionInitialized, k8s_corev1.ConditionTrue, diff --git a/tests/functional/openstackversion_controller_test.go b/tests/functional/openstackversion_controller_test.go index e197d37fd..642bbd977 100644 --- a/tests/functional/openstackversion_controller_test.go +++ b/tests/functional/openstackversion_controller_test.go @@ -39,6 +39,9 @@ var _ = Describe("OpenStackOperator controller", func() { err := os.Setenv("OPERATOR_TEMPLATES", "../../templates") Expect(err).NotTo(HaveOccurred()) + // create cluster config map which is used to validate if cluster supports fips + DeferCleanup(k8sClient.Delete, ctx, CreateClusterConfigCM()) + }) When("A default OpenStackVersion instance is created with no Controlplane", func() { @@ -87,13 +90,6 @@ var _ = Describe("OpenStackOperator controller", func() { It("should initialize container images", func() { Eventually(func(g Gomega) { - th.ExpectCondition( - names.OpenStackVersionName, - ConditionGetterFunc(OpenStackVersionConditionGetter), - corev1.OpenStackVersionInitialized, - k8s_corev1.ConditionTrue, - ) - version := GetOpenStackVersion(names.OpenStackVersionName) g.Expect(version).Should(Not(BeNil())) @@ -129,9 +125,7 @@ var _ = Describe("OpenStackOperator controller", func() { g.Expect(version.Status.ContainerImages.EdpmIscsidImage).ShouldNot(BeNil()) g.Expect(version.Status.ContainerImages.EdpmLogrotateCrondImage).ShouldNot(BeNil()) g.Expect(version.Status.ContainerImages.EdpmMultipathdImage).ShouldNot(BeNil()) - g.Expect(version.Status.ContainerImages.EdpmNeutronDhcpAgentImage).ShouldNot(BeNil()) g.Expect(version.Status.ContainerImages.EdpmNeutronMetadataAgentImage).ShouldNot(BeNil()) - g.Expect(version.Status.ContainerImages.EdpmNeutronOvnAgentImage).ShouldNot(BeNil()) g.Expect(version.Status.ContainerImages.EdpmNeutronSriovAgentImage).ShouldNot(BeNil()) g.Expect(version.Status.ContainerImages.EdpmNodeExporterImage).ShouldNot(BeNil()) g.Expect(version.Status.ContainerImages.EdpmOvnBgpAgentImage).ShouldNot(BeNil()) diff --git a/tests/functional/suite_test.go b/tests/functional/suite_test.go index dae7497e5..e87fe27d1 100644 --- a/tests/functional/suite_test.go +++ b/tests/functional/suite_test.go @@ -34,6 +34,7 @@ import ( barbicanv1 "github.com/openstack-k8s-operators/barbican-operator/api/v1beta1" cinderv1 "github.com/openstack-k8s-operators/cinder-operator/api/v1beta1" + dataplanev1beta1 "github.com/openstack-k8s-operators/dataplane-operator/api/v1beta1" designatev1 "github.com/openstack-k8s-operators/designate-operator/api/v1beta1" glancev1 "github.com/openstack-k8s-operators/glance-operator/api/v1beta1" heatv1 "github.com/openstack-k8s-operators/heat-operator/api/v1beta1" @@ -160,6 +161,9 @@ var _ = BeforeSuite(func() { telemetryv1CRDs, err := test.GetCRDDirFromModule( "github.com/openstack-k8s-operators/telemetry-operator/api", "../../go.mod", "bases") Expect(err).ShouldNot(HaveOccurred()) + dataplanev1CRDs, err := test.GetCRDDirFromModule( + "github.com/openstack-k8s-operators/dataplane-operator/api", "../../go.mod", "bases") + Expect(err).ShouldNot(HaveOccurred()) designatev1CRDs, err := test.GetCRDDirFromModule( "github.com/openstack-k8s-operators/designate-operator/api", "../../go.mod", "bases") Expect(err).ShouldNot(HaveOccurred()) @@ -193,6 +197,7 @@ var _ = BeforeSuite(func() { placementv1CRDs, swiftv1CRDs, telemetryv1CRDs, + dataplanev1CRDs, designatev1CRDs, barbicanv1CRDs, rabbitmqv2CRDs, @@ -251,6 +256,8 @@ var _ = BeforeSuite(func() { Expect(err).NotTo(HaveOccurred()) err = telemetryv1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) + err = dataplanev1beta1.AddToScheme(scheme.Scheme) + Expect(err).NotTo(HaveOccurred()) err = designatev1.AddToScheme(scheme.Scheme) Expect(err).NotTo(HaveOccurred()) err = barbicanv1.AddToScheme(scheme.Scheme)