Skip to content

Commit 007c778

Browse files
simonbairdclaude
andcommitted
Remove conflicting pull secret from integration runner SA
The pull-only ec-main-pull secret covers the same registry path as the push secret. When Tekton merges credentials, the pull-only one can win, causing oras attach to fail with "unauthorized". The push secret includes pull permission so removing the pull-only one loses nothing. Ref: https://redhat.atlassian.net/browse/EC-2011 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9cedcf9 commit 007c778

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

hack/create-dummy-its.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,37 @@ echo ""
7272
PUSH_SECRET="${PUSH_SECRET:-imagerepository-for-ec-main-cli-main-image-push}"
7373
INTEGRATION_SA="konflux-integration-runner"
7474

75-
if oc get sa "${INTEGRATION_SA}" -n "${NAMESPACE}" -o json | grep -q "\"${PUSH_SECRET}\""; then
75+
# The pull-only secret "ec-main-pull" covers the same registry path as the
76+
# push secret. Tekton merges all SA secrets into a single docker config, and
77+
# if the pull-only credential wins the merge for that registry, oras attach
78+
# fails with "unauthorized". Removing the pull-only secret avoids the
79+
# conflict — the push secret includes pull permission so nothing is lost.
80+
PULL_SECRET="${PULL_SECRET:-ec-main-pull}"
81+
82+
SA_JSON=$(oc get sa "${INTEGRATION_SA}" -n "${NAMESPACE}" -o json)
83+
84+
if echo "${SA_JSON}" | python3 -c "
85+
import json, sys
86+
sa = json.load(sys.stdin)
87+
secrets = [s['name'] for s in sa.get('secrets', [])]
88+
print('found' if '${PULL_SECRET}' in secrets else 'not_found')
89+
" | grep -q "found"; then
90+
echo "Removing pull secret '${PULL_SECRET}' from SA '${INTEGRATION_SA}' to avoid credential conflict"
91+
INDEX=$(echo "${SA_JSON}" | python3 -c "
92+
import json, sys
93+
sa = json.load(sys.stdin)
94+
for i, s in enumerate(sa.get('secrets', [])):
95+
if s['name'] == '${PULL_SECRET}':
96+
print(i)
97+
break
98+
")
99+
oc patch sa "${INTEGRATION_SA}" -n "${NAMESPACE}" --type=json \
100+
-p="[{\"op\":\"remove\",\"path\":\"/secrets/${INDEX}\"}]"
101+
else
102+
echo "Pull secret '${PULL_SECRET}' not present on SA '${INTEGRATION_SA}' (already removed)"
103+
fi
104+
105+
if echo "${SA_JSON}" | grep -q "\"${PUSH_SECRET}\""; then
76106
echo "Push secret '${PUSH_SECRET}' already linked to SA '${INTEGRATION_SA}'"
77107
else
78108
echo "Adding push secret '${PUSH_SECRET}' to SA '${INTEGRATION_SA}'"

0 commit comments

Comments
 (0)