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

feat: global repo params #3379

Merged
merged 20 commits into from
Jul 7, 2023

Conversation

pseudomorph
Copy link
Contributor

@pseudomorph pseudomorph commented May 5, 2023

what

  • Allow parallel plans/applies to be configured in user config or repocfg, with repocfg taking precedence.
  • Fix behavior of automerge to allow repocfg to take precedence.

why

Would like to be able to configure this parameter server-side to allow fast rollback and not rely on convergence.

tests

Tests added to cover various combinations of setting the three parameters (automerge, parallel_plan, parallel_apply):

  • Set to true globally, but false in repocfg: result false
  • Set to false globally, but true in repocfg: result true
  • Set to true globally, not set in repocfg: result true

The ability to configure parallel plans in usercfg has been used in a production environment for a couple weeks.

references

@pseudomorph pseudomorph requested a review from a team as a code owner May 5, 2023 20:18
@github-actions github-actions bot added docs Documentation go Pull requests that update Go code labels May 5, 2023
@pseudomorph pseudomorph force-pushed the parallel_operation_config branch from 03d8b0b to 4d7f583 Compare May 5, 2023 20:20
Copy link
Member

@GenPage GenPage left a comment

Choose a reason for hiding this comment

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

Makes sense and looks good. However, would it make sense to add test cases for apply repo level parallel plan/apply to project_command_builder_test.go. It seems all the current test cases were just updated to false.

@GenPage GenPage added this to the v0.24.0 milestone May 6, 2023
@pseudomorph pseudomorph requested a review from GenPage May 8, 2023 18:05
GenPage
GenPage previously approved these changes May 10, 2023
Copy link
Member

@GenPage GenPage left a comment

Choose a reason for hiding this comment

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

LGTM @nitrocode @jamengual what do you think

@nitrocode
Copy link
Member

@pseudomorph thank you these changes!

I noticed that the test section above is not filled out. Could you describe there how this was tested ?

Also why would the global server config override the repo config? I'd imaging the repo config would override the server config, no?

jamengual
jamengual previously approved these changes May 10, 2023
@pseudomorph
Copy link
Contributor Author

@nitrocode - No problem!

WRT repo config not overriding global, I was mirroring the behavior of --automerge. However, I'm happy to update this behavior based on what folks think is best.

@nitrocode
Copy link
Member

nitrocode commented May 11, 2023

Before you make any changes, allow me to request the approvers to respond first @jamengual @GenPage . I defer to you folks for the best consistent approach.

I had no idea that the global server flag would override the repo config. I thought it was the other way around.

@jamengual
Copy link
Contributor

jamengual commented May 11, 2023

I agree with @nitrocode the repo.yaml should be able to override the server config flags, we have started to add more config options to the repo.yaml to make it easier to configure atlantis.

@pseudomorph
Copy link
Contributor Author

That order of precedence make most sense to me too. Just wanted to shoot for consistency.

This is what lead me to believe my previous statement: https://github.com/runatlantis/atlantis/blob/main/server/events/automerger.go#L49-L53
https://github.com/runatlantis/atlantis/blob/main/runatlantis.io/docs/automerging.md?plain=1#L10-L11

Shall I open an issue to correct this behavior, or include it here?

@GenPage
Copy link
Member

GenPage commented May 11, 2023

@pseudomorph Please do, we definitely want to be consistent. I'll merge this if there's no other concerns @nitrocode @jamengual

@pseudomorph
Copy link
Contributor Author

👍 I'll update this PR before EOD.

@pseudomorph
Copy link
Contributor Author

Actually, It may take some time, as we need to consider the ternary condition of true, false, or nil at the repoconfig level.

@pseudomorph
Copy link
Contributor Author

Hmm. Seems to me that AutomergeDisabled in the global cfg is a non-functional artifact.

struct: https://github.com/runatlantis/atlantis/blob/main/server/core/config/valid/global_cfg.go#L95
use 1: https://github.com/runatlantis/atlantis/blob/main/server/core/config/valid/global_cfg.go#L362-L377
use 2: https://github.com/runatlantis/atlantis/blob/main/server/core/config/valid/global_cfg.go#L385-L398

It is functional in the command parser.

Would it make sense to remove this, since all configuration possibilities should be covered through the hierarchical usercfg and repoconfig automerge parameters, coupled with the command-level --disable-automerge flag?

@pseudomorph
Copy link
Contributor Author

Actually, this param doesn't seem to be connected to anything in user config.

@pseudomorph pseudomorph changed the title feat: global parallel params feat: global repo params May 12, 2023
@pseudomorph pseudomorph dismissed stale reviews from jamengual and GenPage via 600735c May 12, 2023 18:21
@GenPage
Copy link
Member

GenPage commented May 15, 2023

Re-reviewing this today

@nitrocode
Copy link
Member

@pseudomorph please

  • fill out the tests section of the pr body
  • Besides unit tests, please also confirm that you've tested this in your own environment and how you've tested it

server/core/config/raw/repo_cfg_test.go Show resolved Hide resolved
server/core/config/raw/repo_cfg.go Show resolved Hide resolved
server/events/automerger.go Show resolved Hide resolved
@pseudomorph
Copy link
Contributor Author

I'll try to get this sorted today.

@nitrocode nitrocode added the needs tests Change requires tests label May 22, 2023
@nitrocode nitrocode modified the milestones: v0.24.0, v0.25.0 May 22, 2023
// only automerge if all projects have automerge set; or if global automerge is set and there are no projects.
automerge := c.GlobalAutomerge
if len(projectCmds) > 0 {
for _, prjCmd := range projectCmds {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I suppose the previous condition still holds. All projects would be contained in the same repo, so picking the first one should be sufficient.

@pseudomorph
Copy link
Contributor Author

@GenPage @nitrocode @jamengual - Any thoughts here? This has been running for some time in our production environment.

Copy link
Member

@GenPage GenPage left a comment

Choose a reason for hiding this comment

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

:shipit:

@GenPage GenPage merged commit 76c482b into runatlantis:main Jul 7, 2023
@pseudomorph
Copy link
Contributor Author

Thanks!

ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
ijames-gc pushed a commit to gocardless/atlantis that referenced this pull request Feb 13, 2024
terakoya76 pushed a commit to terakoya76/atlantis that referenced this pull request Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation go Pull requests that update Go code needs tests Change requires tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

automerge param should take priority in repo config feat: configure global parallel param
4 participants