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 variable validation to ClusterClass controller, block Cluster reconcile if variables not reconciled #10812

Merged
merged 1 commit into from
Jun 28, 2024

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Jun 28, 2024

What this PR does / why we need it:
Follow-up to #9239

We should also make sure that variables returned by a Runtime Extension are valid

Example conditions when a Runtime Extension returns an invalid variable schema (I think it's especially nice that multi-line strings are rendered correctly)

ClusterClass:

      message: |-
        VariableDiscovery failed: test-patch.variables[kubeadmControlPlaneMaxSurge].schema.openAPIV3Schema.default: Invalid value: "string": rule compile error: compilation failed: ERROR: <input>:1:20: Syntax error: token recognition error at: '= '
         | self == "" || self = ""
         | ...................^
        ERROR: <input>:1:22: Syntax error: extraneous input '""' expecting <EOF>
         | self == "" || self = ""
         | .....................^
      reason: VariableDiscoveryFailed
      severity: Error
      status: "False"
      type: VariablesReconciled

Cluster

      message: 'ClusterClass is not successfully reconciled: status of VariablesReconciled
        condition on ClusterClass must be "True"'
      reason: TopologyReconcileFailed
      severity: Error
      status: "False"
      type: TopologyReconciled

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area PR is missing an area label size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 28, 2024
@sbueringer
Copy link
Member Author

sbueringer commented Jun 28, 2024

/hold
Have to rebase after #10778 is merged to drop the first commit

/assign @fabriziopandini @chrischdi

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 28, 2024
@sbueringer sbueringer added the area/clusterclass Issues or PRs related to clusterclass label Jun 28, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-area PR is missing an area label label Jun 28, 2024
reconcile if variables not reconciled

Signed-off-by: Stefan Büringer buringerst@vmware.com
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-conformance-ci-latest-main
/test pull-cluster-api-e2e-conformance-main
/test pull-cluster-api-e2e-main
/test pull-cluster-api-e2e-mink8s-main
/test pull-cluster-api-e2e-upgrade-1-30-1-31-main

@sbueringer
Copy link
Member Author

/hold cancel
(rebased)

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jun 28, 2024
return ctrl.Result{}, nil
return ctrl.Result{}, errors.Errorf("ClusterClass is not successfully reconciled: ClusterClass.status.observedGeneration must be %d, but is %d", clusterClass.GetGeneration(), clusterClass.Status.ObservedGeneration)
}
if !conditions.Has(clusterClass, clusterv1.ClusterClassVariablesReconciledCondition) ||
Copy link
Member Author

Choose a reason for hiding this comment

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

Realized that the Cluster topology controller was not block in this case.

Previous behavior was enough for inline variables, because with every change of inline variables generation was changed as well.

But if now variables are coming from a RuntimeExtension just checking the generation is not enough anymore

Copy link
Member

Choose a reason for hiding this comment

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

Nice catch!

@@ -916,21 +916,22 @@ func (webhook *Cluster) validateClusterClassExistsAndIsReconciled(ctx context.Co
case apierrors.IsNotFound(clusterClassPollErr):
allWarnings = append(allWarnings,
fmt.Sprintf(
Copy link
Member Author

@sbueringer sbueringer Jun 28, 2024

Choose a reason for hiding this comment

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

Did a bit of manual testing and realized that the warnings should be improved a bit

@fabriziopandini
Copy link
Member

Thank you for improving variable validation, users messages and unit tests!
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 28, 2024
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: de81ae7c9699c66cec7b2ecc2822afee76af1daf

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 28, 2024
@k8s-ci-robot k8s-ci-robot merged commit 132cf04 into kubernetes-sigs:main Jun 28, 2024
26 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.8 milestone Jun 28, 2024
@sbueringer sbueringer deleted the pr-cel-cc-controller branch June 28, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/clusterclass Issues or PRs related to clusterclass cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants