Repository navigation
Add safeguards when multiple contexts are available #289
Replies: 11 comments 2 replies
|
I'm facing the same problem and always have to double-check if I use the correct context. Thank you for raising this! I'm actually playing with a new format for displaying a deployment plan. Taking inspiration from the Terraform plan, I want to add modifiers and colours to make it easier to grasp the changes and see if there are destructive ones to review them more carefully. Will share soon what I've got. I hope the new plan will cover your idea 2. Also, I like your idea 3. Maybe the plan should start with printing what cluster/context it will be applied to. Regarding supporting a I'm also thinking of implementing a shell prompt that would display the current uc context. Similar to other prompts for k8s for example:
But unsure if it should be displayed always, or maybe only when there is a Compose file in the current directory. What do you think about this idea? |
|
A TF-style plan should make things clearer. Would the Compose file Having text in the prompt might be a little nice for quality of life (I do this for git branches) but I think it's not compelling as a safety mechanism. It's easy to not pay attention to it. As far as visibility, I'd say only show it if |
Single value sounds more appealing to me. It will essentially be equivalent to setting the How does this sound to you? |
|
I thought of the array option since it may be useful in corporate settings, where services are deployed to multiple environments. But between the better visualization, and those settings being more predisposed to automation, I'm not sure whether or not that's important to optimize for? I do like the simplicity of "context option means the same thing everywhere". That sounds good. |
I think in the case of deploying to different environments, you'd likely want to slightly change the service configurations depending on the environment. Using Compose overrides is a typical solution for this: uc deploy -f compose.yaml -f compose.prod.yamlYou should be able to override the uc deploy --context another-prod -f compose.yaml -f compose.prod.yamlSo accepting one value should still be flexible enough even when deploying to multiple environments. |
|
Agreed. |
|
@spiffytech I've just implemented it and pushed to These are client-side only changes so you should be able to build One thing that is still worth discussing is whether we need to change the context for all commands if there is I'm not sure if the user experience is consistent now when Would you expect |
|
IMO Aside from uniformity, it seems appropriate that specifying a context specifies it for all operations. Setting it for only some operations feels like surprising behavior to me. We don't where the user thinking they've set a holistic context only to discover after the fact that they've performed destructive operations on the wrong cluster. If we did limit the compose field only to deploys, we should name it Now, this brings up a question: how should a user manually select a context when they're in a folder with an Alternately, would we somehow temporarily apply the context override, then switch it back whenever the user comes back to the compose root? Is the user going to understand what's happening, or will they be constantly frustrated by "what?? oh yeah, that's happening again..."? Is a compose field even the best solution? What about keeping state in This would apply only to implicit context ( The warning prompt means the context preference cannot be committed to version control. Since the whole point of the compose file is to move from imperative to declarative, that's a notable con. |
|
Thank you for a very thoughtful reply!
I was thinking that maybe the
Yeah, this sounds reasonable to me. There is another case when working with an app that is deployed to different environments/clusters, e.g. staging and prod. uc deploy -f compose.yaml -f compose.staging.yamlWith using This behaviour feels reasonable to me. So I think Then everything else follows from this.
Isn't that what we discussed above? Or are you talking about switching it even in the config (
Oh, this scares me a bit. It seems we would anyway need to implement the same overrides as Looks like we both agreed that the proposed Then we can see how it works and reevaluate the decision if it brings more trouble than help. |
Color it orange or something and that sounds good to me. Exit code zero or non-zero? Non-zero would make scripts more reliable if they call
Will we strip I'm not sure we can count on users to naturally construct a compose file that's environment-agnostic. Sometimes users make settings default to some env, then have the others import and override that. Good or bad design, we need to be prepared for them to do it and handle that safely.
Re: implicit state: agreed, seems like the compose field is the way to go. All sounds good! Will test when that's ready. |
|
After giving it a bit more thought, I don't really like the edge case with multiple I'm thinking maybe we need to introduce some kind of convention instead of configuration around the compose file usage and naming. For example, load I believe this is similar to the destination convention in Kamal: https://kamal-deploy.org/docs/commands/deploy/ The But then we will have two different flags Maybe just a global
I'm a bit hesitant to do anything beyond what has been implemented for now ( I'm converting this issue to discussion to continue iterating on the ideas. |
Uh oh!
There was an error while loading. Please reload this page.
My services are split between two contexts, and it's easy to accidentally deploy to the wrong one because I didn't remember to
uc ctxbefore deploy.uc deploydoesn't display the active context, and doesn't behave any differently when deploying a new service vs redeploying an existing one.A few of ideas that might help (happy to workshop this):
contextfield in the compose file. Guarantees the right behavior. Requires all deploy machines to give the cluster the same context name.uc deploy: 'this is gonna make a new service, is that what you mean to do?"uc deploywording: "Deployment plan: deploy service [name=foo] to cluster [name=my-cluster]"All reactions