-
Notifications
You must be signed in to change notification settings - Fork 521
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
host-ctr: add label flag to host-ctr pull-image. #3757
Conversation
44f9c90
to
6fcf66a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You included a binary in the git commit that we should ensure we strip out.
I'd also like to sort out the lint failures to see if its the code or if its something else? I ran the lint manually and it did find something worth fixing while we are updating the code:
cmd/host-ctr/main.go:43:2: SA1019: rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New(NewSource(seed)) to obtain a local random generator. (staticcheck)
rand.Seed(time.Now().UnixNano())
@@ -161,9 +162,15 @@ func App() *cli.App { | |||
Destination: &useCachedImage, | |||
Value: false, | |||
}, | |||
&cli.StringFlag{ | |||
Name: "labels", | |||
Usage: "add labels to the pulled image. Each label should be in the format of `key=value` and separated by a comma", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What characters are allowed in a label? If either comma or whitespace are allowed then this might not be the right interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
labelKeyValue := strings.Split(label, "=") | ||
labelsMap[labelKeyValue[0]] = labelKeyValue[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are labels required to have an =
separate or can raw keys be used?
Linking to the label "spec" for containerd would help provide the right context for a thorough review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
containerd expects a map[string]string as labels input. Otherwise, all it cares about is that the key and value are under 4096 bytes combined. /~https://github.com/containerd/containerd/blob/f5e7fe0cb6286333a597a407029fe7c760626669/pkg/labels/validate.go#L32-L41
I'll add this validation and meanwhile I'll validate key=value
format.
^ addressed comments
|
probably need a
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM on green CI
|
rebase to use go 1.21 version on |
^ addressed comments.
Test
|
^addressed comments tolerate input without an = and just assume it's a key where the value is the empty string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks correct to me 🚢
Sandbox container image on k8s 1.29 isn't pinned and causea the Sandbox container image would be GC. we add label flag to host-ctr pull-image and pass "io.cri-containerd.pinned=pinned" label to all 1.29 varaints. Then the Sandbox contianer image will be pinned and avoid GC issue.
Issue number:
#3745
Closes #
Description of changes:
Sandbox container image on k8s 1.29 isn't pinned and causea the Sandbox container image would be GC. we add label flag to host-ctr pull-image and pass "io.cri-containerd.pinned=pinned" label to all 1.29 varaints. Then the Sandbox contianer image will be pinned and avoid GC issue.
Testing done:
AWS
VMWARE - a Known kubernetes flake on conformance test.
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.