Skip to content

Commit

Permalink
improve ci failure logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils authored and k8s-ci-robot committed Jan 14, 2025
1 parent 4a2b70a commit b2742f1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions hack/ci/e2e-apparmor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ check_apparmor_profile_recording() {

done

print_spo_logs
git diff --exit-code examples
}

Expand Down
1 change: 1 addition & 0 deletions hack/ci/e2e-seccomp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ EOT
# that uses `setns` to join the container mount namespace.
# As a consequence, we sometimes get all the funny syscalls emitted
# by the Go runtime, which we need to ignore.
print_spo_logs
echo "Diffing output while ignoring flaky syscalls"
git diff --exit-code -U0 \
-I rt_sigreturn \
Expand Down
13 changes: 9 additions & 4 deletions hack/ci/install-spo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,18 @@ wait_for() {
done

echo "Timed out waiting for $*"
echo "---------------------------------"
echo "Logs"
echo "---------------------------------"
k logs --selector name=spod --all-containers
print_spo_logs
exit 1
}

print_spo_logs() {
echo "---------------------------------"
echo "Logs"
echo "---------------------------------"
k logs --selector name!=nonexistent --all-pods --all-containers --since=10m --prefix --tail=-1
echo "---------------------------------"
}

ensure_runtime_classes() {
RUNTIMES=(runc crun)
for RUNTIME in "${RUNTIMES[@]}"; do
Expand Down
8 changes: 8 additions & 0 deletions internal/pkg/daemon/bpfrecorder/bpfrecorder.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@ func (b *BpfRecorder) SyscallsForProfile(
return nil, err
}

b.logger.Info(
fmt.Sprintf("Found %d syscalls for profile", len(syscalls)),
"profile", r.GetName(),
"mntns", mntns,
)

return &api.SyscallsResponse{
Syscalls: syscalls,
GoArch: runtime.GOARCH,
Expand Down Expand Up @@ -384,6 +390,7 @@ func (b *BpfRecorder) getMntnsForProfileWithRetry(profile string) (uint32, error
b.logger.Info("Looking up mount namespace for profile", "profile", profile, "try", try)
if foundMntns, ok := b.getMntnsForProfile(profile); ok {
mntns = foundMntns
b.logger.Info("Found mount namespace for profile", "profile", profile, "mntns", mntns)
return nil
}
b.logger.Info("No mount namespace found for profile", "profile", profile)
Expand All @@ -398,6 +405,7 @@ func (b *BpfRecorder) getMntnsForProfileWithRetry(profile string) (uint32, error

func (b *BpfRecorder) getMntnsForProfile(profile string) (uint32, bool) {
if containerID, ok := b.containerIDToProfileMap.GetBackwards(profile); ok {
b.logger.Info("Found container id for profile", "containerID", containerID, "profile", profile)
if mntns, ok := b.mntnsToContainerIDMap.GetBackwards(containerID); ok {
return mntns, true
}
Expand Down

0 comments on commit b2742f1

Please sign in to comment.