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

[remotecache] Add Azure Blob Storage support #3010

Merged
merged 1 commit into from
Sep 2, 2022
Merged

[remotecache] Add Azure Blob Storage support #3010

merged 1 commit into from
Sep 2, 2022

Conversation

vangarp
Copy link
Contributor

@vangarp vangarp commented Aug 9, 2022

This adds experimental support for Azure Blob Storage based remote cache to buildkit. For usage instructions please refer to the updated Readme. We have tried to keep it similar to the S3 based implementation while using equivalent Azure Blob Storage specific semantics where appropriate.
This also adds end-to-end tests to exercise the Azure Blob Storage based cache using the Azurite emulator.

Co-authored-by: Amr Mahdi amrh@microsoft.com
Co-authored-by: Pranav Pandit pranavp@microsoft.com

.dockerignore Outdated Show resolved Hide resolved
.gitignore Outdated Show resolved Hide resolved
client/client.go Outdated Show resolved Hide resolved
@vangarp vangarp requested a review from thaJeztah August 10, 2022 13:33
Copy link
Member

@thaJeztah thaJeztah 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 quick peek at the new dependencies, and left some comments/questions.

fwiw; I'm not a maintainer on this repository (but always keeping a bit of an eye on the dependency tree as it may affect other projects as well that use BuildKit as a module)

go.mod Show resolved Hide resolved
@@ -120,9 +126,11 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
Copy link
Member

@thaJeztah thaJeztah Aug 10, 2022

Choose a reason for hiding this comment

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

This module does a lot of reflection etc, but looks to be used only to provide a "pretty" verbose error; https://github.com/AzureAD/microsoft-authentication-library-for-go/blob/751ec246d696ada22aee7a7c3bfd7a097b248250/apps/errors/errors.go#L77

I'm not very familiar with this package, but it looks to be managed by a single-maintainer, and not very widely used (edit: ignore me; maybe it is; GitHub didn't show things correctly), and it lists github.com/google/go-cmp and github.com/davecgh/go-spew as possible alternatives (both of which are already used, but even those only for tests).

Happy to hear input on that from others, but given that the functionality of that package (from the looks of it) doesn't seem to be essential, I'm wondering if there would be ways to remove it (could be through a build-tag perhaps).

Copy link
Contributor Author

@vangarp vangarp Aug 25, 2022

Choose a reason for hiding this comment

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

The package definitely looks like it is widely used including several very widely used projects like prometheus-operator, istio etc.. The other packages mentioned (gp-cmp, go-spew) also don't look like they are maintained much which is understandable considering how light the functionality they provide is. I really don't see this as a problem unless someone has a strong opinion on why this particular package is bad enough to make an exception by allowing it to be skipped somehow

Copy link
Member

Choose a reason for hiding this comment

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

A difference here is that most of those don't use this in production code, only in tests; e.g. https://cs.github.com/prometheus-operator/prometheus-operator?q=github.com%2Fkylelemons%2Fgodebug
https://cs.github.com/istio/istio?q=github.com%2Fkylelemons%2Fgodebug

Not a strong blocker for me, but let me "unresolved" the conversation to keep the converesation visible for future reference

go.mod Outdated Show resolved Hide resolved
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

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

Separate the golint fixes. Squash the rest.

client/client.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
@vangarp
Copy link
Contributor Author

vangarp commented Aug 18, 2022

@tonistiigi PTAL. I am still waiting for either #3022 or #3023 to complete to fix the panic during lint, but everything else should be good

@vangarp vangarp requested a review from thaJeztah August 25, 2022 05:14
Copy link
Member

@crazy-max crazy-max left a comment

Choose a reason for hiding this comment

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

Can you also rebase please?

.github/workflows/build.yml Outdated Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
.github/workflows/build.yml Outdated Show resolved Hide resolved
@thaJeztah
Copy link
Member

I want to do a quick test (draft PR) to see if the additional dependencies cause issues in combination with the (already complex) dependency tree in moby/moby when vendored. These "SDK" dependencies in particular can cause a lot of havoc (40k+ added lines of code definitely is a lot as well for this). Do we want build-tags to allow making specific drivers to be opt-in/opt-out?

I still have some concerns about #3010 (comment)

This dependency sounds a bit scary (opening a browser with an URL); looks like it can be called from https://github.com/Azure/azure-sdk-for-go/blob/48dd0f41119aa74cbcaa91fa4bac178c1fd09a70/sdk/azidentity/interactive_browser_credential.go#L76-L77

Do you know if that can ever be hit?

yeah that guy looks like it is only used for InteractiveBrowserCredential but we are not using it

And would like to have more eyes on that (also from a security perspective) just to be sure. While BuildKit may not (currently) use the functionality, I want to be sure that code-path cannot be hit. I'd like to be sure that there's no code that "heuristically" determines if interactive authentication is needed, and that might trigger an interactive login (open <scheme://> in default application). Such a code-path may be a backdoor waiting to happen; taking into account BuildKit may be running as root. My ideal would be for that dependency to not be included unless code actually requires it (which could be "interactive" being a separate module and/or gated by a build-tag).

Same applies, but to a lesser extend, to #3010 (comment). Not a blocker for me, but (as you work at Microsoft) if you have any influence on the github.com/AzureAD/microsoft-authentication-library-for-go package, I'd love to see that dependency disappear from non-test code, as it mostly looks like a "nice to have", not essential.

go.sum Outdated Show resolved Hide resolved
thaJeztah added a commit to thaJeztah/docker that referenced this pull request Aug 25, 2022
testing moby/buildkit#3010

Looks like we should be good here; the new Azure bits don't affect other
Azure / MS versions in use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member

I want to do a quick test (draft PR) to see if the additional dependencies cause issues in combination with the (already complex) dependency tree in moby/moby when vendored.

Looks like we're good from that perspective; the new dependencies don't appear to be affecting versions of the Azure / Microsoft dependencies in moby/moby; moby/moby#44031

This adds experimental support for Azure Blob Storage based remote cache to buildkit. For usage instructions please refer to the updated Readme. We have tried to keep it similar to the S3 based implementation while using equivalent Azure Blob Storage specific semantics where appropriate.
This also adds end-to-end tests to exercise the Azure Blob Storage based cache using the [Azurite emulator](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite).

Co-authored-by: Amr Mahdi <amrh@microsoft.com>
Co-authored-by: Pranav Pandit <pranavp@microsoft.com>
Signed-off-by: Pranav Pandit <pranavp@microsoft.com>
@vangarp vangarp requested a review from crazy-max August 25, 2022 13:58
@vangarp
Copy link
Contributor Author

vangarp commented Aug 25, 2022

I want to do a quick test (draft PR) to see if the additional dependencies cause issues in combination with the (already complex) dependency tree in moby/moby when vendored. These "SDK" dependencies in particular can cause a lot of havoc (40k+ added lines of code definitely is a lot as well for this). Do we want build-tags to allow making specific drivers to be opt-in/opt-out?

I still have some concerns about #3010 (comment)

This dependency sounds a bit scary (opening a browser with an URL); looks like it can be called from https://github.com/Azure/azure-sdk-for-go/blob/48dd0f41119aa74cbcaa91fa4bac178c1fd09a70/sdk/azidentity/interactive_browser_credential.go#L76-L77
Do you know if that can ever be hit?

yeah that guy looks like it is only used for InteractiveBrowserCredential but we are not using it

And would like to have more eyes on that (also from a security perspective) just to be sure. While BuildKit may not (currently) use the functionality, I want to be sure that code-path cannot be hit. I'd like to be sure that there's no code that "heuristically" determines if interactive authentication is needed, and that might trigger an interactive login (open <scheme://> in default application). Such a code-path may be a backdoor waiting to happen; taking into account BuildKit may be running as root. My ideal would be for that dependency to not be included unless code actually requires it (which could be "interactive" being a separate module and/or gated by a build-tag).

Same applies, but to a lesser extend, to #3010 (comment). Not a blocker for me, but (as you work at Microsoft) if you have any influence on the github.com/AzureAD/microsoft-authentication-library-for-go package, I'd love to see that dependency disappear from non-test code, as it mostly looks like a "nice to have", not essential.

I know ideal would be to not have that dependency and I will create an issue to see if there is a possibility of that, but for now what I can do is go over the code to show why the browser path is not being hit in this case. If you look at the place where we are using the credentials then you can see that we use either the NewSharedKeyCredential or NewDefaultAzureCredential. Shared key credential just uses the account name and key directly. DefaultAzureCredential code is also fairly clear, in that it is meant to make it easy for servers to auth easily using 1 of the combinations of environment variables or logged in credentials as mentioned here. You can see in the code and also in the documentation that it does not use the InteractiveBrowserCredential anywhere in there. I hope this helps somewhat alleviate the doubts?

@thaJeztah
Copy link
Member

I know ideal would be to not have that dependency and I will create an issue to see if there is a possibility of that

Thank you; appreciated!

I know ideal would be to not have that dependency and I will create an issue to see if there is a possibility of that, but for now what I can do is go over the code to show why the browser path is not being hit in this case.

Yes, I had a look at the code earlier, and indeed it won't be hit currently. My (perhaps too paranoid) look at having the dependency was that, with the pkg/browser dependency already in place, it would be less apparent if an (indirect) dependency would start to consume it; with BuildKit (and/or dockerd) running as root, that's a risk. We do use vendoring to help us to audit/review changes in dependencies, but of course things can be missed, so where possible I try to veer on the safe side.

I guess a "dirty" fix would be to replace it with a stubbed out version, but perhaps that's taking it too far for now.

So I'm fine with the current state if maintainers are ok with it, but would indeed like to see it gone in future (if possible).

@thaJeztah
Copy link
Member

thaJeztah commented Aug 25, 2022

I guess a "dirty" fix would be to replace it with a stubbed out version, but perhaps that's taking it too far for now.

Just for fun; tried if that would work, and looks like it does. Quite a dirty trick though; https://github.com/thajeztah/buildkit/tree/nobrowser

thaJeztah@38ac4be

@vangarp
Copy link
Contributor Author

vangarp commented Aug 25, 2022

I guess a "dirty" fix would be to replace it with a stubbed out version, but perhaps that's taking it too far for now.

Just for fun; tried if that would work, and looks like it does. Quite a dirty trick though; https://github.com/thajeztah/buildkit/tree/nobrowser

thaJeztah@38ac4be

haha it is an interesting way of addressing it indeed!

@crazy-max @tonistiigi what do you think? are you ok with the browser dependency remaining as it is given that the path which uses it is not being used (and I am going to create an issue to see if it can be removed somehow), or would you rather have the "trick" that @thaJeztah suggested?

@tonistiigi
Copy link
Member

or would you rather have the "trick"

No, that 250 lines is not worth it.

thaJeztah added a commit to thaJeztah/docker that referenced this pull request Aug 25, 2022
testing moby/buildkit#3010

Looks like we should be good here; the new Azure bits don't affect other
Azure / MS versions in use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
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.

5 participants