Skip to content

Commit

Permalink
Run image_cache script kuttl test
Browse files Browse the repository at this point in the history
This patch enables in CI the image_cache script that is supposed to
verify the image Cache feature with multiple replicas.

Signed-off-by: Francesco Pantano <[email protected]>
  • Loading branch information
fmount committed Oct 17, 2024
1 parent c3a7309 commit 38e2c3c
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 420 deletions.
3 changes: 2 additions & 1 deletion config/samples/image_cache/cache_and_delete_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#
# export PASSWORD=12345678

# set -ex

TIME=3
CACHE_TIME=6
DOMAIN=${DOMAIN:-"glance-default-single.openstack.svc"}
Expand All @@ -29,7 +31,6 @@ IMAGE_NAME="myimage"
KEYSTONE=$(awk '/auth_url/ {print $2}' "/etc/openstack/clouds.yaml")
ADMIN_PWD=${1:-12345678}
ADMIN_USER=${ADMIN_USER:-"admin"}
DEBUG=0

# this method uses distributed image import and relies on the glance cli
glance="glance --os-auth-url ${KEYSTONE} \
Expand Down
2 changes: 2 additions & 0 deletions config/samples/layout/split/glance_v1beta1_glance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ spec:
glanceAPIs:
default:
replicas: 1
imageCache:
size: 2G
storage:
storageClass: local-storage
storageRequest: 10G
161 changes: 93 additions & 68 deletions test/kuttl/tests/glance_image_cache/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#
# Check for:
# - Glance CR
# - GlanceAPI glance-single CR
# - GlanceAPI glance-api StatefulSet
# - glance-api Pod
# - glance-cleaner CronJob
# - glance-pruner CronJob
# - glance imageCache PVC
# - GlanceAPI glance-external CR
# - GlanceAPI glance-internal CR
# - GlanceAPI glance-external-api StatefulSet
# - GlanceAPI glance-internal-api StatefulSet
# - glance-external-api Pod
# - glance-internal-api Pod
# - glance-internal service
# - glance-public service
# - glance internal and public endpoints

apiVersion: glance.openstack.org/v1beta1
kind: Glance
Expand All @@ -18,23 +21,36 @@ spec:
databaseAccount: glance
glanceAPIs:
default:
replicas: 1
type: "single"
imageCache:
cleanerScheduler: '*/30 * * * *'
prunerScheduler: 1 0 * * *
size: 2G
replicas: 2
secret: osp-secret
storage:
storageRequest: 10G
---
apiVersion: glance.openstack.org/v1beta1
kind: GlanceAPI
metadata:
name: glance-default-single
name: glance-default-external
spec:
apiType: single
replicas: 1
apiType: external
databaseAccount: glance
passwordSelectors:
service: GlancePassword
replicas: 2
imageCache:
cleanerScheduler: '*/30 * * * *'
prunerScheduler: 1 0 * * *
size: 2G
---
apiVersion: glance.openstack.org/v1beta1
kind: GlanceAPI
metadata:
name: glance-default-internal
spec:
apiType: internal
databaseAccount: glance
passwordSelectors:
service: GlancePassword
replicas: 2
imageCache:
cleanerScheduler: '*/30 * * * *'
prunerScheduler: 1 0 * * *
Expand All @@ -48,38 +64,69 @@ metadata:
status:
phase: Running
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
image-cache: "true"
labels:
component: glance-api
glanceAPI: glance-default-external
owner: glance-default-external
service: glance
name: glance-cache-glance-default-external-api-0
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2G

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
image-cache: "true"
labels:
component: glance-api
glanceAPI: glance-default-internal
owner: glance-default-internal
service: glance
name: glance-cache-glance-default-internal-api-0
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2G
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: glance-cache-glance-default-single-0-cleaner
name: glance-cache-glance-default-external-api-0-cleaner
spec:
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
jobTemplate:
metadata:
labels:
component: glance-api
glanceAPI: glance-default-single
owner: glance-default-single
glanceAPI: glance-default-external
owner: glance-default-external
service: glance
spec:
completions: 1
parallelism: 1
template:
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: glanceAPI
operator: In
values:
- glance-default-single
topologyKey: kubernetes.io/hostname
containers:
- args:
- -c
- /usr/bin/glance-cache-cleaner --config-dir /etc/glance/glance.conf.d
command:
- /bin/bash
name: glance-cache-glance-default-single-0-cleaner
name: glance-cache-glance-default-external-api-0-cleaner
volumeMounts:
- mountPath: /etc/glance/glance.conf.d
name: image-cache-config-data
Expand All @@ -89,47 +136,42 @@ spec:
volumes:
- name: image-cache-config-data
secret:
defaultMode: 420
items:
- key: 00-config.conf
path: 00-config.conf
secretName: glance-default-single-config-data
secretName: glance-default-external-config-data
- name: glance-cache
persistentVolumeClaim:
claimName: glance-cache-glance-default-single-0
claimName: glance-cache-glance-default-external-api-0
schedule: '*/30 * * * *'
successfulJobsHistoryLimit: 3
suspend: false
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: glance-cache-glance-default-single-0-pruner
name: glance-cache-glance-default-external-api-0-pruner
spec:
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
jobTemplate:
metadata:
labels:
component: glance-api
glanceAPI: glance-default-single
owner: glance-default-single
glanceAPI: glance-default-external
owner: glance-default-external
service: glance
spec:
template:
spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: glanceAPI
operator: In
values:
- glance-default-single
topologyKey: kubernetes.io/hostname
containers:
- args:
- -c
- /usr/bin/glance-cache-pruner --config-dir /etc/glance/glance.conf.d
command:
- /bin/bash
name: glance-cache-glance-default-single-0-pruner
name: glance-cache-glance-default-external-api-0-pruner
volumeMounts:
- mountPath: /etc/glance/glance.conf.d
name: image-cache-config-data
Expand All @@ -139,31 +181,14 @@ spec:
volumes:
- name: image-cache-config-data
secret:
defaultMode: 420
items:
- key: 00-config.conf
path: 00-config.conf
secretName: glance-default-single-config-data
secretName: glance-default-external-config-data
- name: glance-cache
persistentVolumeClaim:
claimName: glance-cache-glance-default-single-0
schedule: '1 0 * * *'
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
annotations:
image-cache: "true"
pv.kubernetes.io/bind-completed: "yes"
pv.kubernetes.io/bound-by-controller: "yes"
labels:
component: glance-api
glanceAPI: glance-default-single
owner: glance-default-single
service: glance
name: glance-cache-glance-default-single-0
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2G
claimName: glance-cache-glance-default-external-api-0
schedule: 1 0 * * *
successfulJobsHistoryLimit: 3
suspend: false
6 changes: 5 additions & 1 deletion test/kuttl/tests/glance_image_cache/01-deploy_glance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- script: |
oc kustomize ../../../../config/samples/layout/single | oc apply -n $NAMESPACE -f -
oc kustomize ../../../../config/samples/layout/split | oc apply -n $NAMESPACE -f -
- script: |
oc patch Glance -n $NAMESPACE glance --type='json' -p='[{"op": "replace", "path": "/spec/glanceAPIs/default/replicas", "value":2}]'
- script: |
oc -n $NAMESPACE kustomize --load-restrictor LoadRestrictionsNone ../../../../config/samples/openstackclient | oc -n $NAMESPACE apply -f -
Loading

0 comments on commit 38e2c3c

Please sign in to comment.