Skip to content

Commit 75540e2

Browse files
committed
Fix scripts volum issue
1 parent 18fc0ca commit 75540e2

File tree

5 files changed

+40
-18
lines changed

5 files changed

+40
-18
lines changed

controllers/placementapi_controller.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ func (r *PlacementAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request
431431

432432
apiEndpoints, result, err := r.ensureServiceExposed(ctx, h, instance)
433433

434-
if err != nil {
434+
if (err != nil || result != ctrl.Result{}) {
435+
// We can ignore RequeueAfter as we are watching the Service resource
436+
// but we have to return while waiting for the service to be exposed
435437
return ctrl.Result{}, err
436438
}
437439

@@ -441,10 +443,10 @@ func (r *PlacementAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request
441443
}
442444

443445
result, err = r.ensureKeystoneEndpoint(ctx, h, instance, apiEndpoints)
444-
if err != nil {
446+
if (err != nil || result != ctrl.Result{}) {
447+
// We can ignore RequeueAfter as we are watching the KeystoneEndpoint resource
445448
return ctrl.Result{}, err
446449
}
447-
448450
result, err = r.ensureDbSync(ctx, instance, h, serviceAnnotations)
449451
if (err != nil || result != ctrl.Result{}) {
450452
return result, err
@@ -482,6 +484,7 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
482484
}
483485
apiEndpoints := make(map[string]string)
484486

487+
serviceLabels := getServiceLabels(instance)
485488
for endpointType, data := range placementEndpoints {
486489
endpointTypeStr := string(endpointType)
487490
endpointName := placement.ServiceName + "-" + endpointTypeStr
@@ -492,7 +495,7 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
492495
}
493496

494497
exportLabels := util.MergeStringMaps(
495-
getServiceLabels(instance),
498+
serviceLabels,
496499
map[string]string{
497500
service.AnnotationEndpointKey: endpointTypeStr,
498501
},
@@ -504,7 +507,7 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
504507
Name: endpointName,
505508
Namespace: instance.Namespace,
506509
Labels: exportLabels,
507-
Selector: getServiceLabels(instance),
510+
Selector: serviceLabels,
508511
Port: service.GenericServicePort{
509512
Name: endpointName,
510513
Port: data.Port,
@@ -522,7 +525,7 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
522525
condition.ExposeServiceReadyErrorMessage,
523526
err.Error()))
524527

525-
return nil, ctrl.Result{}, err
528+
return apiEndpoints, ctrl.Result{}, err
526529
}
527530

528531
svc.AddAnnotation(map[string]string{
@@ -554,14 +557,14 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
554557
condition.ExposeServiceReadyErrorMessage,
555558
err.Error()))
556559

557-
return nil, ctrlResult, err
560+
return apiEndpoints, ctrlResult, err
558561
} else if (ctrlResult != ctrl.Result{}) {
559562
instance.Status.Conditions.Set(condition.FalseCondition(
560563
condition.ExposeServiceReadyCondition,
561564
condition.RequestedReason,
562565
condition.SeverityInfo,
563566
condition.ExposeServiceReadyRunningMessage))
564-
return nil, ctrlResult, nil
567+
return apiEndpoints, ctrlResult, nil
565568
}
566569
// create service - end
567570

@@ -574,7 +577,7 @@ func (r *PlacementAPIReconciler) ensureServiceExposed(
574577
apiEndpoints[string(endpointType)], err = svc.GetAPIEndpoint(
575578
svcOverride.EndpointURL, data.Protocol, data.Path)
576579
if err != nil {
577-
return nil, ctrl.Result{}, err
580+
return apiEndpoints, ctrl.Result{}, err
578581
}
579582
}
580583

pkg/placement/volumes.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,9 @@ func getVolumes(name string) []corev1.Volume {
2828
{
2929
Name: "scripts",
3030
VolumeSource: corev1.VolumeSource{
31-
ConfigMap: &corev1.ConfigMapVolumeSource{
31+
Secret: &corev1.SecretVolumeSource{
3232
DefaultMode: &scriptsVolumeDefaultMode,
33-
LocalObjectReference: corev1.LocalObjectReference{
34-
Name: name + "-scripts",
35-
},
33+
SecretName: name + "-scripts",
3634
},
3735
},
3836
},

tests/kuttl/common/assert_sample_deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ spec:
145145
- mountPath: /usr/local/bin/container-scripts
146146
name: scripts
147147
readOnly: true
148+
- mountPath: /var/log/placement
149+
name: logs
148150
- mountPath: /var/lib/config-data/
149151
name: config-data
150152
- mountPath: /var/lib/kolla/config_files/config.json
151153
name: config-data
152154
readOnly: true
153155
subPath: placement-api-config.json
154-
- mountPath: /var/log/placement
155-
name: logs
156156
- args:
157157
- -c
158158
- /usr/local/bin/kolla_start

tests/kuttl/common/errors_cleanup_placement.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ kind: Deployment
1818
metadata:
1919
name: placement
2020
---
21+
# the openshift annotations can't be checked through the deployment above
22+
apiVersion: v1
23+
kind: Pod
24+
metadata:
25+
annotations:
26+
openshift.io/scc: anyuid
27+
labels:
28+
service: placement
29+
---
2130
apiVersion: v1
2231
kind: Service
2332
metadata:
@@ -62,6 +71,18 @@ spec:
6271
---
6372
apiVersion: v1
6473
kind: Secret
74+
metadata:
75+
labels:
76+
placement.openstack.org/name: placement
77+
name: placement-scripts
78+
ownerReferences:
79+
- blockOwnerDeletion: true
80+
controller: true
81+
kind: PlacementAPI
82+
name: placement
83+
---
84+
apiVersion: v1
85+
kind: Secret
6586
metadata:
6687
labels:
6788
placement.openstack.org/name: placement

tests/kuttl/tests/placement_deploy_tls/03-assert.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ spec:
152152
- mountPath: /usr/local/bin/container-scripts
153153
name: scripts
154154
readOnly: true
155-
- mountPath: /var/lib/config-data
155+
- mountPath: /var/log/placement
156+
name: logs
157+
- mountPath: /var/lib/config-data/
156158
name: config-data
157159
- mountPath: /var/lib/kolla/config_files/config.json
158160
name: config-data
159161
readOnly: true
160162
subPath: placement-api-config.json
161-
- mountPath: /var/log/placement
162-
name: logs
163163
- mountPath: /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem
164164
name: combined-ca-bundle
165165
readOnly: true

0 commit comments

Comments
 (0)