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(cloudbuilder): add error handling to fallback to cli install of buildx builder #6258

Merged
merged 3 commits into from
Jul 5, 2024

Conversation

twelvemo
Copy link
Collaborator

@twelvemo twelvemo commented Jul 5, 2024

What this PR does / why we need it:
We try to install a buildx builder directly by writing to the local .docker directory and if that fails we use docker cli to install the builder. In some environments e.g. CI the local .docker directory may not be available or not configured with the correct subpath of ~/.docker/buildx/instances. We were missing some error handling and await when checking for these paths, which led garden to fail in case the path does not exist.
Also adds an error message for a common error which is missing or wrong credentials for the registry.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

@twelvemo twelvemo requested review from eysi09 and vvagaytsev July 5, 2024 11:54
Copy link
Collaborator

@eysi09 eysi09 left a comment

Choose a reason for hiding this comment

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

Had a couple of comments but otherwise looks great!

await this.remove_builder()
await this.remove_tmpdir()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the order matter? If so, can we add a comment to that effect since this could easily break.

(Ideally we have a test for this but I don't know how feasible that is here.)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we always use camelCase for method names? :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right, we should add a comment since it matters because if we fallback to removing using docker cli in remove_builder we assume the certDir still exists and we use it as cwd. Though i don't see why we would need to change to the certDir to run that command, will just remove this dependency.

// An error is thrown e.g. if the path does not exist.
// We don't need to handle this error, as we will fall back to the CLI installation.
if (isErrnoException(e) && e.code === "ENOENT") {
return false
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we still log the error though? In case there are other failure modes we're not thinking of which we won't see if the error is swallowed.

@twelvemo twelvemo requested a review from eysi09 July 5, 2024 13:01
@twelvemo twelvemo enabled auto-merge July 5, 2024 13:43
Copy link
Collaborator

@vvagaytsev vvagaytsev left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@twelvemo twelvemo added this pull request to the merge queue Jul 5, 2024
Merged via the queue into main with commit 6f4b120 Jul 5, 2024
40 checks passed
@twelvemo twelvemo deleted the fix-cloudbuilder-fallback-install branch July 5, 2024 14:11
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.

3 participants