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

Init container not removed when cronjob is updated #52177

Closed
julia-stripe opened this issue Sep 8, 2017 · 5 comments
Closed

Init container not removed when cronjob is updated #52177

julia-stripe opened this issue Sep 8, 2017 · 5 comments
Labels
area/workload-api/cronjob kind/bug Categorizes issue or PR as related to a bug. sig/apps Categorizes an issue or PR as relevant to SIG Apps.

Comments

@julia-stripe
Copy link
Contributor

julia-stripe commented Sep 8, 2017

Is this a BUG REPORT or FEATURE REQUEST?:

/kind bug

What happened:

I created a cronjob with an init container. This works correctly. I then updated that cronjob (with kubectl apply) to no longer have an init container. This doesn't work -- after updating the cronjob, the init container is still there. (also, there are no error messages)

Strangely, updating the init container works correctly, but removing the init container does not work.

(I'm planning to work on fixing this, but wanted to report an issue first in case anyone has any thoughts)

What you expected to happen:

I expected the init container to be removed.

How to reproduce it (as minimally and precisely as possible):

I created a gist with a script that reproduces this issue at https://gist.github.com/julia-stripe/8b9ad694c9f0208828493f012582c863. Here's how to run the script:

minikube start
git clone https://gist.github.com/8b9ad694c9f0208828493f012582c863.git cronjob-init-containers
cd cronjob-init-containers
bash run.sh

Here's the relevant output:

======= CREATE cronjob with init container
cronjob "minikube-test-job" created
list of init containers: (correct)
[
  {
    "command": [
      "/bin/sh",
      "-c",
      "ls"
    ],
    "image": "gcr.io/google_containers/debian-iptables-amd64:v5",
    "imagePullPolicy": "IfNotPresent",
    "name": "init-myservice",
    "resources": {},
    "terminationMessagePath": "/dev/termination-log",
    "terminationMessagePolicy": "File"
  }
]
======= APPLY cronjob with no init container
cronjob "minikube-test-job" configured
list of init containers: (incorrect, should be empty)
[
  {
    "command": [
      "/bin/sh",
      "-c",
      "ls"
    ],
    "image": "gcr.io/google_containers/debian-iptables-amd64:v5",
    "imagePullPolicy": "IfNotPresent",
    "name": "init-myservice",
    "resources": {},
    "terminationMessagePath": "/dev/termination-log",
    "terminationMessagePolicy": "File"
  }
]

Anything else we need to know?:

a few more notes:

  • modifying the init containers on a cron job also doesn't work
  • modifying the init containers on a cron job does work if you use the legacy pod.beta.kubernetes.io/init-containers annotations, but deleting them still doesn't

I noticed that modifying or deleting the init container on a Job also doesn't work (see this output) for what happens.

I'd expect modifying/deleting the init containers on a Job object to give a validation error, but instead it just silently fails. Overall everything related to changing init containers on jobs / cronjobs seems to not work well.

Environment:

  • Kubernetes version: 1.7.0
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Sep 8, 2017
@k8s-github-robot
Copy link

@julia-stripe
There are no sig labels on this issue. Please add a sig label by:

  1. mentioning a sig: @kubernetes/sig-<group-name>-<group-suffix>
    e.g., @kubernetes/sig-contributor-experience-<group-suffix> to notify the contributor experience sig, OR

  2. specifying the label manually: /sig <label>
    e.g., /sig scalability to apply the sig/scalability label

Note: Method 1 will trigger an email to the group. You can find the group list here and label list here.
The <group-suffix> in the method 1 has to be replaced with one of these: bugs, feature-requests, pr-reviews, test-failures, proposals

@k8s-github-robot k8s-github-robot added the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Sep 8, 2017
@julia-stripe
Copy link
Contributor Author

/sig apps
/area workload-api/cronjob

@k8s-ci-robot k8s-ci-robot added sig/apps Categorizes an issue or PR as relevant to SIG Apps. area/workload-api/cronjob labels Sep 8, 2017
@k8s-github-robot k8s-github-robot removed the needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. label Sep 8, 2017
@liggitt
Copy link
Member

liggitt commented Sep 9, 2017

Probably a dupe of #47264

Fixed by #51816

@liggitt
Copy link
Member

liggitt commented Sep 9, 2017

Do you see the alpha/beta initcontainer annotations on the API object? If so, unless you also change the annotations, changes to the API field will be ignored (see discussion in #47264 (comment) for how we ended up with that behavior)

To remove initcontainers from the cronjob with apply, I think you would need to explicitly null out the initcontainer annotations in your applied object.

@julia-stripe
Copy link
Contributor Author

thanks so much, that workaround works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/workload-api/cronjob kind/bug Categorizes issue or PR as related to a bug. sig/apps Categorizes an issue or PR as relevant to SIG Apps.
Projects
None yet
Development

No branches or pull requests

4 participants