Skip to content

Commit 709f113

Browse files
committed
add periodic artifactory cache cleanup
This commit: - Introduces a new periodic prow job to clean up the IPA proxy cache in nordix artifactory - introduces new script to do the cleanup - introduces new artifactory token secret - introduces new generic artifactory deletion script that utilizes only token authentication Signed-off-by: Adam Rozman <[email protected]>
1 parent 5295d8b commit 709f113

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

hack/clean_artifactory.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
# This script is expected to be executed with minimal POSIX shell e.g ash
3+
set -eu
4+
5+
RT_TOKEN_FILE="${RT_TOKEN_FILE:-/etc/artifactory}"
6+
IFS= read -r RT_TOKEN <"${RT_TOKEN_FILE}"
7+
CACHE_URL="${CACHE_URL:-https://artifactory.nordix.org/artifactory/openstack-remote-cache/ironic-python-agent/dib/ipa-centos9-master.tar.gz}"
8+
9+
curl -s -H "Authorization: Bearer ${RT_TOKEN}" -XDELETE "${CACHE_URL}"

prow/README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,9 @@ Files with credentials and other sensitive information are not stored in this
227227
repository. You will need to add them manually before you can apply any
228228
manifests and build the kustomizations. CAPO needs access to the OpenStack API
229229
and so does the external cloud-provider. Prow needs a GitHub token for accessing
230-
GitHub, a HMAC token for validating webhook requests, and S3 credentials for
231-
storing logs and similar.
230+
GitHub, a HMAC token for validating webhook requests, S3 credentials for
231+
storing logs and similar and Nordix Artifactory token for cleaning the proxy
232+
cache and in general accessing Artfactory.
232233

233234
If you are deploying from scratch or rotating credentials, please make sure to
234235
save them in a secure place after creating them. If there is an existing
@@ -246,6 +247,7 @@ Then you will be able to just copy and paste the snippets below.
246247
- `GITHUB_TOKEN`
247248
- `CHERRYPICK_TOKEN`
248249
- `JENKINS_TOKEN`
250+
- `ARTIFACTORY_TOKEN`
249251

250252
Now you are ready to create the files.
251253

@@ -337,6 +339,12 @@ Now you are ready to create the files.
337339
echo "${JENKINS_TOKEN}" > manifests/overlays/metal3/jenkins-token
338340
```
339341
342+
1. Save the Artifactory token as `manifests/overlays/metal3/artifactory-token`.
343+
344+
```bash
345+
echo "${ARTIFACTORY_TOKEN}" > manifests/overlays/metal3/artifactory-token
346+
```
347+
340348
## Access existing instance
341349
342350
For accessing an existing instance, you can simply get the relevant credentials

prow/config/jobs/periodics.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,26 @@ periodics:
8585
- name: github-token
8686
secret:
8787
secretName: github-token
88+
- name: clean-artifactory-cache
89+
# At 04:00 AM every day
90+
cron: 0 4 * * *
91+
decorate: true
92+
extra_refs:
93+
- org: metal3-io
94+
repo: project-infra
95+
base_ref: main
96+
spec:
97+
containers:
98+
- image: docker.io/alpine/curl:8.14.1@sha256:d9d451635fea7317186adda62cebe3f7e46810a3de6ddfcae662339e456b6c55
99+
command:
100+
- sh
101+
args:
102+
- ./hack/clean_artifactory_cache.sh
103+
volumeMounts:
104+
- name: artifactory-token
105+
mountPath: /etc/artifactory
106+
readOnly: true
107+
volumes:
108+
- name: artifactory-token
109+
secret:
110+
secretName: artifactory-token

prow/manifests/overlays/metal3/kustomization.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ secretGenerator:
5757
name: jenkins-token
5858
namespace: prow
5959
type: Opaque
60+
- files:
61+
- token=artifactory-token
62+
name: artifactory-token
63+
namespace: prow
64+
type: Opaque
6065

6166
patches:
6267
- path: patches/crier.yaml

0 commit comments

Comments
 (0)