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

Support granular management policies #495

Merged
merged 7 commits into from
Jul 31, 2023
Merged

Conversation

lsviben
Copy link
Contributor

@lsviben lsviben commented Jul 17, 2023

Description of your changes

ManagementPolicy -> granular ManagementPolicies

Adds support for granular management policies described based on the design.

This is a breaking change for the management policies alpha feature. (ObserveOnly)

The old

spec:
  managmentPolicy: FullControl/ObserveOnly/OrphanOnDelete

is getting replaced by

spec: 
  managementPolicies: ["*", "Observe", "Create", "Update", "LateInitialize", "Delete"]

After applying the updated provider, the spec.managementPolicy field will be removed automatically, and the spec.managementPolicies: ["*"] will be defaulted. This is equivalent to FullControl but for resources using ObserveOnly and OrphanOnDelete the it meanst that the behavior changes.

Suggested migration if needed is to:

  • pause your resources using non-default management policies before upgrading the provider version
  • noting down which ones those are (could be by adding labels managementPolicy: x )
  • upgrading provider version
  • setting desired management policies on the marked ones (those with label managementPolicy)

initProvider

The new upjet version introduces the spec.initProvider field, which can be used to set fields which can replace spec.forProvider fields during resource creation.

In practice, how it works is that spec.initProvider and spec.forProvider are merged before writing the main.tf file, plus based on fields in spec.initProvider which are not in spec.forProvider we calculate a list of fields which are added to the ignore_changes terraform hook, to avoid them being used in updates.

Both new features are only active if the managementPolicy alplha feature flag is enabled.

** NOTE: This PR uses an unmerged branch of upjet, should be merged after it **

Fixes #494

I have:

  • Run make reviewable test to ensure this PR is ready for review.

Running above crashes on my machine :(.

How has this code been tested

The granular policies were tested with crossplane-runtime gmp PR & crossplane/upjet#224. More details in the crossplane-runtime PR.

The initProvider was tested with initProvider upjet PR. More details there

@lsviben
Copy link
Contributor Author

lsviben commented Jul 26, 2023

For some reason the CI lint is failing in the prepare environment step with errors such as:

  Error: /usr/bin/tar: ../../../go/pkg/mod/gomodules.xyz/jsonpatch/v2@v2.2.0/jsonpatch.go: Cannot open: File exists

@lsviben lsviben marked this pull request as ready for review July 26, 2023 09:27
@turkenf
Copy link
Collaborator

turkenf commented Jul 31, 2023

/test-examples="examples/azure/resourcegroup.yaml"

lsviben and others added 7 commits July 31, 2023 19:50
Signed-off-by: lsviben <sviben.lovro@gmail.com>
Signed-off-by: lsviben <sviben.lovro@gmail.com>
Signed-off-by: lsviben <sviben.lovro@gmail.com>
Signed-off-by: lsviben <sviben.lovro@gmail.com>
Signed-off-by: lsviben <sviben.lovro@gmail.com>
Signed-off-by: lsviben <sviben.lovro@gmail.com>
Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
@ulucinar
Copy link
Collaborator

/test-examples="examples/azure/resourcegroup.yaml"

Copy link
Collaborator

@ulucinar ulucinar left a comment

Choose a reason for hiding this comment

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

Thanks @lsviben, lgtm.

Copy link
Collaborator

@turkenf turkenf left a comment

Choose a reason for hiding this comment

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

Thank you @lsviben, LGTM.

@turkenf turkenf merged commit 1ad57f4 into crossplane-contrib:main Jul 31, 2023
8 checks passed
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.

Support granular management policies
3 participants