Skip to content

fix: return error from installAgentFromImage when extraction fails - #6533

Merged
avorima merged 4 commits into
Dynatrace:mainfrom
knQzx:fix/image-installer-swallowed-error
Sep 7, 2026
Merged

avorima merged 4 commits into
Dynatrace:mainfrom
knQzx:fix/image-installer-swallowed-error

Conversation

@knQzx

@knQzx knQzx commented May 1, 2026 •

Copy link
Copy Markdown
Contributor

description

installAgentFromImage logs the extraction error but returns nil. so InstallAgent never sees the error and skips the os.RemoveAll(targetDir) cleanup

for single-layer codemodule images this mostly hides itself - the symlink step fails afterwards on the missing dir and the error still surfaces, just with a misleading log

multi-layer is where it bites. layer 1 renames into targetDir successfully then layer 2 fails. targetDir has partial files. error swallowed. symlink created over the partial dir. InstallAgent returns (true, nil). next reconcile sees isAlreadyPresent=true and skips install forever. silent broken install no auto recovery

root cause

regression from a803e77 ("Make the image download function use the go-containerregistry library") - the refactor dropped the return errors.WithStack(err) and changed the log message to "via proxy"

fix

put the return back

how can this be tested?

  • existing pkg/injection/codemodule/installer/image/... tests pass
  • manually: trigger an extraction failure (unreachable registry, bad auth) - the error now propagates instead of falling through to the symlink step

installAgentFromImage was logging the error from extractAgentBinariesFromImage
but not returning it, so InstallAgent always got nil and skipped cleanup of
targetDir - leaving a potentially partial installation that isAlreadyPresent
would treat as valid on subsequent calls

regression from a803e77 which switched to go-containerregistry and dropped
the return by mistake
@knQzx
knQzx requested a review from a team as a code owner May 1, 2026 10:19
@dynatrace-cla-bot

dynatrace-cla-bot commented May 1, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

avorima
avorima previously approved these changes May 27, 2026

@avorima avorima 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.

Hi, thank you for your contribution.

This looks okay to merge. Omitting the error at this point somewhat obfuscated that multi-layer images are not supported. I've created a follow-up task on our end to improve reporting in that case.

After main was merged in, imageCacheDir is only a struct field on imagePullInfo, not a local variable, so the log line failed to compile
@knQzx

knQzx commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Pushed a build fix - after main was merged in, imageCacheDir became a field on imagePullInfo rather than a local, so the failure-log line stopped compiling. It now references the CacheDir constant, which is the exact value passed into imagePullInfo, so the log stays accurate. CI should go green again. @avorima the approval was dismissed on the update - could you take another look when you get a chance?

@jokuniew jokuniew added the community Pull requests submitted by external / community contributors label Jul 30, 2026
@jdanieck
jdanieck requested review from avorima and removed request for jdanieck September 7, 2026 10:45
@avorima
avorima removed their request for review September 7, 2026 11:33
@avorima
avorima enabled auto-merge September 7, 2026 11:51
@avorima
avorima added this pull request to the merge queue Sep 7, 2026
Merged via the queue into Dynatrace:main with commit fa30d1a Sep 7, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Pull requests submitted by external / community contributors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants