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

Add changes to infrastructure object to contain service endpoints and feature flag added #2078

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

jared-hayes-dev
Copy link

Copy link
Contributor

openshift-ci bot commented Oct 29, 2024

Hello @jared-hayes-dev! Some important instructions when contributing to openshift/api:
API design plays an important part in the user experience of OpenShift and as such API PRs are subject to a high level of scrutiny to ensure they follow our best practices. If you haven't already done so, please review the OpenShift API Conventions and ensure that your proposed changes are compliant. Following these conventions will help expedite the api review process for your PR.

@openshift-ci openshift-ci bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 29, 2024
@openshift-ci openshift-ci bot requested review from deads2k and knobunc October 29, 2024 15:15
@openshift-ci openshift-ci bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 5, 2024
Comment on lines 1523 to 1524
// ServiceEndpoints contains custom endpoints designated to
// override existing defaults of IBM Cloud Services.
Copy link
Contributor

Choose a reason for hiding this comment

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

The godoc on the status version of this field is different, shall we copy it here?

Copy link
Author

Choose a reason for hiding this comment

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

yes, fixed

type IBMCloudPlatformSpec struct {
// ServiceEndpoints contains custom endpoints designated to
// override existing defaults of IBM Cloud Services.
// +listType=atomic
Copy link
Contributor

Choose a reason for hiding this comment

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

Status version is a map type, why would this one be different?

Copy link
Author

Choose a reason for hiding this comment

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

my bad, unintentionally messed that up when playing with some things - fixed

@@ -670,4 +670,10 @@ var (
enableIn(configv1.DevPreviewNoUpgrade, configv1.TechPreviewNoUpgrade).
enhancementPR("https://github.com/openshift/enhancements/pull/1697").
mustRegister()

FeatureGateDyanmicServiceEndpointIBMCloud = newFeatureGate("DyanmicServiceEndpointIBMCloud").
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll want to include an enableIn and add this to DevPreview and TechPreview initially

Copy link
Author

Choose a reason for hiding this comment

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

Added, but just to confirm our goal would be to remove these post-dev as we wouldn't want to keep this feature within dev/tech preview long term.

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct, once this is dev complete and testing in techpreview shows it's stable, you add the configv1.Default featureSet to enabledIn to promote the feature to the default feature set

type IBMCloudPlatformSpec struct {
// serviceEndpoints is a list of custom endpoints which will override the default
// service endpoints of an IBM Cloud service. These endpoints are consumed by
// components within the cluster to reach the respective IBM Cloud Services.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add some description here of what happens when you add values. They get verified and then copied to status by some controller right? And then consumed by?

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 4, 2024
Copy link
Contributor

openshift-ci bot commented Jan 7, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jared-hayes-dev
Once this PR has been reviewed and has the lgtm label, please assign knobunc for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 7, 2025
@jeffnowicki
Copy link

/retest-required

//
// +required
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:XValidation:rule="isURL(self)",message="url must be a valid absolute URL"
// +kubebuilder:validation:Pattern:=`https:\/\/.*(?:\/(api\/)?v\d+\/{0,1})$`
Copy link
Contributor

Choose a reason for hiding this comment

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

This struct is currently used in both spec and status. Ratcheting validation will work in spec, but there's a bug and it's currently not working for status.

There's two things you can do to move forward.

1.) Wait for the bug to be resolved, I'm working on that actively but don't have a timeline, hopefully not long
2.) Create a separate version of this struct for use in the spec with the improved validation

Copy link
Author

Choose a reason for hiding this comment

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

Ok thanks for the heads up. Is there a Jira for this that we could track this bug? And if I am to understand correctly the temporary solution is to duplicate the struct for use within the spec?

Copy link
Contributor

Choose a reason for hiding this comment

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

The PR to fix the status issue is openshift/kubernetes#2167, I'm hoping to have that merged this week, so potentially hold off on making further changes.

The upstream version of the PR has been merged which was the ask from the o/k team prior to merging this version

//
// +required
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:XValidation:rule="isURL(self)",message="url must be a valid absolute URL"
// +kubebuilder:validation:Pattern:=`https:\/\/.*(?:\/(api\/)?v\d+\/{0,1})$`
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest using CEL for these validations instead of a pattern

// +kubebuilder:validation:XValidation:rule="isURL(self)",message="url must be a valid URL, including a scheme"
// +kubebuilder:validation:XValidation:rule="url(self).getScheme() == \"https\"",message="url scheme must be https"
// +kubebuilder:validation:XValidation:rule="url(self).getEscapedPath().matches(\"\/(api\/)?v\d+\/{0,1}\")",message="url path must match /v[0,9]+ or /api/v[0,9]+"

You will also need a maximum length on the string to add these validations, choose something sensible, but long enough, perhaps 256 chars? Perhaps a little more to add some headroom for the path? 300?

Copy link
Author

Choose a reason for hiding this comment

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

Sounds good, 300 chars would work perfectly.

// +listType=map
// +listMapKey=name
// +optional
ServiceEndpoints []IBMCloudServiceEndpoint `json:"serviceEndpoints,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

All lists must have a maximum number of items marker, what is the rough number of items you'd expect to be in this list in the worst case scenario?

Copy link
Author

Choose a reason for hiding this comment

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

We chose to limit the list to 25 - this covers all current uses cases and gives good room for any future additions

Copy link
Contributor

Choose a reason for hiding this comment

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

You've added the limit to status only, add to spec as well please

//
// +required
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:XValidation:rule="isURL(self)",message="url must be a valid absolute URL"
// +kubebuilder:validation:XValidation:rule=`self.matches('https:\/\/.*(?:\/(api\/)?v\d+\/{0,1})$')`,message="Invalid URL pattern for IBM service overrides"
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to use matches, over the URL helpers that I had suggested? In theory this could allow the path to be incorrect
E.g. https://a.b.c/my/malicious/path?pretend_that_i_am=/api/v1 passes your regex right now, but is not your intention.

The URL helpers I mentioned previously will accurately return you the escaped path, which you can then match against, and would avoid this kind of issue

Copy link
Author

Choose a reason for hiding this comment

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

My bad, somehow I misunderstood your comment when I first read it, and missed the portion in which you suggested the exact URL functions. I have updated the field to correctly use them over trying to pattern match the entire field.

// serviceEndpoints is a list of custom endpoints which will override the default
// service endpoints of an IBM Cloud service. These endpoints are consumed by
// components within the cluster to reach the respective IBM Cloud Services.
// Once admitted, the CCCMO will furthger validate the endpoint exists by pinging it
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Once admitted, the CCCMO will furthger validate the endpoint exists by pinging it
// Once admitted, the CCCMO will further validate the endpoint exists by pinging it

Copy link
Author

Choose a reason for hiding this comment

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

Addressed below in rewrite

// service endpoints of an IBM Cloud service. These endpoints are consumed by
// components within the cluster to reach the respective IBM Cloud Services.
// Once admitted, the CCCMO will furthger validate the endpoint exists by pinging it
// before processing using the provided endpoints to updates the platform status
Copy link
Contributor

Choose a reason for hiding this comment

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

This line isn't reading well to me, want to just double check the wording here?

Copy link
Author

@jared-hayes-dev jared-hayes-dev Jan 15, 2025

Choose a reason for hiding this comment

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

Rewritten to hopefully address the confusing portions

// +listType=map
// +listMapKey=name
// +optional
ServiceEndpoints []IBMCloudServiceEndpoint `json:"serviceEndpoints,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

You've added the limit to status only, add to spec as well please

Copy link
Contributor

openshift-ci bot commented Jan 15, 2025

@jared-hayes-dev: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/okd-scos-e2e-aws-ovn 0a95665 link false /test okd-scos-e2e-aws-ovn
ci/prow/verify 0a95665 link true /test verify
ci/prow/e2e-azure 0a95665 link false /test e2e-azure
ci/prow/e2e-aws-serial 0a95665 link true /test e2e-aws-serial
ci/prow/e2e-aws-serial-techpreview 0a95665 link true /test e2e-aws-serial-techpreview

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

Comment on lines +1624 to +1626
// +kubebuilder:validation:XValidation:rule="url(self).getScheme() == \"https\"",message="url scheme must be https"
// +kubebuilder:validation:XValidation:rule="url(self).getEscapedPath().matches(\"\/(api\/)?v\d+\/{0,1}\")",message="url path must match /v[0,9]+ or /api/v[0,9]+"
// +kubebuilder:validation:MaxLength=300
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to make sure that each of these validations is tested, and in particular, also tested with ratcheting, which is new to the test suite.

You can see some examples of adding ratcheting tests in #2142

You'll have to come up with a patch operation (likely a remove on the path to the maxLength, CEL validations etc) that allows you to persist something not allowed by the new validation, and then show through tests that this does not block writes.

Since this field is new in spec, you'll need to write those ratcheting tests only for the status. That's currently not going to ratchet because of the bug linked to those other tests, I'll let you know when they will pass

// within the cluster when trying to reach the IBM Cloud Services that have been
// overriden. The CCCMO reads in the IBMCloudPlatformSpec and validates each
// endpoint is resolvable. Once validated, the cloud config and IBMCloudPlatformStatus
// are updated to reflect the same custom endpoints.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// are updated to reflect the same custom endpoints.
// are updated to reflect the same custom endpoints.
// A maximum of 25 service endpoints are supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants