Skip to content

Commit

Permalink
Merge pull request #640 from fmount/cache_kuttl
Browse files Browse the repository at this point in the history
Run image_cache script kuttl test
  • Loading branch information
openshift-merge-bot[bot] authored Oct 18, 2024
2 parents 32b669e + 75c0edd commit b38ee10
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 415 deletions.
4 changes: 4 additions & 0 deletions config/samples/distributed_image_import/dist-image-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ $glance --os-image-url "http://${REPLICA}""1.$DOMAIN:9292" image-import --import
$glance image-list
status=$($glance image-show "$ID" | awk '/status/{print $4}')
printf "Image Status: %s\n" "$status"

# Stage 5 - Clean up images
openstack image list -c ID -f value | xargs -n 1 openstack image delete

if [[ $status == "active" ]]; then
exit 0
fi
Expand Down
6 changes: 4 additions & 2 deletions 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 -x

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 All @@ -42,7 +43,7 @@ glance="glance --os-auth-url ${KEYSTONE} \
exec 0<&-

# Build a dodgy image
echo This is a dodgy image > "${IMAGE_NAME}"
echo This is a dodgy image > $HOME/"${IMAGE_NAME}"

# Stage 0 - Delete any pre-existing image
openstack image list -c ID -f value | xargs -n 1 openstack image delete
Expand All @@ -67,6 +68,7 @@ $glance --verbose image-create \
--container-format bare \
--name "${IMAGE_NAME}" \
--file myimage
sleep "$TIME"
ID=$($glance image-list | awk -v img=$IMAGE_NAME '$0 ~ img {print $2}')
echo "Image ID: $ID"
sleep "$TIME"
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
151 changes: 86 additions & 65 deletions test/kuttl/tests/glance_image_cache/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#
# Check for:
# - Glance CR
# - GlanceAPI glance-single CR
# - GlanceAPI glance-api StatefulSet
# - GlanceAPI glance-external CR
# - GlanceAPI glance-internal CR
# - glance-api Pod
# - glance-cleaner CronJob
# - glance-pruner CronJob
Expand All @@ -18,23 +17,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 +60,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 +132,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 +177,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 b38ee10

Please sign in to comment.