-
Notifications
You must be signed in to change notification settings - Fork 474
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
Question: Why are functions updated when they are deployed? #484
Comments
Hi Bruno, This is working as designed. Many users deploy the same Docker image over and over without changing its tag, and for that reason we cause an annotation to change "UID" in this case, in order for the function to pull in the newer version. Why are you calling the deploy API multiple times if you're not changing the code? Cheers, Alex |
I chatted to the members team about this and suggested that you may benefit from using the Operator and the CRD, if you have some process that is deploying the same config over and over again. The other thing you may want to do is to use an annotation or a state file to decide whether to deploy again. This behaviour is by design, but there are at least two ways above that you can get what you need. We'd still like to know more about your use-case though as this hasn't been requested before. Alex |
Hi @alexellis, thanks for looking into this! Yeah, I didn't mean to imply this is a bug—I was just saying that it feels a bit strange to me, as I was expecting I understand what my other options are, and thanks for pointing them out, but I'd really like to get away without the complexity of those if at all possible. The main use-case is to have Terraform deploying a function (using a |
I discussed this with @LucasRoesler @stefanprodan @matipan and @martindekov - the feedback was given to you above. From my perspective, I would tend to agree with the team, but I also want faas-netes to suit users of Terraform. Personally I think I would accept a PR for an environment variable called @LucasRoesler / @stefanprodan - would you be OK with us adding this feature for Form3? Alex |
This behavior can currently be overridden by setting the If we don't want to make any code changes, we could document this behavior (and close #229 as won't fix). If we make a change, I think I would prefer to avoid another installation configuration option like this. Especially because I could see wanting to change this behavior on the fly. It seems slightly cleaner to remove the UID generation from faas-netes and let the client control that label. This provides maximum flexibility to the client and integrators. We can maintain this behavior for existing users by generating the UID label in the CLI. |
Thanks for your input Lucas. @bmcstdio please can you try setting a static UID label as suggested by @LucasRoesler ? It sounds like a good balance between changing the code and achieving your goals. Perhaps you can set it to a value by convention like the endpoint name? Alex |
@alexellis i tested this in the faas-cli deploy --gateway localhost:31112 --fprocess=cat -e write_debug=true --label "uid=empty" --image=functions/alpine --name echo-me The resulting function pod had these labels labels:
faas_function: echo-me
pod-template-hash: 94d59cdbb
uid: empty And subsequent calls to deploy with the same values was accepted by the API but did not result in a new pod in k8s. I also re-deployed while updating that TL;DR: the work around works as expected. |
@bmcstdio Once you verify this behavior with the static |
@alexellis @LucasRoesler thank you for looking into this and for your feedback. However, and as I've mentioned, the |
@alexellis and @bmcstdio i just tested this with multiple envvars using faas-cli deploy --gateway localhost:31112 --fprocess=cat -e write_debug=true -e a_env=yes -e b_env=no --label "uid=empty" --image=functions/alpine --name echo-me As @bmcstdio said, after multiple deploys, you can see the deployment be re-created because the env variable order will change. I think env vars are the only remaining issue for this, because it goes from a map in the Sorting the env vars alphabetically seems reasonable to me. |
This issue fixes the non-determinism observed by @LucasRoesler and @bmcstdio which caused Function Pods to be re-created due to the order of environment variables changing in the Deployment and PodSpec. Ref: #484 Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
@LucasRoesler given your comment "Sorting the env vars alphabetically seems reasonable to me." and the hypothesis that this single change is enough to resolve @bmcstdio's issue, I will go ahead with a fix and submit a PR. Alex |
This issue fixes the non-determinism observed by @LucasRoesler and @bmcstdio which caused Function Pods to be re-created due to the order of environment variables changing in the Deployment and PodSpec. Ref: #484 Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
@alexellis I think this can be closed now. |
/close |
Thank you Bruno. Let us know if you need anything. |
Expected Behaviour
Running
faas deploy
multiple times without changing anything doesn't cause a function (and hence its pods) to be re-created.Current Behaviour
Running
faas deploy
multiple times without changing anything causes a function (and hence its pods) to be re-created. This is (in part?) due to the value of theUID
label being changed everytime, as well as to the fact that environment variables are not sorted:https://github.com/openfaas/faas-netes/blob/master/handlers/update.go#L80
https://github.com/openfaas/faas-netes/blob/master/handlers/update.go#L71
Possible Solution
I am not sure what the purpose of the
UID
label is, but maybe it could be removed. If that is not a possibility, then maybe we can provide an option that allows for overriding that value (and hence to keep it constant)? If this is acceptable as a solution, I believe I'll be able to work on a PR.Steps to Reproduce (for bugs)
faas deploy
.faas deploy
again without changing anything.Context
My current thinking is that running
faas deploy
should be as idempotent as possible—meaning it is "safe" to run the command multiple times using the same parameters. This would be useful on CI/CD, for instance.Your Environment
faas-cli version
):docker version
(e.g. Docker 17.0.05 ):kubectl version
MacOS 10.14.5.
N/A.
I am using AWS EKS.
The text was updated successfully, but these errors were encountered: