forked from openstack-k8s-operators/openstack-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstanceha.go
More file actions
53 lines (43 loc) · 1.66 KB
/
Copy pathinstanceha.go
File metadata and controls
53 lines (43 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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) {
customData := map[string]string{
InstanceHaImageKey: *getImg(version.Status.ContainerImages.OpenstackClientImage, &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
}