prefect icon indicating copy to clipboard operation
prefect copied to clipboard

Ability to not overwrite CLI deployments

Open sti0 opened this issue 2 years ago • 4 comments

First check

  • [X] I added a descriptive title to this issue.
  • [X] I used the GitHub search to find a similar request and didn't find it.
  • [X] I searched the Prefect documentation for this feature.

Prefect Version

2.x

Describe the current behavior

Currently if a deployment gets executed multiple times it overwrites settings done in the UI. This cause empty or maybe wrong schedules because the schedule was set initial by UI or it was changed. Also tags can be deleted and so on.

Describe the proposed behavior

There should be a --overwrite=False flag which then just skips the deployment if it already exists.

Example Use

We like to deploy our flows via CI but won't make a deployment everytime we need to adjust the schedule. This adds additonal overhead (because of our deployment process and guidelines) and may cause in wrong configuration if someone needs to change the schedule by UI and forgot to change it in the deployment specs.

Additional context

No response

sti0 avatar Aug 31 '22 13:08 sti0

Hi @sti0! The ability to load an existing deployment was recently added to the Deployment class, would exposing that flag via the CLI with a --load-existing option handle your use case?

bunchesofdonald avatar Oct 19 '22 14:10 bunchesofdonald

@bunchesofdonald note that new flag actually allows you to disable loading the existing deployment — our default behavior is to load it.

zanieb avatar Oct 19 '22 15:10 zanieb

Oh great point @madkinsz.

bunchesofdonald avatar Oct 19 '22 15:10 bunchesofdonald

@bunchesofdonald I don't think so. The idea behind my request is to not overwrite/execute the deployment again if it already exists. If I understand correctly the current behavior is:

  1. Create a new deployment eg. with tags
  2. Create the deployment again without tags

This results in still having the tags present in the deployment. But I don't think this is handy in CI context because we always execute the same pattern for CI deployments, right? So if a Tag gets added in the UI it will be overriden by the re-deployment. Same for schedule and so on.

sti0 avatar Oct 20 '22 06:10 sti0

@billpalombi this pairs well with previous discussion of "locking" deployments such that they cannot be edited in the UI. A --no-overwrite flag seems reasonable to include on prefect deployment apply.

zanieb avatar Mar 20 '23 21:03 zanieb

@madkinsz To be clear, the --no-overwrite flag would prevent the deployment from being updated by the command if a deployment of the same flow with the same name already exists? If so, I support that.

billpalombi avatar Mar 20 '23 22:03 billpalombi