Introduce script run stage
What would you like to be added: follow: https://github.com/pipe-cd/pipecd/issues/1089
implement stage to execute any command.
- [x] alpha: only for sync https://github.com/pipe-cd/pipecd/pull/4720
- [ ] beta: include thinking for rollback
- [x] k8s https://github.com/pipe-cd/pipecd/pull/4743
- [ ] ecs
- [ ] cloud run
- [ ] lambda
- [ ] terraform
Why is this needed:
TODO
- [x] just executing commands not considered about rollbacking https://github.com/pipe-cd/pipecd/pull/4603
- [x] consider about rollback (fix rfc and implement)
- [ ] consider about managing commands
📝
- SCRIPT_RUN stage can cancel on the Web UI
- commands are executed in the dir for current application
refer the implementation https://github.com/pipe-cd/pipecd/blob/master/pkg/app/piped/executor/customsync/customsync.go#L55
📝 Share my current opinion when to rollback :)
Behavior during rollback of SCRIPT_RUN
- Execute the command to rollback SCRIPT_RUN to the point where the deployment was canceled or failed.
- When there are multiple SCRIPT_RUN stages to be rolled back, they are executed in the same order as SCRIPT_RUN on the pipeline.
For example, consider when deployment proceeds in the following order from 1 to 7.
1. K8S_CANARY_ROLLOUT
2. WAIT
3. SCRIPT_RUN
4. K8S_PRIMARY_ROLLOUT
5. SCRIPT_RUN
6. K8S_CANARY_CLEAN
7. SCRIPT_RUN
Then
- If 4 is canceled or fails while running, only SCRIPT_RUN of 3 will be rolled back.
- If 6 is canceled or fails while running, only SCRIPT_RUNs 3 and 5 will be rolled back.
How to realize it
We can choose 2 ways to realize the rollback.
- execute command on ROLLBACK stage
- execute command on another stage e.g. ROLLBACK_SCRIPTRUN
@ffjlabo I want to vote for (2) We're going to have a plugin for each platform, in such case, each platform ROLLBACK stage implementation would be run/implemented by the plugin author. At the time the plugin is implemented, there would be no way for them to notice that the ROLLBACK stage has to be called the ROLLBACK_SCRIPTRUN. For simplicity, ROLLBACK stage for the platform should only focus on ROLLBACK for platform, ROLLBACK_SCRIPTRUN should be implemented by SCRIPTRUN executor.
Another way to think is, if we treat this SCRIPT_RUN as a plugin for piped, then it should provide its ROLLBACK, not rely on other stages/platform ROLLBACK.
Thank you for your opinion :) I got it! I will try it 👍 At first I will consider how to execute the rollback for each stage because currently, the rollback is for each application kind.
Currently, k8s only. I will apply it to other kind of apps.
📝 It might be nice to have the option to ignore the failure on the stage.
for ECS app request: https://github.com/pipe-cd/pipecd/issues/4813
Related issue: https://github.com/pipe-cd/pipecd/issues/4814 Context: Users want to use deployment information in script which be run in SCRIPT_RUN stage execution