Skip to content

Commit e2678c1

Browse files
Merge pull request #1922 from Deydra71/ac-edpm-annotation
Set EDPM service annotation on nova and ceilometer ACs
2 parents 79cd52d + aa52627 commit e2678c1

16 files changed

Lines changed: 56 additions & 7 deletions

File tree

internal/openstack/applicationcredential.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,15 @@ func CleanupApplicationCredentialForService(
6868
instance *corev1beta1.OpenStackControlPlane,
6969
serviceName string,
7070
) error {
71+
Log := GetLogger(ctx)
7172
acName := keystonev1.GetACCRName(serviceName)
73+
7274
acCR := &keystonev1.KeystoneApplicationCredential{
7375
ObjectMeta: metav1.ObjectMeta{
7476
Name: acName,
7577
Namespace: instance.Namespace,
7678
},
7779
}
78-
Log := GetLogger(ctx)
7980
err := helper.GetClient().Delete(ctx, acCR)
8081
if k8s_errors.IsNotFound(err) {
8182
return nil
@@ -106,6 +107,7 @@ func EnsureApplicationCredentialForService(
106107
passwordSelector string,
107108
serviceUser string,
108109
acConfig *corev1beta1.ServiceAppCredSection,
110+
edpmService bool,
109111
) (acSecretName string, result ctrl.Result, err error) {
110112
Log := GetLogger(ctx)
111113

@@ -154,7 +156,7 @@ func EnsureApplicationCredentialForService(
154156
// Check if AC CR exists and is ready
155157
if acExists {
156158
// We want to run reconcileApplicationCredential to update the AC CR if it exists and is ready and AC config fields changed
157-
err = reconcileApplicationCredential(ctx, helper, instance, acName, serviceUser, secretName, passwordSelector, merged)
159+
err = reconcileApplicationCredential(ctx, helper, instance, acName, serviceUser, secretName, passwordSelector, merged, edpmService)
158160
if err != nil {
159161
return "", ctrl.Result{}, err
160162
}
@@ -177,7 +179,7 @@ func EnsureApplicationCredentialForService(
177179
// Service is ready, create Application Credential CR
178180
Log.Info("Service is ready, creating Application Credential", "service", serviceName, "acName", acName)
179181

180-
err = reconcileApplicationCredential(ctx, helper, instance, acName, serviceUser, secretName, passwordSelector, merged)
182+
err = reconcileApplicationCredential(ctx, helper, instance, acName, serviceUser, secretName, passwordSelector, merged, edpmService)
181183
if err != nil {
182184
return "", ctrl.Result{}, err
183185
}
@@ -196,6 +198,7 @@ func reconcileApplicationCredential(
196198
secretName string,
197199
passwordSelector string,
198200
effective corev1beta1.ApplicationCredentialSection,
201+
edpmService bool,
199202
) error {
200203
log := GetLogger(ctx)
201204

@@ -215,6 +218,17 @@ func reconcileApplicationCredential(
215218
acObj.Spec.Roles = effective.Roles
216219
acObj.Spec.Unrestricted = *effective.Unrestricted
217220

221+
annotations := acObj.GetAnnotations()
222+
if annotations == nil {
223+
annotations = map[string]string{}
224+
}
225+
if edpmService {
226+
annotations[keystonev1.EDPMServiceAnnotation] = "true"
227+
} else {
228+
annotations[keystonev1.EDPMServiceAnnotation] = "false"
229+
}
230+
acObj.SetAnnotations(annotations)
231+
218232
if len(effective.AccessRules) > 0 {
219233
kr := make([]keystonev1.ACRule, 0, len(effective.AccessRules))
220234
for _, r := range effective.AccessRules {

internal/openstack/barbican.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func ReconcileBarbican(ctx context.Context, instance *corev1beta1.OpenStackContr
9191
instance.Spec.Barbican.Template.PasswordSelectors.Service,
9292
instance.Spec.Barbican.Template.ServiceUser,
9393
instance.Spec.Barbican.ApplicationCredential,
94+
false,
9495
)
9596
if err != nil {
9697
return ctrl.Result{}, err

internal/openstack/cinder.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func ReconcileCinder(ctx context.Context, instance *corev1beta1.OpenStackControl
115115
instance.Spec.Cinder.Template.PasswordSelectors.Service,
116116
instance.Spec.Cinder.Template.ServiceUser,
117117
instance.Spec.Cinder.ApplicationCredential,
118+
false,
118119
)
119120
if err != nil {
120121
return ctrl.Result{}, err

internal/openstack/designate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ func ReconcileDesignate(ctx context.Context, instance *corev1beta1.OpenStackCont
103103
instance.Spec.Designate.Template.PasswordSelectors.Service,
104104
instance.Spec.Designate.Template.ServiceUser,
105105
instance.Spec.Designate.ApplicationCredential,
106+
false,
106107
)
107108
if err != nil {
108109
return ctrl.Result{}, err

internal/openstack/glance.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ func ReconcileGlance(ctx context.Context, instance *corev1beta1.OpenStackControl
145145
instance.Spec.Glance.Template.PasswordSelectors.Service,
146146
instance.Spec.Glance.Template.ServiceUser,
147147
instance.Spec.Glance.ApplicationCredential,
148+
false,
148149
)
149150
if err != nil {
150151
return ctrl.Result{}, err

internal/openstack/heat.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ func ReconcileHeat(ctx context.Context, instance *corev1beta1.OpenStackControlPl
134134
instance.Spec.Heat.Template.PasswordSelectors.Service,
135135
instance.Spec.Heat.Template.ServiceUser,
136136
instance.Spec.Heat.ApplicationCredential,
137+
false,
137138
)
138139
if err != nil {
139140
return ctrl.Result{}, err

internal/openstack/ironic.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ func ReconcileIronic(ctx context.Context, instance *corev1beta1.OpenStackControl
147147
instance.Spec.Ironic.Template.PasswordSelectors.Service,
148148
instance.Spec.Ironic.Template.ServiceUser,
149149
instance.Spec.Ironic.ApplicationCredential,
150+
false,
150151
)
151152
if err != nil {
152153
return ctrl.Result{}, err
@@ -173,6 +174,7 @@ func ReconcileIronic(ctx context.Context, instance *corev1beta1.OpenStackControl
173174
instance.Spec.Ironic.Template.IronicInspector.PasswordSelectors.Service,
174175
instance.Spec.Ironic.Template.IronicInspector.ServiceUser,
175176
instance.Spec.Ironic.ApplicationCredential,
177+
false,
176178
)
177179
if err != nil {
178180
return ctrl.Result{}, err

internal/openstack/manila.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func ReconcileManila(ctx context.Context, instance *corev1beta1.OpenStackControl
9393
instance.Spec.Manila.Template.PasswordSelectors.Service,
9494
instance.Spec.Manila.Template.ServiceUser,
9595
instance.Spec.Manila.ApplicationCredential,
96+
false,
9697
)
9798
if err != nil {
9899
return ctrl.Result{}, err

internal/openstack/neutron.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro
137137
instance.Spec.Neutron.Template.PasswordSelectors.Service,
138138
instance.Spec.Neutron.Template.ServiceUser,
139139
instance.Spec.Neutron.ApplicationCredential,
140+
false,
140141
)
141142
if err != nil {
142143
return ctrl.Result{}, err

internal/openstack/nova.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ func ReconcileNova(ctx context.Context, instance *corev1beta1.OpenStackControlPl
209209
instance.Spec.Nova.Template.PasswordSelectors.Service,
210210
instance.Spec.Nova.Template.ServiceUser,
211211
instance.Spec.Nova.ApplicationCredential,
212+
true,
212213
)
213214
if err != nil {
214215
return ctrl.Result{}, err

0 commit comments

Comments
 (0)