Skip to content

Commit

Permalink
Rename InstanceHA to InstanceHa and add image to configmap
Browse files Browse the repository at this point in the history
This commits renames InstanceHA to InstanceHa to adhere to the
openstackversion naming (casing) scheme.
It also adds the Infra InstanceHa image to a dedicated configmap
so that the infra-operator can watch it and react to changes.
  • Loading branch information
lmiccini committed Sep 12, 2024
1 parent a113658 commit 0c50cc3
Show file tree
Hide file tree
Showing 24 changed files with 134 additions and 6 deletions.
2 changes: 2 additions & 0 deletions apis/bases/core.openstack.org_openstackcontrolplanes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17611,6 +17611,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstanceHaImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down
6 changes: 6 additions & 0 deletions apis/bases/core.openstack.org_openstackversions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstanceHaImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down Expand Up @@ -328,6 +330,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstanceHaImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down Expand Up @@ -502,6 +506,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstanceHaImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down
9 changes: 9 additions & 0 deletions apis/core/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ const (

// OpenStackControlPlaneTestCMReadyCondition Status=True condition which indicates if Test operator CM is ready
OpenStackControlPlaneTestCMReadyCondition condition.Type = "OpenStackControlPlaneTestCMReadyCondition"

// OpenStackControlPlaneInstanceHaCMReadyCondition Status=True condition which indicates if InstanceHa CM is ready
OpenStackControlPlaneInstanceHaCMReadyCondition condition.Type = "OpenStackControlPlaneInstanceHaCMReadyCondition"
)

// Common Messages used by API objects.
Expand Down Expand Up @@ -456,6 +459,12 @@ const (

// OpenStackControlPlaneTestCMReadyMessage
OpenStackControlPlaneTestCMReadyMessage = "OpenStackControlPlane Test Operator CM is available"

// OpenStackControlPlaneInstanceHaCMReadyErrorMessage
OpenStackControlPlaneInstanceHaCMReadyErrorMessage = "OpenStackControlPlane InstanceHa CM error occured %s"

// OpenStackControlPlaneInstanceHaCMReadyMessage
OpenStackControlPlaneInstanceHaCMReadyMessage = "OpenStackControlPlane InstanceHa CM is available"
)

// Version Conditions used by API objects.
Expand Down
1 change: 1 addition & 0 deletions apis/core/v1beta1/openstackversion_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type ContainerTemplate struct {
InfraDnsmasqImage *string `json:"infraDnsmasqImage,omitempty"`
InfraMemcachedImage *string `json:"infraMemcachedImage,omitempty"`
InfraRedisImage *string `json:"infraRedisImage,omitempty"`
InfraInstanceHaImage *string `json:"infraInstanceHaImage,omitempty"`
IronicAPIImage *string `json:"ironicAPIImage,omitempty"`
IronicConductorImage *string `json:"ironicConductorImage,omitempty"`
IronicInspectorImage *string `json:"ironicInspectorImage,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions apis/core/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ require (
github.com/openstack-k8s-operators/glance-operator/api v0.4.1-0.20240909180656-33fe3c05a637
github.com/openstack-k8s-operators/heat-operator/api v0.4.1-0.20240909065043-d5b093777de2
github.com/openstack-k8s-operators/horizon-operator/api v0.4.1-0.20240906120219-9c3e4ba4077b
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240910085802-31f905cfe219
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240912140341-4066f2ead41d
github.com/openstack-k8s-operators/ironic-operator/api v0.4.1-0.20240909085220-4736023a2e4f
github.com/openstack-k8s-operators/keystone-operator/api v0.4.1-0.20240906103150-990fe66f2e5d
github.com/openstack-k8s-operators/lib-common/modules/common v0.4.1-0.20240905123813-174296c09ec6
Expand Down
4 changes: 2 additions & 2 deletions apis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ github.com/openstack-k8s-operators/heat-operator/api v0.4.1-0.20240909065043-d5b
github.com/openstack-k8s-operators/heat-operator/api v0.4.1-0.20240909065043-d5b093777de2/go.mod h1:w+8OpHuUfk4nEUSQfFZbYGPZEkn0c1xe3fyZ062fkDA=
github.com/openstack-k8s-operators/horizon-operator/api v0.4.1-0.20240906120219-9c3e4ba4077b h1:B4kw/FovC+mKMRA8dahi2k3x751iOuBwglu9DBz0iX4=
github.com/openstack-k8s-operators/horizon-operator/api v0.4.1-0.20240906120219-9c3e4ba4077b/go.mod h1:Q9/AUCUCA959gIq3DxzUdTWvkwqDp0lz3ujW0vTPdWg=
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240910085802-31f905cfe219 h1:o0epGu5XkImn5pggs/eyZMBS2Iok8wSaaTXRBwybDCk=
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240910085802-31f905cfe219/go.mod h1:TFh01OyR/NP5Sy7vikMIpQc80AKl0WWPyYDaJBfFiGc=
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240912140341-4066f2ead41d h1:GbkbsL89plNNnyQI06VzDyJ1xe8DhDky3wAPL5g6LBs=
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240912140341-4066f2ead41d/go.mod h1:TFh01OyR/NP5Sy7vikMIpQc80AKl0WWPyYDaJBfFiGc=
github.com/openstack-k8s-operators/ironic-operator/api v0.4.1-0.20240909085220-4736023a2e4f h1:Dj1KlPwlXzLyLaEDReJg3sHyo/TMN62pKH3X0L5bsZQ=
github.com/openstack-k8s-operators/ironic-operator/api v0.4.1-0.20240909085220-4736023a2e4f/go.mod h1:iQq0r9XaY6+AN9LaJIvhoetuOwnaGIhU0XkQvHLFT9M=
github.com/openstack-k8s-operators/keystone-operator/api v0.4.1-0.20240906103150-990fe66f2e5d h1:PbTZo4RCo+RFiGZ0q/rllUXoUtxgtWAh4V0IUe3aW5k=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17611,6 +17611,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstanceHaImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down
6 changes: 6 additions & 0 deletions config/crd/bases/core.openstack.org_openstackversions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstanceHaImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down Expand Up @@ -328,6 +330,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstanceHaImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down Expand Up @@ -502,6 +506,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstanceHaImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down
2 changes: 2 additions & 0 deletions config/default/manager_default_images.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ spec:
value: quay.io/podified-antelope-centos9/openstack-memcached:current-podified
- name: RELATED_IMAGE_INFRA_REDIS_IMAGE_URL_DEFAULT
value: quay.io/podified-antelope-centos9/openstack-redis:current-podified
- name: RELATED_IMAGE_INFRA_INSTANCE_HA_IMAGE_URL_DEFAULT
value: quay.io/podified-antelope-centos9/openstack-openstackclient:current-podified
- name: RELATED_IMAGE_IRONIC_API_IMAGE_URL_DEFAULT
value: quay.io/podified-antelope-centos9/openstack-ironic-api:current-podified
- name: RELATED_IMAGE_IRONIC_CONDUCTOR_IMAGE_URL_DEFAULT
Expand Down
7 changes: 7 additions & 0 deletions controllers/core/openstackcontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ func (r *OpenStackControlPlaneReconciler) reconcileNormal(ctx context.Context, i
return ctrlResult, nil
}

ctrlResult, err = openstack.ReconcileInstanceHa(ctx, instance, version, helper)
if err != nil {
return ctrl.Result{}, err
} else if (ctrlResult != ctrl.Result{}) {
return ctrlResult, nil
}

return ctrl.Result{}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/openstack-k8s-operators/glance-operator/api v0.4.1-0.20240909180656-33fe3c05a637
github.com/openstack-k8s-operators/heat-operator/api v0.4.1-0.20240909065043-d5b093777de2
github.com/openstack-k8s-operators/horizon-operator/api v0.4.1-0.20240906120219-9c3e4ba4077b
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240910085802-31f905cfe219
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240912140341-4066f2ead41d
github.com/openstack-k8s-operators/ironic-operator/api v0.4.1-0.20240909085220-4736023a2e4f
github.com/openstack-k8s-operators/keystone-operator/api v0.4.1-0.20240906103150-990fe66f2e5d
github.com/openstack-k8s-operators/lib-common/modules/ansible v0.4.1-0.20240905123813-174296c09ec6
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ github.com/openstack-k8s-operators/heat-operator/api v0.4.1-0.20240909065043-d5b
github.com/openstack-k8s-operators/heat-operator/api v0.4.1-0.20240909065043-d5b093777de2/go.mod h1:w+8OpHuUfk4nEUSQfFZbYGPZEkn0c1xe3fyZ062fkDA=
github.com/openstack-k8s-operators/horizon-operator/api v0.4.1-0.20240906120219-9c3e4ba4077b h1:B4kw/FovC+mKMRA8dahi2k3x751iOuBwglu9DBz0iX4=
github.com/openstack-k8s-operators/horizon-operator/api v0.4.1-0.20240906120219-9c3e4ba4077b/go.mod h1:Q9/AUCUCA959gIq3DxzUdTWvkwqDp0lz3ujW0vTPdWg=
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240910085802-31f905cfe219 h1:o0epGu5XkImn5pggs/eyZMBS2Iok8wSaaTXRBwybDCk=
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240910085802-31f905cfe219/go.mod h1:TFh01OyR/NP5Sy7vikMIpQc80AKl0WWPyYDaJBfFiGc=
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240912140341-4066f2ead41d h1:GbkbsL89plNNnyQI06VzDyJ1xe8DhDky3wAPL5g6LBs=
github.com/openstack-k8s-operators/infra-operator/apis v0.4.1-0.20240912140341-4066f2ead41d/go.mod h1:TFh01OyR/NP5Sy7vikMIpQc80AKl0WWPyYDaJBfFiGc=
github.com/openstack-k8s-operators/ironic-operator/api v0.4.1-0.20240909085220-4736023a2e4f h1:Dj1KlPwlXzLyLaEDReJg3sHyo/TMN62pKH3X0L5bsZQ=
github.com/openstack-k8s-operators/ironic-operator/api v0.4.1-0.20240909085220-4736023a2e4f/go.mod h1:iQq0r9XaY6+AN9LaJIvhoetuOwnaGIhU0XkQvHLFT9M=
github.com/openstack-k8s-operators/keystone-operator/api v0.4.1-0.20240906103150-990fe66f2e5d h1:PbTZo4RCo+RFiGZ0q/rllUXoUtxgtWAh4V0IUe3aW5k=
Expand Down
1 change: 1 addition & 0 deletions hack/export_related_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export RELATED_IMAGE_KEYSTONE_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-ce
export RELATED_IMAGE_MARIADB_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-mariadb:current-podified
export RELATED_IMAGE_INFRA_MEMCACHED_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-memcached:current-podified
export RELATED_IMAGE_INFRA_REDIS_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-redis:current-podified
export RELATED_IMAGE_INFRA_INSTANCE_HA_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-openstackclient:current-podified
export RELATED_IMAGE_ANSIBLEEE_IMAGE_URL_DEFAULT=quay.io/openstack-k8s-operators/openstack-ansibleee-runner:current-podified
export RELATED_IMAGE_NOVA_API_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-nova-api:current-podified
export RELATED_IMAGE_NOVA_CONDUCTOR_IMAGE_URL_DEFAULT=quay.io/podified-antelope-centos9/openstack-nova-conductor:current-podified
Expand Down
54 changes: 54 additions & 0 deletions pkg/openstack/instanceha.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package openstack

import (
"context"

"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
"github.com/openstack-k8s-operators/lib-common/modules/common/configmap"
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"

corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
ctrl "sigs.k8s.io/controller-runtime"
)

const (
InstanceHaConfigMap = "infra-instanceha-config"
InstanceHaImageKey = "instanceha-image"
)

func ReconcileInstanceHa(ctx context.Context, instance *corev1beta1.OpenStackControlPlane, version *corev1beta1.OpenStackVersion, helper *helper.Helper) (ctrl.Result, error) {
missingImageDefault := ""
customData := map[string]string{
InstanceHaImageKey: *getImg(version.Status.ContainerImages.InfraInstanceHaImage, &missingImageDefault),
}

cms := []util.Template{
{
Name: InstanceHaConfigMap,
Namespace: instance.Namespace,
InstanceType: instance.Kind,
Labels: nil,
ConfigOptions: nil,
CustomData: customData,
},
}

if err := configmap.EnsureConfigMaps(ctx, helper, instance, cms, nil); err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
corev1beta1.OpenStackControlPlaneInstanceHaCMReadyCondition,
condition.ErrorReason,
condition.SeverityWarning,
corev1beta1.OpenStackControlPlaneInstanceHaCMReadyErrorMessage,
err.Error()))

return ctrl.Result{}, err
}

instance.Status.Conditions.Set(condition.TrueCondition(
corev1beta1.OpenStackControlPlaneInstanceHaCMReadyCondition,
corev1beta1.OpenStackControlPlaneInstanceHaCMReadyMessage,
))

return ctrl.Result{}, nil
}
1 change: 1 addition & 0 deletions pkg/openstack/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func GetContainerImages(defaults *corev1beta1.ContainerDefaults, instance corev1
InfraDnsmasqImage: getImg(instance.Spec.CustomContainerImages.InfraDnsmasqImage, defaults.InfraDnsmasqImage),
InfraMemcachedImage: getImg(instance.Spec.CustomContainerImages.InfraMemcachedImage, defaults.InfraMemcachedImage),
InfraRedisImage: getImg(instance.Spec.CustomContainerImages.InfraRedisImage, defaults.InfraRedisImage),
InfraInstanceHaImage: getImg(instance.Spec.CustomContainerImages.InfraInstanceHaImage, defaults.InfraInstanceHaImage),
IronicAPIImage: getImg(instance.Spec.CustomContainerImages.IronicAPIImage, defaults.IronicAPIImage),
IronicConductorImage: getImg(instance.Spec.CustomContainerImages.IronicConductorImage, defaults.IronicConductorImage),
IronicInspectorImage: getImg(instance.Spec.CustomContainerImages.IronicInspectorImage, defaults.IronicInspectorImage),
Expand Down
4 changes: 4 additions & 0 deletions tests/kuttl/common/assert-sample-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ status:
reason: Ready
status: "True"
type: OpenStackControlPlaneExposeKeystoneAPIReady
- message: OpenStackControlPlane InstanceHa CM is available
reason: Ready
status: "True"
type: OpenStackControlPlaneInstanceHaCMReadyCondition
- message: OpenStackControlPlane neutron service exposed
reason: Ready
status: "True"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ status:
reason: Ready
status: "True"
type: OpenStackControlPlaneKeystoneAPIReady
- message: OpenStackControlPlane InstanceHa CM is available
reason: Ready
status: "True"
type: OpenStackControlPlaneInstanceHaCMReadyCondition
- message: OpenStackControlPlane MariaDB completed
reason: Ready
status: "True"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@ status:
reason: Ready
status: "True"
type: OpenStackControlPlaneKeystoneAPIReady
- message: OpenStackControlPlane InstanceHa CM is available
reason: Ready
status: "True"
type: OpenStackControlPlaneInstanceHaCMReadyCondition
- message: OpenStackControlPlane MariaDB completed
reason: Ready
status: "True"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ status:
reason: Ready
status: "True"
type: OpenStackControlPlaneExposeKeystoneAPIReady
- message: OpenStackControlPlane InstanceHa CM is available
reason: Ready
status: "True"
type: OpenStackControlPlaneInstanceHaCMReadyCondition
- message: OpenStackControlPlane neutron service exposed
reason: Ready
status: "True"
Expand Down
4 changes: 4 additions & 0 deletions tests/kuttl/tests/ctlplane-galera-basic/01-assert-galera.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ status:
reason: Ready
status: "True"
type: OpenStackControlPlaneKeystoneAPIReady
- message: OpenStackControlPlane InstanceHa CM is available
reason: Ready
status: "True"
type: OpenStackControlPlaneInstanceHaCMReadyCondition
- message: OpenStackControlPlane MariaDB completed
reason: Ready
status: "True"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ status:
reason: Ready
status: "True"
type: OpenStackControlPlaneExposeKeystoneAPIReady
- message: OpenStackControlPlane InstanceHa CM is available
reason: Ready
status: "True"
type: OpenStackControlPlaneInstanceHaCMReadyCondition
- message: OpenStackControlPlane neutron service exposed
reason: Ready
status: "True"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ status:
reason: Ready
status: "True"
type: OpenStackControlPlaneKeystoneAPIReady
- message: OpenStackControlPlane InstanceHa CM is available
reason: Ready
status: "True"
type: OpenStackControlPlaneInstanceHaCMReadyCondition
- message: OpenStackControlPlane MariaDB completed
reason: Ready
status: "True"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ status:
reason: Ready
status: "True"
type: OpenStackControlPlaneKeystoneAPIReady
- message: OpenStackControlPlane InstanceHa CM is available
reason: Ready
status: "True"
type: OpenStackControlPlaneInstanceHaCMReadyCondition
- message: OpenStackControlPlane MariaDB completed
reason: Ready
status: "True"
Expand Down

0 comments on commit 0c50cc3

Please sign in to comment.