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

SPLAT-1452: Added New FeatureGate/FeatureSet Aware MaxItems #19

Merged
merged 1 commit into from Apr 29, 2024

Conversation

vr4manta
Copy link

@vr4manta vr4manta commented Apr 1, 2024

SPLAT-1452

Changes

  • Added new FeatureSetAwareMaxItems
  • Added new FeatureGateAwareMaxItems

Blocks

Use Case

This enhancement is being done for the vSphere Multi vCenter feature. The idea is we want to have max vCenter count == 3 initially for Tech Preview. By adding maxItemsAware we will have a way to set Default stay at 1, but for TP / Custom, allow vCenter count to be a max of 3. Also by setting this way with the maxItemsAware, we will be able to have the CRD limit it so all operators do not have to be max count aware (check for 3 vs just checking for feature enabled).

Example of new validation field:

// +openshift:validation:FeatureGateAwareMaxItems:featureGate="",maxItems=1
// +openshift:validation:FeatureGateAwareMaxItems:featureGate=VSphereMultiVCenters,maxItems=3

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 1, 2024
@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 1, 2024

@vr4manta: This pull request references SPLAT-1452 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.16.0" version, but no target version was set.

In response to this:

SPLAT-1452

Changes

  • Added new FeatureSetAwareMaxItems
  • Added new FeatureGateAwareMaxItems

Blocks

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@rvanderp3
Copy link

/lgtm

Copy link

openshift-ci bot commented Apr 1, 2024

@rvanderp3: changing LGTM is restricted to collaborators

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@vr4manta
Copy link
Author

vr4manta commented Apr 1, 2024

/assign @JoelSpeed

@vr4manta
Copy link
Author

vr4manta commented Apr 3, 2024

/assign @deads2k

@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 16, 2024

@vr4manta: This pull request references SPLAT-1452 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.16.0" version, but no target version was set.

In response to this:

SPLAT-1452

Changes

  • Added new FeatureSetAwareMaxItems
  • Added new FeatureGateAwareMaxItems

Blocks

Use Case

This enhancement is being done for the vSphere Multi vCenter feature. The idea is we want to have max vCenter count == 3 initially for Tech Preview. By adding maxItemsAware we will have a way to set Default stay at 1, but for TP / Custom, allow vCenter count to be a max of 3. Also by setting this way with the maxItemsAware, we will be able to have the CRD limit it so all operators do not have to be max count aware (check for 3 vs just checking for feature enabled).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

}

if schema.Type != "array" {
return fmt.Errorf("must apply maxitem to an array")

Choose a reason for hiding this comment

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

Is it maxitem cased in other error messages?

Copy link
Author

@vr4manta vr4manta Apr 26, 2024

Choose a reason for hiding this comment

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

I copied this logic from here:

return fmt.Errorf("must apply maxitem to an array")

They are using the all lowercase for their output. I can change to maxItems to match the actual field name.

Examples of FeatureGateAwere and normal:

Normal:

// +kubebuilder:validation:MaxItems=20

FG Aware

// +openshift:validation:FeatureGateAwareMaxItems:featureGate=VSphereMultiVCenters,featureGateEnabled=false,maxItems=1
// +openshift:validation:FeatureGateAwareMaxItems:featureGate=VSphereMultiVCenters,featureGateEnabled=true,maxItems=3

The base has var start w/ capital, but feature gate aware starts with lower and upper depending. It seems its not case sensitive.

Example:

// +openshift:validation:FeatureGateAwareEnum:featureGate="",enum="";None;IntegratedOAuth

or

// +openshift:validation:FeatureGateAwareXValidation:featureGate=GCPLabelsTags,rule="!has(oldSelf.resourceLabels) && !has(self.resourceLabels) || has(oldSelf.resourceLabels) && has(self.resourceLabels)",message="resourceLabels may only be configured during installation"
// +openshift:validation:FeatureGateAwareXValidation:featureGate=GCPLabelsTags,rule="!has(oldSelf.resourceTags) && !has(self.resourceTags) || has(oldSelf.resourceTags) && has(self.resourceTags)",message="resourceTags may only be configured during installation"

Choose a reason for hiding this comment

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

If you look at how the enum version of this works, the default case is with an empty feature gate, can we copy the same pattern so there's consistency?

I'd also like an example usage of this marker added to the same example APi once this is merged please

Copy link
Author

Choose a reason for hiding this comment

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

So problem with default when I tested it was that it was also firing casuing my value of 3 to get overridden by the 1. Thats why I added the second flag. I can retest this , but I am pretty sure this is what I saw resulting in me adding this new variable.

For the example api, I can add it there. I haven't seen the example before so I will ping you offline about this. Thanks!

Copy link
Author

Choose a reason for hiding this comment

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

Based on our discussion, I've made the changes to follow enum's example. I've confirmed this is looking great. I have pushed the changes.

For the api example, I'll make that change and push w/ my PR at top of this PR (marked as blocker).

@@ -143,6 +149,25 @@ func (m FeatureGateEnum) ApplyToSchema(schema *apiext.JSONSchemaProps) error {
return nil
}

type FeatureGateMaxItems struct {
FeatureGateNames []string `marker:"featureGate"`
FeatureGateEnabled bool `marker:"featureGateEnabled"`

Choose a reason for hiding this comment

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

What's this looking at? Can you provide an example of using this?

I guess this is so you can have one version with the feature gate and one without? Is this how it works for other feature gate aware markers?

Copy link
Author

Choose a reason for hiding this comment

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

The featureGateEnabled was a test i tried. I can remove that one to match the others. For some reason I thought I had copied that from another existing one, but now I am not sure.

Copy link
Author

@vr4manta vr4manta Apr 26, 2024

Choose a reason for hiding this comment

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

Oh I remember now, I needed a way to say if my feature gate is disabled, to do something. See example in comment about syntax above. Also, the PR from blocker section in PR description has usage and outputs to show this logic working.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Apr 29, 2024

@vr4manta: This pull request references SPLAT-1452 which is a valid jira issue.

In response to this:

SPLAT-1452

Changes

  • Added new FeatureSetAwareMaxItems
  • Added new FeatureGateAwareMaxItems

Blocks

Use Case

This enhancement is being done for the vSphere Multi vCenter feature. The idea is we want to have max vCenter count == 3 initially for Tech Preview. By adding maxItemsAware we will have a way to set Default stay at 1, but for TP / Custom, allow vCenter count to be a max of 3. Also by setting this way with the maxItemsAware, we will be able to have the CRD limit it so all operators do not have to be max count aware (check for 3 vs just checking for feature enabled).

Example of new validation field:

// +openshift:validation:FeatureGateAwareMaxItems:featureGate="",maxItems=1
// +openshift:validation:FeatureGateAwareMaxItems:featureGate=VSphereMultiVCenters,maxItems=3

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@JoelSpeed
Copy link

Spoken with @vr4manta, this now is in keeping with the enum version for usage, an example will be added to the o/api examples as well

@JoelSpeed JoelSpeed merged commit 9c16df4 into openshift:master Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.
Projects
None yet
5 participants