Skip to content

Commit

Permalink
Fix lint errors and kuttl tests
Browse files Browse the repository at this point in the history
  • Loading branch information
beagles committed Nov 26, 2024
1 parent 65c4f54 commit c373c65
Show file tree
Hide file tree
Showing 18 changed files with 71 additions and 79 deletions.
4 changes: 2 additions & 2 deletions config/samples/designate_redis_tls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ metadata:
spec:
replicas: 1
tls:
secretName: redis-tls
caBundleSecretName: redis-tls
secretName: cert-designate-redis-svc
caBundleSecretName: combined-ca-bundle
6 changes: 3 additions & 3 deletions controllers/designatecentral_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,11 @@ func (r *DesignateCentralReconciler) generateServiceConfigMaps(
),
}
if len(instance.Spec.RedisHostIPs) > 0 {
backendUrl := fmt.Sprintf("redis://%s:6379/", instance.Spec.RedisHostIPs[0])
backendURL := fmt.Sprintf("redis://%s:6379/", instance.Spec.RedisHostIPs[0])
if tlsCfg != nil {
backendUrl = fmt.Sprintf("%s?ssl=true", backendUrl)
backendURL = fmt.Sprintf("%s?ssl=true", backendURL)
}
templateParameters["CoordinationBackendUrl"] = backendUrl
templateParameters["CoordinationBackendURL"] = backendURL
}

transportURLSecret, _, err := secret.GetSecret(ctx, h, instance.Spec.TransportURLSecret, instance.Namespace)
Expand Down
6 changes: 3 additions & 3 deletions controllers/designateproducer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,11 @@ func (r *DesignateProducerReconciler) generateServiceConfigMaps(
}

if len(instance.Spec.RedisHostIPs) > 0 {
backendUrl := fmt.Sprintf("redis://%s:6379/", instance.Spec.RedisHostIPs[0])
backendURL := fmt.Sprintf("redis://%s:6379/", instance.Spec.RedisHostIPs[0])
if tlsCfg != nil {
backendUrl = fmt.Sprintf("%s?ssl=true", backendUrl)
backendURL = fmt.Sprintf("%s?ssl=true", backendURL)
}
templateParameters["CoordinationBackendUrl"] = backendUrl
templateParameters["CoordinationBackendURL"] = backendURL
}

transportURLSecret, _, err := secret.GetSecret(ctx, h, instance.Spec.TransportURLSecret, instance.Namespace)
Expand Down
1 change: 0 additions & 1 deletion templates/designate/bin/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,3 @@ cp -a ${SVC_CFG} ${SVC_CFG_MERGED}
for dir in /var/lib/config-data/default; do
merge_config_dir ${dir}
done

4 changes: 2 additions & 2 deletions templates/designatecentral/config/designate.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ connection={{ .DatabaseConnection }}
{{/* Some services don't need this section, so either we create independent files
or do not error on this missing for the ones that need it.
TODO: look into creating separate conf templates. */}}
{{ if .CoordinationBackendUrl }}
{{ if .CoordinationBackendURL }}
[coordination]
backend_url={{ .CoordinationBackendUrl }}
backend_url={{ .CoordinationBackendURL }}
{{ end }}

[service:api]
Expand Down
1 change: 0 additions & 1 deletion templates/designateproducer/bin/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ cp -a ${SVC_CFG} ${SVC_CFG_MERGED}
for dir in /var/lib/config-data/default; do
merge_config_dir ${dir}
done

4 changes: 2 additions & 2 deletions templates/designateproducer/config/designate.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ connection={{ .DatabaseConnection }}
{{/* Some services don't need this section, so either we create independent files
or do not error on this missing for the ones that need it.
TODO: look into creating separate conf templates. */}}
{{ if .CoordinationBackendUrl }}
{{ if .CoordinationBackendURL }}
[coordination]
backend_url={{ .CoordinationBackendUrl }}
backend_url={{ .CoordinationBackendURL }}
{{ end }}

[service:api]
Expand Down
10 changes: 10 additions & 0 deletions tests/kuttl/tests/basic/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
commands:
- script: |
if ! oc get -n $NAMESPACE secret -o json designate-central-config-data | jq '.data["designate.conf"] | @base64d' | sed -e 's/\\n/\n/g' | grep ^backend_url.*redis.*/$;
then
echo "Configuration of backend_url failed"
exit 1
fi
exit 0
9 changes: 9 additions & 0 deletions tests/kuttl/tests/basic/03-cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
delete:
- apiVersion: designate.openstack.org/v1beta1
kind: Designate
name: designate
- apiVersion: redis.openstack.org/v1beta1
kind: Redis
name: designate-redis
16 changes: 3 additions & 13 deletions tests/kuttl/tests/designate_tls/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
apiVersion: v1
kind: Secret
apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
name: cert-designate-internal-svc
---
apiVersion: v1
kind: Secret
metadata:
name: cert-designate-public-svc
---
apiVersion: v1
kind: Secret
metadata:
name: combined-ca-bundle
name: designate
4 changes: 4 additions & 0 deletions tests/kuttl/tests/designate_tls/02-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Secret
metadata:
name: kuttl-redis-tls
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
# hardcode the secret generated by the certificate CR below,
# to avoid kuttl from depending on cert-manager at runtime
# the ca.crt key has been renamed to tls-ca-bundle.pem
# ---
# apiVersion: cert-manager.io/v1
# kind: Certificate
# metadata:
# name: kuttl-redis-cert
# spec:
# secretName: kuttl-redis-tls
# duration: 12720h
# renewBefore: 1h
# subject:
# organizations:
# - cluster.local
# commonName: openstack-redis
# isCA: false
# privateKey:
# algorithm: RSA
# encoding: PKCS8
# size: 2048
# usages:
# - server auth
# - client auth
# dnsNames:
# - "redis.openstack.svc"
# - "redis.openstack.svc.cluster.local"
# - "*.redis-redis"
# - "*.redis-redis.openstack"
# - "*.redis-redis.openstack.svc"
# - "*.redis-redis.openstack.svc.cluster"
# - "*.redis-redis.openstack.svc.cluster.local"
# issuerRef:
# name: kuttl-ca-issuer
# group: cert-manager.io
# kind: Issuer
# ---
apiVersion: v1
kind: Secret
metadata:
Expand Down
14 changes: 14 additions & 0 deletions tests/kuttl/tests/designate_tls/04-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Secret
metadata:
name: cert-designate-internal-svc
---
apiVersion: v1
kind: Secret
metadata:
name: cert-designate-public-svc
---
apiVersion: v1
kind: Secret
metadata:
name: combined-ca-bundle
Original file line number Diff line number Diff line change
Expand Up @@ -157,21 +157,6 @@ spec:
- /usr/local/bin/container-scripts/init.sh
command:
- /bin/bash
env:
- name: AdminPassword
valueFrom:
secretKeyRef:
key: DesignatePassword
name: osp-secret
- name: TransportURL
valueFrom:
secretKeyRef:
key: transport_url
name: rabbitmq-transport-url-designate-designate-transport
- name: DatabaseHost
value: openstack.designate-kuttl-tests.svc
- name: DatabaseName
value: designate
imagePullPolicy: IfNotPresent
name: init
resources: {}
Expand Down Expand Up @@ -249,3 +234,13 @@ spec:
selector:
service: designate
type: ClusterIP
---
apiVersion: kuttl.dev/v1beta1
kind: TestAssert
commands:
- script: |
if ! oc get -n $NAMESPACE secret -o json designate-central-config-data | jq '.data["designate.conf"] | @base64d' | sed -e 's/\\n/\n/g' | grep ^backend_url.*redis.*ssl.true;
then
echo "Configuration of backend_url failed"
exit 1
fi
9 changes: 9 additions & 0 deletions tests/kuttl/tests/designate_tls/06-cleanup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
delete:
- apiVersion: designate.openstack.org/v1beta1
kind: Designate
name: designate
- apiVersion: redis.openstack.org/v1beta1
kind: Redis
name: designate-redis

0 comments on commit c373c65

Please sign in to comment.