Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix shadowed trustedroot #178

Merged
merged 2 commits into from
Sep 17, 2024
Merged

Fix shadowed trustedroot #178

merged 2 commits into from
Sep 17, 2024

Conversation

codysoyland
Copy link
Collaborator

This code caused the singleton trustedRoot to be returned as nil on subsequent calls. The singleton was shadowed when the variable was redeclared in the if block:

-trustedRoot, err := root.NewTrustedRootFromJSON(targetBytes)
+trustedRoot, err = root.NewTrustedRootFromJSON(targetBytes)

Additionally, this PR removes some unused code managing a singleton error.

Fixes #177

This code caused the singleton `trustedRoot` to be returned as nil on subsequent calls. The singleton was shadowed when the variable was redeclared in the `if` block.

Signed-off-by: Cody Soyland <[email protected]>
`singletonRootError` was never returned without being overwritten, so it was essentially unused. I think it's wise to always retry the TUF call on future invocations in case of network errors.

Signed-off-by: Cody Soyland <[email protected]>
@codysoyland codysoyland requested review from steiza and a team as code owners September 17, 2024 21:34
@codysoyland codysoyland requested review from malancas and removed request for a team and steiza September 17, 2024 21:36
@codysoyland codysoyland merged commit 4db97ca into release Sep 17, 2024
12 of 69 checks passed
codysoyland added a commit that referenced this pull request Oct 10, 2024
* Fix shadowed variable bug

This code caused the singleton `trustedRoot` to be returned as nil on subsequent calls. The singleton was shadowed when the variable was redeclared in the `if` block.

Signed-off-by: Cody Soyland <[email protected]>

* Remove unused singleton

`singletonRootError` was never returned without being overwritten, so it was essentially unused. I think it's wise to always retry the TUF call on future invocations in case of network errors.

Signed-off-by: Cody Soyland <[email protected]>

---------

Signed-off-by: Cody Soyland <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

controller crashes with segmentation violation error when retrying to run an admissible pod
2 participants