Repository navigation
Fix cross-project deploy: make the target match the local project - #1588
midigofrank wants to merge 2 commits into
Conversation
4597116 to
5b42eff
Compare
Deploying a workspace to a different project now treats every local workflow as a merge candidate, instead of only those changed since the workspace's own last sync. --remove-unmapped sends delete entries for target workflows that don't exist locally.
c41f26d to
54032a0
Compare
josephjclark
left a comment
There was a problem hiding this comment.
I really think something is off here Frank and I'd like to see a rethink. See comments.
I welcome discussion abotu this - let's talk it through and then decide next steps
| '@openfn/project': patch | ||
| --- | ||
|
|
||
| Add `--remove-unmapped` to `project deploy` to delete target workflows that don't exist locally |
There was a problem hiding this comment.
I am pretty sure that --remove-unmapped needs to be true by default, and not exposed to the CLI.
I think the user can bass --workflows to get different behaviour. If a workflow is picked, the local state will apply to the remote (if the workflow does not exist locally, it is removed from the remote). We should support --workflows all. which means "make the target look like the source".
So what I'm looking for is: we have the correct default behaviour built in (dependong on whether the UUID matches), but users can override the behaviour with --workflows if they want to force-push a change
There was a problem hiding this comment.
Agreed. Removed the flag and this changeset. Mirroring is now the default when the UUIDs differ.
| o2.workflow, | ||
| o2.credentials, | ||
| o2.checkout, | ||
| override(o2.removeUnmapped, { |
There was a problem hiding this comment.
I'm not convinced this needs exposing
| const didChannelsChange = channelsChanged(localProject, remoteProject); | ||
| if (!workflowDiffs.length && !didCollectionsChange && !didChannelsChange) { | ||
| // workflows on the target which don't exist locally at all | ||
| const unmappedWorkflows = options.removeUnmapped |
There was a problem hiding this comment.
Hesitant on whether this belongs here. Is there a test that covers it?
I think it's saying: if there's an unmapped workflow that needs removing, then there's something to deploy. Why isn't that covered by the other diff stuff here?
I'd like it to be covered by workflowDiffs.
Worth noting tht adding this unmapped check alongside locally changed is adding quite a lot of complexity. I can hardly follow the code these days and that scares me. It was never meant to get so complicated.
There was a problem hiding this comment.
Removed. When the target is a different project, its workflow ids are added to the merge candidates, so the existing diff reports them as removed and they flow through workflowDiffs like everything else. Covered by the "makes a different project look exactly like the local project" test.
| t.falsy(logger._find('success', /Nothing to deploy/)); | ||
| const added = findWorkflow(TWO_WORKFLOWS_UUID, 'My Workflow'); | ||
| t.is(added.jobs['transform-data'].body, 'fn()'); | ||
| // the target's other workflows are left alone |
There was a problem hiding this comment.
Is this right?
Don't we want the remote to look exactly the same as the local in this case?
When posting to a different UUID, without any extra instruction, I think we're saying "take my local project and make the remote look exactly like it".
That means removing workflow A and B from the remote.
Now, in this PR right now I should be able to do that with --remove-unmapped. But I think we need to have the correct default behavioour first. I want to be really clear on this.
There was a problem hiding this comment.
Yeah, that was asserting the wrong default. Flipped it: the target now ends up with only the local workflows. There's also a new test for the --no-confirm guard.
Drop --remove-unmapped: target-only workflows are removed by default when the target UUID differs, and need --force when there is no confirmation prompt.
|
Thanks Joe, agreed. I've made changes:
One guard I added: mirroring means a cross-project deploy can delete workflows. If that's about to happen and there's no prompt ( I've left |
Short Description
Deploying a workspace to a different project sent none of its workflows. A cross-project deploy now makes the target look exactly like the local project, including removing workflows that only exist on the target.
Fixes OFN-4761, OFN-4762
Implementation Details
findLocallyChangedWorkflows, which compares the workspace with its ownforked_from.remoteProject.diff()reports target-only workflows asremovedinworkflowDiffs, and they are sent asdelete: true.--no-confirm), it stops withREMOVES_WORKFLOWSunless--forceis passed.--dry-runisn't blocked. Interactive runs show the removals in the plan and ask as usual.--forceis still required in that case.@openfn/projectnow exportsWorkflow.QA Notes
--no-confirmwithout--forcethrows and leaves B untouched.--force.--force, because that deploy removes the target's own workflows.--workflowis unchanged: it force-deploys only the named workflows, which must exist locally.--workflow allis not in this PR (see review discussion).deploy.ts.avaruns segfault locally (also on the base commit); every test file passes when run on its own.AI Usage