Skip to content

Commit aab8f13

Browse files
authored
Merge pull request #17 from jduimovich/cleanup-tasks-fix
cleanup build directory fix
2 parents 5abb137 + 0808de7 commit aab8f13

File tree

5 files changed

+24
-13
lines changed

5 files changed

+24
-13
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ This repository contains components that are installed or managed by the managed
44

55
This includes default Pipelines and Tasks. You need to have bootstrapped a working appstudio configuration from (see `https://github.com/redhat-appstudio/infra-deployments`) for the dev of pipelines or new tasks.
66

7-
Pipelines are delivered into App Studio via `quay.io/redhat-appstudio/build-templates-bundle:v0.1.3` (the tag will be updated every change)
7+
Pipelines are delivered into App Studio via `quay.io/redhat-appstudio/build-templates-bundle:vX.Y.Z` (the tag will be updated every change)
88

99
Tasks are delivered into App Studio via `quay.io/redhat-appstudio/appstudio-tasks`. Where each task is bundled and pushed into tag in format `${TASK_NAME}-${VERSION}` where version is the same as pipelines bundle version.
1010

11-
Currently a set of utilties are bundled with App Studio in `quay.io/redhat-appstudio/appstudio-utils:v0.1.3` as a convenience but tasks may be run from different per-task containers in future.
11+
Currently a set of utilties are bundled with App Studio in `quay.io/redhat-appstudio/appstudio-utils:vX.Y.Z` as a convenience but tasks may be run from different per-task containers in future.
1212

1313
## Devmode
1414

@@ -30,7 +30,7 @@ Please test in _gitops mode_ when doing a new release into staging as it will be
3030
The tasks can be found in the `tasks` directories. Tasks are bundled and used by bundled pipelines. Tasks are not stored in the Cluster.
3131
For quick local innerloop style task development, you may install new Tasks in your local namespace manually and create your pipelines as well as the base task image to test new function. Tasks can be installed into local namespace using `oc apply -k tasks/appstudio-utils/util-tasks`.
3232

33-
There is a container which is used to support multiple set of tasks called `quay.io/redhat-appstudio/appstudio-utils:v0.1.3` , which is a single container which is used by multiple tasks. Tasks may also be in their own container as well however many simple tasks are utilities and will be packaged for app studio in a single container. Tasks can rely on other tasks in the system which are co-packed in a container allowing combined tasks (build-only vs build-deploy) which use the same core implementations.
33+
There is a container which is used to support multiple set of tasks called `quay.io/redhat-appstudio/appstudio-utils:vX.Y.Z` , which is a single container which is used by multiple tasks. Tasks may also be in their own container as well however many simple tasks are utilities and will be packaged for app studio in a single container. Tasks can rely on other tasks in the system which are co-packed in a container allowing combined tasks (build-only vs build-deploy) which use the same core implementations.
3434

3535
## Release
3636

tasks/appstudio-utils/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Source for quay.io/redhat-appstudioappstudio-utils:v0.1.3
1+
# Source for quay.io/redhat-appstudioappstudio-utils:vX.Y.Z
22

33
This component provides an image which contains a suite of app-studio specific utilies.
44

tasks/appstudio-utils/test-all-tasks.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
33

44
oc apply -k $SCRIPTDIR/test-all-tasks
5-
tkn pipeline start test-all-tasks -w name=workspace,claimName=app-studio-default-workspace -p test-image=quay.io/redhat-appstudio/appstudio-utils:v0.1.3 --showlog --use-param-defaults
5+
tkn pipeline start test-all-tasks -w name=workspace,claimName=app-studio-default-workspace -p test-image=quay.io/redhat-appstudio/appstudio-utils:test --showlog --use-param-defaults
66

77
# cleanup manually, this is so you can inspect the results
88
# if you delete immediately, the results are gone

tasks/appstudio-utils/test-all-tasks/kustomization.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ patches:
1111
patch: |-
1212
- op: replace
1313
path: /spec/steps/0/image
14-
value: quay.io/redhat-appstudio/appstudio-utils:v0.1.3
14+
value: quay.io/redhat-appstudio/appstudio-utils:test

tasks/appstudio-utils/util-scripts/cleanup-build-directories.sh

+18-7
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,24 @@
55
# rm unused marker in live pipeline-runs
66
# rm all directories with unused marker
77
# all other directories are live and have no marker (done)
8-
9-
MARKER=.appstudio-mark-unused
10-
8+
# if a directory is being gc'd by two copies of this task
9+
# the marker will be unique so they can both run.
10+
# live directories will be a noop
11+
# dead directories can be deleted by either copy
12+
# note, not recommended to run in parallel but will work.
13+
14+
# use a unique marker per tasks based on time to NS
15+
MARKER=.appstudio-mark-unused-$(date +"%Y%m%d%H%M%S%6N")
16+
# Keep track of the existing pvs, any pvs added during this run
17+
# will be ignored until a later run so that new pvs which were not
18+
# originally marked dont get deleted due to not being marked.
19+
CANDIDATES=./pv-*
20+
1121
cd workspace/source
1222
echo "Cleanup:"
13-
BEFORE=$(du -h . | tail -n 1)
23+
BEFORE=$(du -s)
1424
# mark all unused
15-
for build in ./pv-* ; do
25+
for build in $CANDIDATES ; do
1626
if [ -d "$build" ]; then
1727
echo "Directory: $build"
1828
echo "unused" > "$build/$MARKER"
@@ -30,8 +40,9 @@ kubectl get pipelineruns --no-headers -o custom-columns=":metadata.name" | \
3040
kubectl get pipelineruns --no-headers -o custom-columns=":metadata.name" | \
3141
xargs -n 1 -I {} rm -f pv-{}/$MARKER 2> /dev/null
3242

43+
3344
# if still marked unused, may be removed
34-
for build in ./pv-* ; do
45+
for build in $CANDIDATES ; do
3546
if [ -f "$build/$MARKER" ]; then
3647
echo "Removing: $(du -h $build | tail -n 1)"
3748
rm -rf $build
@@ -41,7 +52,7 @@ for build in ./pv-* ; do
4152
fi
4253
fi
4354
done
44-
AFTER=$(du -h . | tail -n 1)
55+
AFTER=$(du -s)
4556

4657
CMD=$(basename $0)
4758
if [ -d "$1" ]; then

0 commit comments

Comments
 (0)