Skip to content

Commit 6febb63

Browse files
committed
debug
1 parent 5f60f64 commit 6febb63

File tree

2 files changed

+987
-884
lines changed

2 files changed

+987
-884
lines changed

internal/buildsign/resource/common.go

Lines changed: 110 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,24 +146,113 @@ func buildBuildahScript(destinationImg string, tlsOptions kmmv1beta1.TLSOptions,
146146
}
147147

148148
// Build the setup section based on operation type
149-
setupSection := `echo "setting up build context"
149+
setupSection := `echo "=== DEBUG: Starting buildah setup ==="
150+
echo "DEBUG: Current working directory: $(pwd)"
151+
echo "DEBUG: Current user: $(whoami)"
152+
echo "DEBUG: Available disk space:"
153+
df -h /tmp
154+
155+
echo "=== DEBUG: Setting up build context ==="
156+
echo "setting up build context"
150157
mkdir -p /tmp/build-context
151158
cp /workspace/Dockerfile /tmp/build-context/
159+
160+
echo "=== DEBUG: Checking /run/secrets directory ==="
161+
if [ -d "/run/secrets" ]; then
162+
echo "DEBUG: /run/secrets directory exists"
163+
echo "DEBUG: /run/secrets permissions:"
164+
ls -ld /run/secrets
165+
echo "DEBUG: /run/secrets contents:"
166+
ls -la /run/secrets/ || echo "DEBUG: Failed to list /run/secrets contents"
167+
else
168+
echo "DEBUG: ERROR - /run/secrets directory does not exist!"
169+
fi
170+
171+
echo "=== DEBUG: Checking for secret directories pattern /run/secrets/*/ ==="
152172
# Copy build secrets into build context so they're accessible during build
153173
for secret_dir in /run/secrets/*/; do
174+
echo "DEBUG: Checking pattern match: $secret_dir"
154175
if [ -d "$secret_dir" ]; then
176+
echo "DEBUG: Found valid secret directory: $secret_dir"
177+
echo "DEBUG: Secret directory permissions:"
178+
ls -ld "$secret_dir"
179+
echo "DEBUG: Secret directory contents:"
180+
ls -la "$secret_dir" || echo "DEBUG: Failed to list secret directory contents"
181+
155182
echo "copying secrets from $secret_dir to build context"
156-
cp -r "$secret_dir"* /tmp/build-context/
183+
echo "DEBUG: About to copy: $secret_dir* -> /tmp/build-context/"
184+
cp -rv "$secret_dir"* /tmp/build-context/ || echo "DEBUG: Copy failed with exit code $?"
185+
186+
echo "DEBUG: Verifying copy results:"
187+
echo "DEBUG: Files copied from $secret_dir:"
188+
find "$secret_dir" -type f -exec basename {} \; || echo "DEBUG: Failed to find files in secret dir"
189+
else
190+
echo "DEBUG: Pattern $secret_dir is not a directory or doesn't exist"
157191
fi
158-
done`
192+
done
193+
194+
echo "=== DEBUG: Final build context contents ==="
195+
echo "DEBUG: /tmp/build-context directory:"
196+
ls -la /tmp/build-context/ || echo "DEBUG: Failed to list build context"
197+
echo "DEBUG: Checking for specific file ci-build-secret:"
198+
if [ -f "/tmp/build-context/ci-build-secret" ]; then
199+
echo "DEBUG: SUCCESS - ci-build-secret file found!"
200+
echo "DEBUG: ci-build-secret file contents:"
201+
cat /tmp/build-context/ci-build-secret || echo "DEBUG: Failed to read ci-build-secret"
202+
else
203+
echo "DEBUG: ERROR - ci-build-secret file NOT found in build context!"
204+
fi
205+
206+
echo "=== DEBUG: Volume mounts information ==="
207+
echo "DEBUG: All mounted filesystems:"
208+
mount | grep -E "(secret|tmp)" || echo "DEBUG: No secret or tmp mounts found"`
159209

160210
// If we do sign instead
161211
if operation == Sign {
162-
setupSection = `echo "setting up build context with cert and key files"
212+
setupSection = `echo "=== DEBUG: Starting buildah sign setup ==="
213+
echo "DEBUG: Current working directory: $(pwd)"
214+
echo "DEBUG: Current user: $(whoami)"
215+
216+
echo "=== DEBUG: Setting up build context for signing ==="
217+
echo "setting up build context with cert and key files"
163218
mkdir -p /tmp/build-context
164219
cp /workspace/Dockerfile /tmp/build-context/
165-
cp /run/secrets/cert/cert.pem /tmp/build-context/cert.pem
166-
cp /run/secrets/key/key.pem /tmp/build-context/key.pem`
220+
221+
echo "=== DEBUG: Checking signing secrets ==="
222+
echo "DEBUG: Checking /run/secrets/cert directory:"
223+
if [ -d "/run/secrets/cert" ]; then
224+
echo "DEBUG: /run/secrets/cert exists"
225+
ls -la /run/secrets/cert/
226+
if [ -f "/run/secrets/cert/cert.pem" ]; then
227+
echo "DEBUG: cert.pem file found"
228+
else
229+
echo "DEBUG: ERROR - cert.pem file not found!"
230+
fi
231+
else
232+
echo "DEBUG: ERROR - /run/secrets/cert directory does not exist!"
233+
fi
234+
235+
echo "DEBUG: Checking /run/secrets/key directory:"
236+
if [ -d "/run/secrets/key" ]; then
237+
echo "DEBUG: /run/secrets/key exists"
238+
ls -la /run/secrets/key/
239+
if [ -f "/run/secrets/key/key.pem" ]; then
240+
echo "DEBUG: key.pem file found"
241+
else
242+
echo "DEBUG: ERROR - key.pem file not found!"
243+
fi
244+
else
245+
echo "DEBUG: ERROR - /run/secrets/key directory does not exist!"
246+
fi
247+
248+
echo "=== DEBUG: Copying signing certificates ==="
249+
echo "DEBUG: Copying cert.pem..."
250+
cp -v /run/secrets/cert/cert.pem /tmp/build-context/cert.pem || echo "DEBUG: Failed to copy cert.pem"
251+
echo "DEBUG: Copying key.pem..."
252+
cp -v /run/secrets/key/key.pem /tmp/build-context/key.pem || echo "DEBUG: Failed to copy key.pem"
253+
254+
echo "=== DEBUG: Final signing build context contents ==="
255+
ls -la /tmp/build-context/`
167256
}
168257

169258
// Build command section
@@ -185,6 +274,14 @@ export PUSH_IMAGE="%s"
185274
186275
%s
187276
277+
echo "=== DEBUG: Setup completed, starting buildah ==="
278+
echo "DEBUG: About to run buildah command with these parameters:"
279+
echo "DEBUG: Image: $IMAGE"
280+
echo "DEBUG: TLS Verify: %s"
281+
echo "DEBUG: Build command: %s"
282+
echo "DEBUG: Final verification of /tmp/build-context before buildah:"
283+
ls -la /tmp/build-context/
284+
188285
echo "starting Buildah %s for $IMAGE"
189286
%s \
190287
--tls-verify=%s \
@@ -193,17 +290,23 @@ echo "starting Buildah %s for $IMAGE"
193290
-t "$IMAGE" \
194291
/tmp/build-context
195292
293+
echo "=== DEBUG: Buildah command completed with exit code: $? ==="
294+
196295
if [ "$PUSH_IMAGE" = "true" ]; then
296+
echo "=== DEBUG: Starting push phase ==="
197297
echo "pushing %s $IMAGE..."
198298
buildah push \
199299
--tls-verify=%s \
200300
--storage-driver=vfs \
201301
"$IMAGE" \
202302
"docker://$IMAGE"
303+
echo "DEBUG: Push completed with exit code: $?"
203304
else
204305
echo "skipping push step (PUSH_IMAGE=$PUSH_IMAGE)"
205306
fi
206-
`, destinationImg, pushImageStr, setupSection, actionDescription, buildCmd, tlsVerify, pushDescription, tlsVerify)
307+
308+
echo "=== DEBUG: Script execution completed ==="
309+
`, destinationImg, pushImageStr, setupSection, tlsVerify, buildCmd, actionDescription, buildCmd, tlsVerify, pushDescription, tlsVerify)
207310

208311
return script
209312
}

0 commit comments

Comments
 (0)