Skip to content

containerimage: Export option keys#3694

Merged
tonistiigi merged 3 commits intomoby:masterfrom
vvoland:containerimage-consts-public
Jun 2, 2023
Merged

containerimage: Export option keys#3694
tonistiigi merged 3 commits intomoby:masterfrom
vvoland:containerimage-consts-public

Conversation

@vvoland
Copy link
Copy Markdown
Collaborator

@vvoland vvoland commented Mar 8, 2023

Make containerdimage attribute key names public, to make it easier for some downstream projects to use them without hardcoding them on their side 😅 .

Copy link
Copy Markdown
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.

LGTM

Comment on lines +39 to +45
KeyPush = "push"
KeyPushByDigest = "push-by-digest"
KeyInsecure = "registry.insecure"
KeyUnpack = "unpack"
KeyDanglingPrefix = "dangling-name-prefix"
KeyNameCanonical = "name-canonical"
KeyStore = "store"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As a follow-up, we should consider;

  • making these strong-typed (if possible)
  • documenting these (some of them may be clear, but still may require some knowledge (what does this mean?)

I know @jedevc has done some work on improving such consts in other areas (happy to do the work, but I may need some input on the docs side of things)

Copy link
Copy Markdown
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.

We could do this in a follow-up but these constants should not be defined in this pkg if they are public. If you want to use these keys, eg. to pass them from the client side, you should not need to pull in the server side implementation with all its dependencies.

This could either be in exptypes, or in a separate subpackage.

@thaJeztah
Copy link
Copy Markdown
Member

these contacts should not be defined in this pkg if they are public

Good point, I was wondering (should've asked) if this was the right place for these; are these consts "common" between exporters, or specific to each?

FWIW; this change is not "urgent" (we currently just duplicate them in moby/moby) but would be good to have in the next (v0.12) release, so I'd be fine to give it a bit more look and "do it correct" in a single PR (no need to rush this in). Perhaps that also allows us to combine it with #3694 (comment)

Copy link
Copy Markdown
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.

changing my "LGTM" to "request changes".

As there's no rush, I think it's worth spending a bit more time on this to "do it right"

@vvoland
Copy link
Copy Markdown
Collaborator Author

vvoland commented Mar 8, 2023

Yeah, good point. I'll rework this PR.

@jedevc
Copy link
Copy Markdown
Member

jedevc commented May 23, 2023

@vvoland @thaJeztah, I imagine there's a good chance you might want these in the next buildkit release?

@thaJeztah
Copy link
Copy Markdown
Member

Looks like good to have (not critical but definitely good to have).

Do we have pointers what package those consts should move to?

@vvoland
Copy link
Copy Markdown
Collaborator Author

vvoland commented May 23, 2023

exporter/containerimage/exptypes sounds reasonable. I'll try to do it today.

@vvoland vvoland force-pushed the containerimage-consts-public branch 2 times, most recently from 43b79f7 to c3fdce5 Compare May 23, 2023 15:22
@vvoland
Copy link
Copy Markdown
Collaborator Author

vvoland commented May 23, 2023

Done, also added some docs, please let me know if I wrote something silly there 😄

@thaJeztah
Copy link
Copy Markdown
Member

@jedevc any thoughts on #3694 (comment) (in case we want a type for these?)

@jedevc
Copy link
Copy Markdown
Member

jedevc commented May 24, 2023

I think having a custom separate type (that's not just an alias) will cause a lot of churn in different places. The exporter type is passed as a plain string through the BuildKit control API, so we'd have to convert it out of that constantly.

Nothing else in exptypes has its custom type, so I'm happy to leave it as-is for - we can also revisit later 🎉

@thaJeztah
Copy link
Copy Markdown
Member

The exporter type is passed as a plain string through the BuildKit control API, so we'd have to convert it out of that constantly.

Yes, makes sense. I had #3199 in mind, where we ultimately decided to go for strong-typed (which wasn't too bad w.r.t. casting strings to types), but must admit I haven't looked how much impact the consts in this PR would have. (Was just considering: if we want to do it, this might be a good occasion to do so)

@vvoland vvoland force-pushed the containerimage-consts-public branch from c3fdce5 to 718b1a8 Compare May 24, 2023 12:08
@vvoland
Copy link
Copy Markdown
Collaborator Author

vvoland commented May 24, 2023

Moved other exporter keys and changed the keys to be strongly typed. It doesn't seem to involve that much type-casting, although it makes it a bit weird for the external consumer to assign them to a map[string]string anyway. I can drop the last commit if we don't want it.

@vvoland vvoland changed the title containerimage: Make attribute keys consts public containerimage: Export option keys May 24, 2023
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the containerimage-consts-public branch 2 times, most recently from 6d6b719 to 6443a6a Compare May 30, 2023 11:01
@jedevc jedevc requested review from thaJeztah and tonistiigi May 30, 2023 11:12
@vvoland
Copy link
Copy Markdown
Collaborator Author

vvoland commented May 30, 2023

Failure looks unrelated:

=== FAIL: client TestIntegration/TestBasicGhaCacheImportExport/worker=containerd (302.33s)
    client_test.go:4804: 
        	Error Trace:	/src/client/client_test.go:4804
        	            				/src/client/client_test.go:5190
        	            				/src/util/testutil/integration/run.go:89
        	            				/src/util/testutil/integration/run.go:198
        	Error:      	Received unexpected error:
        	            	maximum timeout reached
        	            	github.com/moby/buildkit/util/stack.Enable
        	            		/src/util/stack/stack.go:77
        	            	github.com/moby/buildkit/util/grpcerrors.FromGRPC
        	            		/src/util/grpcerrors/grpcerrors.go:198
        	            	github.com/moby/buildkit/util/grpcerrors.UnaryClientInterceptor
        	            		/src/util/grpcerrors/intercept.go:41
        	            	google.golang.org/grpc.(*ClientConn).Invoke
        	            		/src/vendor/google.golang.org/grpc/call.go:35
        	            	github.com/moby/buildkit/api/services/control.(*controlClient).Solve
        	            		/src/api/services/control/control.pb.go:2208
        	            	github.com/moby/buildkit/client.(*Client).solve.func2
        	            		/src/client/solve.go:258
        	            	golang.org/x/sync/errgroup.(*Group).Go.func1
        	            		/src/vendor/golang.org/x/sync/errgroup/errgroup.go:75
        	            	runtime.goexit
        	            		/usr/local/go/src/runtime/asm_amd64.s:1598
        	            	failed to solve
        	            	github.com/moby/buildkit/client.(*Client).solve.func2
        	            		/src/client/solve.go:273
        	            	golang.org/x/sync/errgroup.(*Group).Go.func1
        	            		/src/vendor/golang.org/x/sync/errgroup/errgroup.go:75
        	            	runtime.goexit
        	            		/usr/local/go/src/runtime/asm_amd64.s:1598
        	Test:       	TestIntegration/TestBasicGhaCacheImportExport/worker=containerd

@thaJeztah
Copy link
Copy Markdown
Member

Failure looks unrelated:

I gave CI a kick

@thaJeztah
Copy link
Copy Markdown
Member

Not for this PR, but while looking at a ticket in moby/moby (moby/moby#45665), I discovered more strings in there that have non-exported consts defined in BuildKit;
https://github.com/moby/moby/blob/8d67d0c1a8d28ad4014444edc6b9975f9877b1d6/builder/builder-next/builder.go#L299-L332

consts are in the dockerfile frontend;

const (
buildArgPrefix = "build-arg:"
labelPrefix = "label:"
keyTarget = "target"
keyCgroupParent = "cgroup-parent"
keyForceNetwork = "force-network-mode"
keyGlobalAddHosts = "add-hosts"
keyHostname = "hostname"
keyImageResolveMode = "image-resolve-mode"
keyMultiPlatform = "multi-platform"
keyNoCache = "no-cache"
keyShmSize = "shm-size"
keyTargetPlatform = "platform"
keyUlimit = "ulimit"
keyCacheFrom = "cache-from" // for registry only. deprecated in favor of keyCacheImports
keyCacheImports = "cache-imports" // JSON representation of []CacheOptionsEntry
// Don't forget to update frontend documentation if you add
// a new build-arg: frontend/dockerfile/docs/reference.md
keyCacheNSArg = "build-arg:BUILDKIT_CACHE_MOUNT_NS"
keyMultiPlatformArg = "build-arg:BUILDKIT_MULTI_PLATFORM"
keyHostnameArg = "build-arg:BUILDKIT_SANDBOX_HOSTNAME"
keyContextKeepGitDirArg = "build-arg:BUILDKIT_CONTEXT_KEEP_GIT_DIR"
keySourceDateEpoch = "build-arg:SOURCE_DATE_EPOCH"
)

Perhaps we should look at those as well 🤔 - let me create a ticket for that.

@thaJeztah
Copy link
Copy Markdown
Member

Copy link
Copy Markdown
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.

LGTM! ❤️

for those interested; docs look like this;

Screenshot 2023-06-01 at 01 02 26

vvoland added 2 commits June 2, 2023 09:38
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
@vvoland vvoland force-pushed the containerimage-consts-public branch from b1d3836 to d82a803 Compare June 2, 2023 07:39
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