Skip to content

debug: add a script for investigating a jar - #1945

Open
hdonnay wants to merge 1 commit into
quay:mainfrom
hdonnay:hack/jar-debug
Open

debug: add a script for investigating a jar#1945
hdonnay wants to merge 1 commit into
quay:mainfrom
hdonnay:hack/jar-debug

Conversation

@hdonnay

@hdonnay hdonnay commented Jul 10, 2026

Copy link
Copy Markdown
Member

This script automates the process of extracting a jar from an OCI image and running the java/jar "TestJAR" test against it.

@hdonnay
hdonnay requested review from a team as code owners July 10, 2026 19:01
@hdonnay
hdonnay requested a review from crozzy July 10, 2026 19:01
@BradLugo
BradLugo self-requested a review August 5, 2026 16:02

@BradLugo BradLugo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to publish this! I love debug tooling.

One more consideration I wanted to note: what happens in the case of whiteout files? Maybe not something worth worrying about, but I was curious.

I'd really like the env change so I can use this on my NixOS machine 🙂

Comment thread etc/debug/bin/investigate-jar Outdated
@@ -0,0 +1,106 @@
#!/usr/bin/zsh

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#!/usr/bin/zsh
#!/usr/bin/env zsh

Comment on lines +67 to +80
# Find the jars across all the layers.
#
# Keeping an array and a map means when the list is presented in the next step,
# they're in the "correct" order: newer layers first.
local -a jarlist
local -A jarlayer
for l in $layers; do
tar taf ${opts[--ocidir]}/blobs/${l/://} |
grep -E '\.[jwe]ar$' |
while read -r n; do
jarlist+=($n)
jarlayer[$n]=$l
done
done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens when a jar is "overwritten" in another layer?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will only allow you to select the earliest file with a given path. We could fix this if it ever comes up, or I can hack at it some more.

@hdonnay

hdonnay commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

One more consideration I wanted to note: what happens in the case of whiteout files? Maybe not something worth worrying about, but I was curious.

Yeah, this doesn't contend with whiteouts at all. The idea is that a user of this script knows what to investigate; this just bundles it all up.

This script automates the process of extracting a jar from an OCI image
and running the `java/jar` "TestJAR" test against it.

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
Change-Id: Ic17aafc00fd67d9c0964806f23ace5de6a6a6964
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants