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

If the image with :latest tag specified in spec, pull even PullIfNotPresent is set. #2388

Merged
merged 2 commits into from
Nov 15, 2014

Conversation

dchen1107
Copy link
Member

No description provided.

@dchen1107
Copy link
Member Author

@lavalamp @brendandburns

func TestSyncPodsWithPullPolicy(t *testing.T) {
kubelet, _, fakeDocker := newTestKubelet(t)
puller := kubelet.dockerPuller.(*dockertools.FakeDockerPuller)
puller.HasImages = []string{"existing_one", "want:latest"}
Copy link
Member

Choose a reason for hiding this comment

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

This ("want:latest") isn't a state of knowledge that can actually exist in reality-- you never know if you have the latest thing sitting on disk. Or do I misunderstand?

Copy link
Member Author

Choose a reason for hiding this comment

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

HasImage in fakeDockerPull represents the existence of image on fake node, which means IsImagePresent call will return true here. Then the test case with want:latest pull it again even it is existing.

@lavalamp
Copy link
Member

LGTM

lavalamp added a commit that referenced this pull request Nov 15, 2014
If the image with :latest tag specified in spec, pull even PullIfNotPresent is set.
@lavalamp lavalamp merged commit e84ba3c into kubernetes:master Nov 15, 2014
@lavalamp
Copy link
Member

@brendandburns Hopefully this addresses your concerns.

@brendandburns
Copy link
Contributor

Does Docker automatically add ":latest" to images with no version?

@dchen1107
Copy link
Member Author

@brendandburns Docker won't. Instead dockertool/docker.go does; otherwise, all versions will be pulled by docker, and container startup latency will be increased dramatically. With this PR, you can think like we have two stages on an image pulling: 1) decide if pull based on policy, which is addressed in this PR 2) if yes on 1), always pull with latest one, which is implemented in dockertool.

@lavalamp
Copy link
Member

Yes, but the thing that matters here is whether people listed :latest in their pod. It's good to be in the habit of specifying the version anyway, I suppose?

Now I'm less sure.

@bgrant0607
Copy link
Member

I understand this was done to mitigate #2360, but this is really, really confusing. We should not be overriding policies set by the user. We started down the wrong path with #1458, and we're just digging the hole deeper and deeper.

We need a function that looks at a PodSpec and sets the default value if it is not set. This would ensure that we wouldn't override what the user specified, and would enable the user to easily inspect the policy we were actually applying. In that case, we could set the policy intelligently in this way: PullIfNotPresent, unless the image has the latest tag, in which case we set it to PullAlways. If we added a PullEvery{seconds}, we could default to something like PullEvery{14400} (4 hours).

Since Kubelet also will take Pods from other sources (e.g., files) in addition to from the apiserver, it should just call the same validation/conversion code on those as the apiserver does.

/cc @thockin

@dchen1107
Copy link
Member Author

@brendandburns if ":latest" is not specified, docker pull will download the images with all tags, but docker run will automatically append ":latest" tag to run. The recent version of docker should have ":latest" automatically append to both pull and run.

@bgrant0607 Yes, I agreed with you. In my previous version of this PR, I mentioned the same issue. @lavalamp and I briefly discussed this very topic, the problem is that there is no way for me to put it in helper.go since we need to inspect ContainerSpec itself. At the end, we thought we are going to unify the default setting separately later, including PullPolicy, RestartPolicy, etc., let' s handle them together later.

@lavalamp
Copy link
Member

Yeah after more thought over the weekend I independently came to @bgrant0607's conclusion. What we're doing is too ad-hoc. I'm not sure I like any other options, either, though.

Maybe we should focus more on nerfing pullalways/ifnotpresant until we figure out the best expression in the API.

@smarterclayton
Copy link
Contributor

As a note, this change really burns us when trying to test in local environments. I'm really in favor of yanking this - I don't think latest should override pullIfNotPresent

@brendandburns
Copy link
Contributor

It should only have overridden the default if no explicit value was
present. If there is an explicit value present, we shouldn't overwrite,
regardless of the image spec.

--brendan

On Mon, Jan 12, 2015 at 1:40 PM, Clayton Coleman notifications@github.com
wrote:

As a note, this change really burns us when trying to test in local
environments. I'm really in favor of yanking this - I don't think latest
should override pullIfNotPresent


Reply to this email directly or view it on GitHub
#2388 (comment)
.

@brendandburns
Copy link
Contributor

to be clear: this is a bug if it's not the case.

On Mon, Jan 12, 2015 at 1:50 PM, Brendan Burns bburns@google.com wrote:

It should only have overridden the default if no explicit value was
present. If there is an explicit value present, we shouldn't overwrite,
regardless of the image spec.

--brendan

On Mon, Jan 12, 2015 at 1:40 PM, Clayton Coleman <notifications@github.com

wrote:

As a note, this change really burns us when trying to test in local
environments. I'm really in favor of yanking this - I don't think latest
should override pullIfNotPresent


Reply to this email directly or view it on GitHub
#2388 (comment)
.

@dchen1107
Copy link
Member Author

@brendanburns What you described here is exact opposite of what we implemented here. When the user asks for latest of image with PullIfNotPresent (which is default policy), we treat it as Always. It is our policy choice, not a bug. But it is arguable if it is a good policy or not.

@smarterclayton I am ok to remove this, but before we do it, can I understand your use case more?

@smarterclayton
Copy link
Contributor

Our use case is doing test and development on Kubernetes (and things that run on Kubernetes that run in containers) is that we simultaneously want to expose our images as Docker Hub images ("openshift/docker-registry") but test them locally against non-master. We can mutate our references to not be latest, but latest isn't any more special than any other tag.

If the user says "pullIfNotPresent" and we "pullAlways", that sounds like a bug (a user certainly wouldn't expect it). Otherwise, we shouldn't allow someone to specify pullIfNotPresent. And forcing users who want that behavior to use different tag names is a bad idea, because now we're enforcing a certain pattern on how users use tags in repositories they don't control.

----- Original Message -----

@brendanburns What you described here is exact opposite of what we
implemented here. When the user asks for latest of image with
PullIfNotPresent (which is default policy), we treat it as Always. It is our
policy choice, not a bug. But it is arguable if it is a good policy or not.

@smarterclayton I am ok to remove this, but before we do it, can I understand
your use case more?


Reply to this email directly or view it on GitHub:
#2388 (comment)

@brendandburns
Copy link
Contributor

To be clear, I wanted to identify the cases:

In this container, Pull Policy is set to "PullAlways"
{
...
"image": "foo:latest"
// No image pull policy specified
...
}

In these containers, Pull Policy is unchanged
{
...
"image": "foo"
// No Image pull policy specified
...
}

{
...
"image": "foo:some-other-version"
// No Image pull policy specified
...
}

{
...
"imagePullPolicy": ""
...
}

Hope that helps.
--brendan

On Mon, Jan 12, 2015 at 2:06 PM, Clayton Coleman notifications@github.com
wrote:

Our use case is doing test and development on Kubernetes (and things that
run on Kubernetes that run in containers) is that we simultaneously want to
expose our images as Docker Hub images ("openshift/docker-registry") but
test them locally against non-master. We can mutate our references to not
be latest, but latest isn't any more special than any other tag.

If the user says "pullIfNotPresent" and we "pullAlways", that sounds like
a bug (a user certainly wouldn't expect it). Otherwise, we shouldn't allow
someone to specify pullIfNotPresent. And forcing users who want that
behavior to use different tag names is a bad idea, because now we're
enforcing a certain pattern on how users use tags in repositories they
don't control.

----- Original Message -----

@brendanburns What you described here is exact opposite of what we
implemented here. When the user asks for latest of image with
PullIfNotPresent (which is default policy), we treat it as Always. It is
our
policy choice, not a bug. But it is arguable if it is a good policy or
not.

@smarterclayton I am ok to remove this, but before we do it, can I
understand
your use case more?


Reply to this email directly or view it on GitHub:

#2388 (comment)


Reply to this email directly or view it on GitHub
#2388 (comment)
.

@smarterclayton
Copy link
Contributor

----- Original Message -----

To be clear, I wanted to identify the cases:

In this container, Pull Policy is set to "PullAlways"
{
...
"image": "foo:latest"
// No image pull policy specified
...
}

In these containers, Pull Policy is unchanged
{
...
"image": "foo"
// No Image pull policy specified
...
}

{
...
"image": "foo:some-other-version"
// No Image pull policy specified
...
}

{
...
"imagePullPolicy": ""
...
}

Right - this is the case which today is "broken" - in that the value the REST object contains (pullIfPresent) is ignored and the pull policy is converted to pull always when doesn't contain a tag.

@dchen1107
Copy link
Member Author

Yes, the latest use case is broken on purpose to mitigate #2360 and continue supporting ContainerVM users. If I remembered correctly, PullPolicy's default setting implementation is different from other default setting, and we were not convergent on which way is the right way. Meanwhile, the current approach of PullPolicy cannot have image_name:tag easily. I think now we are convergent on how to setting defaults, and kubelet start to have validation too. Will send PR to fix the issue.

@dchen1107
Copy link
Member Author

@brendandburns @smarterclayton @thockin

I were wrong. #2587 is not merged yet and we are not convergent on how to set defaults here.

@bgrant0607
Copy link
Member

#2587 hasn't been merged yet, but I think we have converged on the approach we want to take. We just need something to push it to completion.

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.

None yet

5 participants