Skip to content
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

Add rfc for script run stage #4603

Merged
merged 3 commits into from
Dec 26, 2023
Merged

Add rfc for script run stage #4603

merged 3 commits into from
Dec 26, 2023

Conversation

ffjlabo
Copy link
Member

@ffjlabo ffjlabo commented Oct 5, 2023

What this PR does / why we need it:

Which issue(s) this PR fixes:

Part of #4643

Does this PR introduce a user-facing change?:

  • How are users affected by this change:
  • Is this breaking change:
  • How to migrate (if breaking change):

@codecov
Copy link

codecov bot commented Oct 5, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (master@7366b31). Click here to learn what that means.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #4603   +/-   ##
=========================================
  Coverage          ?   29.99%           
=========================================
  Files             ?      221           
  Lines             ?    25937           
  Branches          ?        0           
=========================================
  Hits              ?     7781           
  Misses            ?    17510           
  Partials          ?      646           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>
Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>
@ffjlabo ffjlabo marked this pull request as ready for review October 19, 2023 07:19
@kentakozuka
Copy link
Member

@ffjlabo Will the custom sync be removed after this feature is released?
It seems like this script run stage has all the features that the custom sync has.

@ffjlabo
Copy link
Member Author

ffjlabo commented Oct 24, 2023

@kentakozuka Yes, I think it will be deprecated and removed in the future.
Custom sync is a great way to execute any command. I think it is more useful to execute any command with other stages. But now we can't use custom sync with other stages such as K8S_SYNC because it is a kind of application.
So I proposed the script run stage to execute any command with other stages.

@kentakozuka
Copy link
Member

@ffjlabo 👌

But now we can't use custom sync with other stages such as K8S_SYNC because it is a kind of application.

What do you mean by this? Maybe I miss something 🤔

@ffjlabo
Copy link
Member Author

ffjlabo commented Oct 24, 2023

@kentakozuka

But now we can't use custom sync with other stages such as K8S_SYNC because it is a kind of application.

Oh, I'm sorry. I don't understand about custom sync correctly. custom sync can be used at any other stage. 🙏
https://pipecd.dev/docs-v0.45.x/user-guide/managing-application/customizing-deployment/custom-sync/

But this stage is for sync. In custom sync, the defined command will execute the same command when rollback.

By the script run stage, I want to realize the demand to just execute commands before or after other stages.
If we want to execute when rollback, we can define any command.

@kentakozuka
Copy link
Member

@ffjlabo Thanks! It is clear to me now.
Can you write that the custom sync would be deprecated when the script run stage is implemented?

Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>
@ffjlabo
Copy link
Member Author

ffjlabo commented Oct 24, 2023

@kentakozuka Thank you for your advise! I added it 🙏 5f74cfd

Comment on lines +207 to +208
- It might be better to add `runsOnRollback` on each sync stage if users want to control when rollback.
This is a just idea.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this part, do you mean in case of multiple script_run stages are combined, we should add runsOnRollback to each? And is this runsOnRollback is same as onRollback (the one used in the example above)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khanhtc1202
This means It might be a way to add onRollback to each stage, not to create a new stage.

e.g. K8S_CANARY_ROLLOUT

  pipeline:
    stages:
      - name: K8S_CANARY_ROLLOUT
        with:
          replicas: 10%
          onRollback: "curl -X POST -H 'Content-type: application/json' --data '{"text":"failed to deploy: rollback"}' $SLACK_WEBHOOK_URL"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it come to this place 🤔 And also, how do we combine your idea with the current rollback logic? Do we have any plans for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it come to this place 🤔 And also, how do we combine your idea with the current rollback logic? Do we have any plans for this?

It is a just idea, so I have no idea to realize it 🙇
But I thought it might be more useful to be able to set onRollback on each stages than set a stage to execute any command.

onRollback:
- "curl -X POST -H 'Content-type: application/json' --data '{"text":"failed to deploy: rollback"}' $SLACK_WEBHOOK_URL"
```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some other questions I think we should define before starting:

  • Do we support multi script_run stages combine
  • How the user-defined onRollback be run in case of multi script_run stages combine
  • How the user-defined onRollback be run in combination with the XXX_ROLLBACK stage? I mean, if k8s app is rollbacked and the pipeline contains script_run, how do we perform the rollback process? Should it be XXX_ROLLBACK first then SCRIPT_RUN_ROLLBACK?

Copy link
Member Author

@ffjlabo ffjlabo Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your questions!
I will write about these things on rfc, but in advance, I will write a little bit my opinions on this.

Do we support multi script_run stages combine

Yes, I think so.

How the user-defined onRollback be run in case of multi script_run stages combine

Multi script_run stages can be executed in the order these are set.

How the user-defined onRollback be run in combination with the XXX_ROLLBACK stage? I mean, if k8s app is rollbacked and the pipeline contains script_run, how do we perform the rollback process? Should it be XXX_ROLLBACK first then SCRIPT_RUN_ROLLBACK?

I don't think about it. I will try to check the implementation and propose it 🙇

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Multi script_run stages can be executed in the order these are set.

How about those stages' rollback scripts? Which order should be made, which will we choice? (or neither)

  1. xxx_canary -> script_run -> script_run -> rollback -> script_rollback (merge all script rollback)
  2. xxx_canary -> script_run -> script_run -> rollback -> script_rollback -> script_rollback

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it will be 2. (But I don't know yet it can be realized technically 🙇 )
xxx_canary -> script_run -> script_run -> rollback -> script_rollback -> script_rollback

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be better not to merge rollback scripts because it would be easy to handle or log error when to execute each rollback scripts.

@ffjlabo
Copy link
Member Author

ffjlabo commented Dec 8, 2023

📝 How to prepare tools that we want to use

There are several ways to realize so.

  1. install the tools on the piped container. It might be nice to prepare piped image based on ubuntu

  2. make a custom piped container image in which some tools are installed.

@khanhtc1202
Copy link
Member

@ffjlabo Please refer to this discussion, we noted about this before
#4380

@ffjlabo ffjlabo mentioned this pull request Dec 18, 2023
2 tasks
@ffjlabo
Copy link
Member Author

ffjlabo commented Dec 22, 2023

@khanhtc1202
I implemented the stage as an alpha version. So, I want to merge this PR and work on the rollback implementation. 🙏
#4720

I will describe about the rollback on the original issue and fix the RFC on another PR :)

@t-kikuc t-kikuc self-requested a review December 26, 2023 07:54
Copy link
Member

@t-kikuc t-kikuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

Copy link
Member

@khanhtc1202 khanhtc1202 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you go 🚀

@khanhtc1202 khanhtc1202 merged commit d814680 into master Dec 26, 2023
14 checks passed
@khanhtc1202 khanhtc1202 deleted the add-rfc-script-run-stage branch December 26, 2023 07:56
nnnkkk7 pushed a commit to nnnkkk7/pipecd that referenced this pull request Feb 1, 2024
* Add rfc for script run stage

Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>

* Fix docs

Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>

* Fix document

Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>

---------

Signed-off-by: Yoshiki Fujikane <ffjlabo@gmail.com>
@github-actions github-actions bot mentioned this pull request Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants