Repository navigation
Can't update the image of CronJob with patch_namespaced_cron_job #1039
Description
What happened (please include outputs or screenshots):
I'm creating a deploy in AWS with lambda for set the images in Kubernetes Cluster.
I want set image in CronJob:
Cron:
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
cronjob.batch/analytics-staging-0 */5 * * * * False 0 4m23s 144m
Describe cronjob:
Name: analytics-staging-0
Namespace: staging-app
Labels: app=analytics-staging-0
Annotations: <none>
Schedule: */5 * * * *
Concurrency Policy: Replace
Suspend: False
Successful Job History Limit: 824641908604
Failed Job History Limit: 1
Starting Deadline Seconds: <unset>
Selector: <unset>
Parallelism: 1
Completions: 1
Pod Template:
Labels: <none>
Containers:
analytics-staging-0:
Image: accountid.dkr.ecr.eu-west-1.amazonaws.com/app:latest
Port: <none>
Host Port: <none>
Command:
/opt/app/analytics
Environment:
AWS_REGION: eu-west-1
Mounts: <none>
Volumes: <none>
Last Schedule Time: Tue, 24 Dec 2019 15:20:00 +0100
Active Jobs: analytics-staging-0-1577197200
Python Code:
def set_image_job(image, namespace, name, conn):
api_instance = conn.BatchV1beta1Api()
body = {
"spec": {
"template": {
"spec": {
"containers": [
{
"image": image
}
]
}
}
}
}
try:
response = api_instance.patch_namespaced_cron_job(name, namespace, body, pretty=True)
print(response)
except Exception as e:
print("Exception when calling BatchV2alpha1Api->patch_namespaced_cron_job: %s\n" % e)
if __name__ == "__main__":
conn = get_connection_eks()
eks_resource = EKSResources('staging-app', conn)
jobs = eks_resource.get_cron_jobs()
for item in jobs:
set_image_job('accountid.dkr.ecr.eu-west-1.amazonaws.com/app:latest', 'staging-app',
item, conn)
Note: item = analytics-staging-0
The response is ok, but don't change the image.
Can you help me?
Thanks!
Environment:
- Kubernetes version (
kubectl version):
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.0", GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5", GitTreeState:"clean", BuildDate:"2019-03-25T15:53:57Z", GoVersion:"go1.12.1", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"14+", GitVersion:"v1.14.9-eks-c0eccc", GitCommit:"c0eccca51d7500bb03b2f163dd8d534ffeb2f7a2", GitTreeState:"clean", BuildDate:"2019-12-22T23:14:11Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
- Python version (
python --version)
Python 3.7
Activity
roycaihw commentedon Jan 6, 2020
could you enable the debug switch and share the actual API request and response?
mdgreenwald commentedon Feb 5, 2020
@roycaihw It's not clear how to enable the debug switch (or if its possible) when using the
config.load_incluster_config()helper. Would you mind sharing an example of how to setup configuration and enable debugging. I believe I also may be impacted by this issue.ricardozd commentedon Feb 6, 2020
Finally I used golang for the code :(
roycaihw commentedon Feb 18, 2020
I created #1083 on how to enable debugging. Please share the HTTP request and response if you hit the issue.
mdgreenwald commentedon Feb 18, 2020
Thank you! I do not have time to test this at the moment, but will get to it as soon as I can.
mdgreenwald commentedon Mar 24, 2020
@roycaihw
Thank you again for your previous reply. So I was able to enable debugging on the client. I have attached the error output as well as the content of the patch.
My patch is almost line for line lifted from the kubernetes patch example documentation.
Thank you for your help. Let me know if there is anything else you need me to share.
error.log
patch.txt
mdgreenwald commentedon May 19, 2020
@roycaihw Is this a known issue?
#951
fejta-bot commentedon Aug 17, 2020
Issues go stale after 90d of inactivity.
Mark the issue as fresh with
/remove-lifecycle stale.Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with
/close.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
fejta-bot commentedon Nov 15, 2020
Issues go stale after 90d of inactivity.
Mark the issue as fresh with
/remove-lifecycle stale.Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with
/close.Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale
fejta-bot commentedon Feb 13, 2021
Issues go stale after 90d of inactivity.
Mark the issue as fresh with
/remove-lifecycle stale.Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with
/close.Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle stale
fejta-bot commentedon Mar 16, 2021
Stale issues rot after 30d of inactivity.
Mark the issue as fresh with
/remove-lifecycle rotten.Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with
/close.Send feedback to sig-contributor-experience at kubernetes/community.
/lifecycle rotten
fejta-bot commentedon Apr 15, 2021
Rotten issues close after 30d of inactivity.
Reopen the issue with
/reopen.Mark the issue as fresh with
/remove-lifecycle rotten.Send feedback to sig-contributor-experience at kubernetes/community.
/close
k8s-ci-robot commentedon Apr 15, 2021
@fejta-bot: Closing this issue.
Details
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
CarlQLange commentedon Sep 29, 2022
In case anyone, like me, happened upon this issue for a handy code sample, the actual problem in the initial post is that the
bodyisn't appropriate for aCronJob(rather aDeployment, which is where the code sample came from initially). For aCronJob, you need something like: