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

Expose clear transients in ecctl #649

Merged
merged 9 commits into from
May 17, 2024
Merged

Conversation

nick-benoit
Copy link
Contributor

@nick-benoit nick-benoit commented May 15, 2024

Description

Exposes new clear_transients field for ecctl for show deployment.

The default value depends on on the value of generate-update-payload in order to facilitate safe usage of the "read - edit - write" loop. If generate-update-payload=true then clear-transients also defaults to true and is false otherwise. If the flag is manually passed then that value takes precedence.

Related Issues

https://elasticco.atlassian.net/browse/CP-4726

Motivation and Context

This change makes reading and writing deployments safer. We ran into this during the last security remediation and almost overwrote someone’s cluster from their most recent snapsho

How Has This Been Tested?

This has been tested by using local build to operate against QA ESS. I have verified that with
--generate-update-payload=true the transient properties are not included (default behavior). If --generate-update-payload=true and --clear-transient=false is explicitly passed then transient properties are included.

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improves code quality but has no user-facing effect)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation

Readiness Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • have added tests to cover my changes
  • All new and existing tests passed

@nick-benoit nick-benoit added the enhancement New feature or request label May 15, 2024
Copy link

@AlexP-Elastic AlexP-Elastic left a comment

Choose a reason for hiding this comment

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

functionally LGTM though someone more familiar (Dominik?) should give it the "binding review" :)

@@ -112,4 +123,5 @@ func initShowFlags() {
showCmd.Flags().BoolP("metadata", "m", false, "Shows the deployment metadata")
showCmd.Flags().BoolP("settings", "s", false, "Shows the deployment settings")
showCmd.Flags().Bool("generate-update-payload", false, "Outputs JSON which can be used as an argument for the --file flag with the update command.")
showCmd.Flags().Bool("clear-transient", false, "Removes the `transient` field in order to make read - edit - write loop safe")

Choose a reason for hiding this comment

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

should the comment explain that its default is true when generate-update-payload is enabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think so. I updated documentation.

@nick-benoit nick-benoit requested a review from gigerdo May 15, 2024 16:43
@nick-benoit nick-benoit marked this pull request as ready for review May 15, 2024 16:46
@nick-benoit nick-benoit requested review from alaudazzi and a team as code owners May 15, 2024 16:46
--plans Shows the deployment plans
--ref-id string Optional deployment kind RefId, if not set, the RefId will be auto-discovered
-s, --settings Shows the deployment settings
--clear-transient transient Removes the transient field in order to make read - edit - write loop safer. The default value of clear-transient depends on the value of `generate-update-payload`. If `generate-update-payload` is true `clear-transient` defaults to true. Otherwise defaults to false.
Copy link
Member

Choose a reason for hiding this comment

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

Looks like some issue with the docs generator: It adds a transient that shouldn't be there --clear-transient transient Removes the

It seems like it is due to `` in the text. Maybe some special syntax 🤔

@@ -192,6 +192,7 @@ func Test_showCmd(t *testing.T) {
Path: "/api/v1/deployments/29337f77410e23ab30e15c280060facf",
Host: api.DefaultMockHost,
Query: url.Values{
"clear_transient": {"true"},
Copy link
Member

Choose a reason for hiding this comment

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

There is another test below succeeds with show flags set where the --clear-transient flag can be added to test that that works as well.

Copy link
Member

@gigerdo gigerdo left a comment

Choose a reason for hiding this comment

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

LGTM, just two comments on a small issue with the docs and maybe a test that could be added

@nick-benoit nick-benoit merged commit c47b9d5 into master May 17, 2024
4 checks passed
@nick-benoit nick-benoit deleted the expose-clear-transients branch May 17, 2024 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants