File tree Expand file tree Collapse file tree 7 files changed +76
-11
lines changed
stepactions/skip-trusted-artifact-operations
tasks/managed/reduce-snapshot Expand file tree Collapse file tree 7 files changed +76
-11
lines changed Original file line number Diff line number Diff line change 27
27
if [ "${ociStorage:?}" == "empty" ]; then
28
28
echo "oci storage not detected via ociStorage...skipping trusted artifacts tasks"
29
29
mkdir -p "${workDir:?}"
30
- touch "${workDir:?}/.skip-trusted-artifacts"
30
+
31
+ # Check if the skip file already exists to avoid permission issues
32
+ if [ -f "${workDir:?}/.skip-trusted-artifacts" ]; then
33
+ echo "Skip file already exists, continuing..."
34
+ else
35
+ # Try to create the file, handle permission issues gracefully
36
+ if ! touch "${workDir:?}/.skip-trusted-artifacts" 2>/dev/null; then
37
+ # If we can't create the file due to permissions, try to fix permissions
38
+ if [ -d "${workDir:?}" ]; then
39
+ # Try to make the directory writable by the current user
40
+ chmod u+w "${workDir:?}" 2>/dev/null || true
41
+ # Try again to create the file
42
+ if ! touch "${workDir:?}/.skip-trusted-artifacts" 2>/dev/null; then
43
+ echo "ERROR: Cannot create .skip-trusted-artifacts file due to permissions"
44
+ echo " This may cause issues with trusted artifacts operations"
45
+ # Exit with error to surface the permission issue
46
+ exit 1
47
+ fi
48
+ else
49
+ echo "ERROR: Work directory ${workDir:?} does not exist"
50
+ exit 1
51
+ fi
52
+ fi
53
+ fi
31
54
fi
Original file line number Diff line number Diff line change 78
78
value : " $(params.orasOptions)"
79
79
- name : " DEBUG"
80
80
value : " $(params.trustedArtifactsDebug)"
81
+ # This is a workaround for a problem observed on a particular cluster where the
82
+ # use-trusted-artifacts step runs with root user causing a docker credential file
83
+ # to not be readable in later steps. There might be solution coming related to the
84
+ # security context constraints on the cluster, but setting this explicitly here
85
+ # should probably be harmless either way.
86
+ securityContext :
87
+ runAsUser : 1001
81
88
steps :
82
89
- name : skip-trusted-artifact-operations
83
90
computeResources :
Original file line number Diff line number Diff line change @@ -48,14 +48,18 @@ spec:
48
48
value : " $(params.orasOptions)"
49
49
- name : " DEBUG"
50
50
value : " $(params.trustedArtifactsDebug)"
51
+ # Use the same security context as the main task to avoid permission issues
52
+ securityContext :
53
+ runAsUser : 1001
51
54
steps :
52
55
- name : create-crs
53
56
image : quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f
54
57
script : |
55
58
#!/usr/bin/env bash
56
59
set -eux
57
60
58
- cat > snapshot << EOF
61
+ # Write to writable directory
62
+ cat > /var/workdir/snapshot << EOF
59
63
apiVersion: appstudio.redhat.com/v1alpha1
60
64
kind: Snapshot
61
65
metadata:
72
76
- name: tom
73
77
containerImage: newimage2
74
78
EOF
75
- kubectl apply -f snapshot
79
+ kubectl apply -f /var/workdir/ snapshot
76
80
77
81
mkdir -p "$(params.dataDir)/$(context.pipelineRun.uid)"
78
82
kubectl get snapshot/snapshot-sample -ojson | jq .spec | tee \
@@ -169,6 +173,9 @@ spec:
169
173
value : " $(params.orasOptions)"
170
174
- name : " DEBUG"
171
175
value : " $(params.trustedArtifactsDebug)"
176
+ # Use the same security context as the main task to avoid permission issues
177
+ securityContext :
178
+ runAsUser : 1001
172
179
steps :
173
180
- name : skip-trusted-artifact-operations
174
181
ref :
Original file line number Diff line number Diff line change @@ -49,14 +49,18 @@ spec:
49
49
value : " $(params.orasOptions)"
50
50
- name : " DEBUG"
51
51
value : " $(params.trustedArtifactsDebug)"
52
+ # Use the same security context as the main task to avoid permission issues
53
+ securityContext :
54
+ runAsUser : 1001
52
55
steps :
53
56
- name : create-crs
54
57
image : quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f
55
58
script : |
56
59
#!/usr/bin/env bash
57
60
set -eux
58
61
59
- cat > snapshot << EOF
62
+ # Write to writable directory
63
+ cat > /var/workdir/snapshot << EOF
60
64
apiVersion: appstudio.redhat.com/v1alpha1
61
65
kind: Snapshot
62
66
metadata:
73
77
- name: tom
74
78
containerImage: newimage2
75
79
EOF
76
- kubectl apply -f snapshot
80
+ kubectl apply -f /var/workdir/ snapshot
77
81
78
82
mkdir -p "$(params.dataDir)/$(context.pipelineRun.uid)"
79
83
kubectl get snapshot/snapshot-sample -ojson | jq .spec | tee \
@@ -170,6 +174,9 @@ spec:
170
174
value : " $(params.orasOptions)"
171
175
- name : " DEBUG"
172
176
value : " $(params.trustedArtifactsDebug)"
177
+ # Use the same security context as the main task to avoid permission issues
178
+ securityContext :
179
+ runAsUser : 1001
173
180
steps :
174
181
- name : skip-trusted-artifact-operations
175
182
ref :
Original file line number Diff line number Diff line change @@ -48,14 +48,18 @@ spec:
48
48
value : " $(params.orasOptions)"
49
49
- name : " DEBUG"
50
50
value : " $(params.trustedArtifactsDebug)"
51
+ # Use the same security context as the main task to avoid permission issues
52
+ securityContext :
53
+ runAsUser : 1001
51
54
steps :
52
55
- name : create-crs
53
56
image : quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f
54
57
script : |
55
58
#!/usr/bin/env bash
56
59
set -eux
57
60
58
- cat > snapshot << EOF
61
+ # Write to writable directory
62
+ cat > /var/workdir/snapshot << EOF
59
63
apiVersion: appstudio.redhat.com/v1alpha1
60
64
kind: Snapshot
61
65
metadata:
69
73
- name: tom
70
74
containerImage: newimage2
71
75
EOF
72
- kubectl apply -f snapshot
76
+ kubectl apply -f /var/workdir/ snapshot
73
77
74
78
mkdir -p "$(params.dataDir)/$(context.pipelineRun.uid)"
75
79
kubectl get snapshot/snapshot-sample -ojson | jq .spec | \
@@ -166,6 +170,9 @@ spec:
166
170
value : " $(params.orasOptions)"
167
171
- name : " DEBUG"
168
172
value : " $(params.trustedArtifactsDebug)"
173
+ # Use the same security context as the main task to avoid permission issues
174
+ securityContext :
175
+ runAsUser : 1001
169
176
steps :
170
177
- name : skip-trusted-artifact-operations
171
178
ref :
Original file line number Diff line number Diff line change @@ -48,14 +48,18 @@ spec:
48
48
value : " $(params.orasOptions)"
49
49
- name : " DEBUG"
50
50
value : " $(params.trustedArtifactsDebug)"
51
+ # Use the same security context as the main task to avoid permission issues
52
+ securityContext :
53
+ runAsUser : 1001
51
54
steps :
52
55
- name : create-crs
53
56
image : quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f
54
57
script : |
55
58
#!/usr/bin/env bash
56
59
set -eux
57
60
58
- cat > snapshot << EOF
61
+ # Write to writable directory
62
+ cat > /var/workdir/snapshot << EOF
59
63
apiVersion: appstudio.redhat.com/v1alpha1
60
64
kind: Snapshot
61
65
metadata:
72
76
- name: tom
73
77
containerImage: newimage2
74
78
EOF
75
- kubectl apply -f snapshot
79
+ kubectl apply -f /var/workdir/ snapshot
76
80
77
81
mkdir -p "$(params.dataDir)/$(context.pipelineRun.uid)"
78
82
kubectl get snapshot/snapshot-sample -ojson | jq .spec | tee \
@@ -167,6 +171,9 @@ spec:
167
171
value : " $(params.orasOptions)"
168
172
- name : " DEBUG"
169
173
value : " $(params.trustedArtifactsDebug)"
174
+ # Use the same security context as the main task to avoid permission issues
175
+ securityContext :
176
+ runAsUser : 1001
170
177
steps :
171
178
- name : skip-trusted-artifact-operations
172
179
ref :
Original file line number Diff line number Diff line change @@ -49,14 +49,18 @@ spec:
49
49
value : " $(params.orasOptions)"
50
50
- name : " DEBUG"
51
51
value : " $(params.trustedArtifactsDebug)"
52
+ # Use the same security context as the main task to avoid permission issues
53
+ securityContext :
54
+ runAsUser : 1001
52
55
steps :
53
56
- name : create-crs
54
57
image : quay.io/konflux-ci/release-service-utils:e633d51cd41d73e4b3310face21bb980af7a662f
55
58
script : |
56
59
#!/usr/bin/env bash
57
60
set -eux
58
61
59
- cat > snapshot << EOF
62
+ # Write to writable directory
63
+ cat > /var/workdir/snapshot << EOF
60
64
apiVersion: appstudio.redhat.com/v1alpha1
61
65
kind: Snapshot
62
66
metadata:
73
77
- name: tom
74
78
containerImage: newimage2
75
79
EOF
76
- kubectl apply -f snapshot
80
+ kubectl apply -f /var/workdir/ snapshot
77
81
78
82
mkdir -p "$(params.dataDir)/$(context.pipelineRun.uid)"
79
83
kubectl get snapshot/snapshot-sample -ojson | jq .spec | tee \
@@ -170,6 +174,9 @@ spec:
170
174
value : " $(params.orasOptions)"
171
175
- name : " DEBUG"
172
176
value : " $(params.trustedArtifactsDebug)"
177
+ # Use the same security context as the main task to avoid permission issues
178
+ securityContext :
179
+ runAsUser : 1001
173
180
steps :
174
181
- name : skip-trusted-artifact-operations
175
182
ref :
You can’t perform that action at this time.
0 commit comments