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

Bump v1beta1 with a Conversion Webhook for Management Policies #154

Closed
wants to merge 7 commits into from

Conversation

turkenh
Copy link
Collaborator

@turkenh turkenh commented Nov 16, 2023

Description of your changes

WIP to bump Object API from v1alpha1 to v1beta1 with a conversion webhook for migrating spec.managementPolicy to XP runtime's spec.managementPolicies

Fixes: #162

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

WIP

Signed-off-by: Hasan Turken <[email protected]>
Looks like we need to have at least v1beta1 for conversion,
otherwise getting:

invalid: spec.conversion.conversionReviewVersions: Invalid value: []string{"v1alpha2"}: must include at least one of v1, v1beta1

Signed-off-by: Hasan Turken <[email protected]>
@turkenh turkenh requested review from morningspace and removed request for morningspace November 16, 2023 13:50
Copy link
Collaborator

@lsviben lsviben left a comment

Choose a reason for hiding this comment

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

Added a few comments, really like the direction!

Comment on lines +20 to +21
case ObserveCreateUpdate:
dst.Spec.ManagementPolicies = xpv1.ManagementPolicies{xpv1.ManagementActionObserve, xpv1.ManagementActionCreate, xpv1.ManagementActionUpdate}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we include LateInitialize here? What was the default behaviour of ObserveCreateUpdate, did it do some LateInitialization?

Comment on lines +54 to +55
// TODO(turkenh): Should we default to something here instead of erroring out?
return errors.New("unsupported management policy")
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could play it safe and make it observe-only but still it would be good to inform the users somehow that it happened.
I would be ok with erroring out to make it simple

@@ -0,0 +1,21 @@
/*
Copyright 2020 The Crossplane Authors.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Copyright 2020 The Crossplane Authors.
Copyright 2023 The Crossplane Authors.

some other places as well

// Package type metadata.
const (
Group = "kubernetes.crossplane.io"
Version = "v1alpha1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Version = "v1alpha1"
Version = "v1beta1"

Comment on lines +31 to +54
// A ManagementPolicy determines what should happen to the underlying external
// resource when a managed resource is created, updated, deleted, or observed.
// +kubebuilder:validation:Enum=Default;ObserveCreateUpdate;ObserveDelete;Observe
type ManagementPolicy string

const (
// Default means the provider can fully manage the resource.
Default ManagementPolicy = "Default"
// ObserveCreateUpdate means the provider can observe, create, or update
// the resource, but can not delete it.
ObserveCreateUpdate ManagementPolicy = "ObserveCreateUpdate"
// ObserveDelete means the provider can observe or delete the resource, but
// can not create and update it.
ObserveDelete ManagementPolicy = "ObserveDelete"
// Observe means the provider can only observe the resource.
Observe ManagementPolicy = "Observe"

// ObjectActionCreate means to create an Object
ObjectActionCreate ObjectAction = "Create"
// ObjectActionUpdate means to update an Object
ObjectActionUpdate ObjectAction = "Update"
// ObjectActionDelete means to delete an Object
ObjectActionDelete ObjectAction = "Delete"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be removed for v1beta1?

- jsonPath: .metadata.creationTimestamp
name: AGE
type: date
name: v1alpha2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be v1beta1?

@turkenh
Copy link
Collaborator Author

turkenh commented Nov 28, 2023

@lsviben as we discussed offline, please continue with a new PR as it will make things easier.

@turkenh turkenh closed this Nov 28, 2023
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.

Migrate from custom ManagementPolicy to Crossplane native ManagementPolicies
2 participants