Skip to content

Commit

Permalink
add instance ha cm to set container image
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiccini committed Sep 11, 2024
1 parent cbcb33f commit 45b48a3
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 0 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
infraInstaceHAImage:
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
infraInstaceHAImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down Expand Up @@ -328,6 +330,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstaceHAImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down Expand Up @@ -502,6 +506,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstaceHAImage:
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"

// OpenStackControlPlaneInstaceHACMReadyMessage
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:"infraInstaceHAImage,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.

Original file line number Diff line number Diff line change
Expand Up @@ -17611,6 +17611,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstaceHAImage:
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
infraInstaceHAImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down Expand Up @@ -328,6 +330,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstaceHAImage:
type: string
infraMemcachedImage:
type: string
infraRedisImage:
Expand Down Expand Up @@ -502,6 +506,8 @@ spec:
type: string
infraDnsmasqImage:
type: string
infraInstaceHAImage:
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
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

0 comments on commit 45b48a3

Please sign in to comment.