-
Notifications
You must be signed in to change notification settings - Fork 586
NO-ISSUE: Fixes KubeletConfig API doc and adds tests #2651
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
base: master
Are you sure you want to change the base?
NO-ISSUE: Fixes KubeletConfig API doc and adds tests #2651
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
Skipping CI for Draft Pull Request. |
📝 WalkthroughWalkthroughAdds a YAML test suite for the KubeletConfig CRD covering onCreate and onUpdate scenarios (single-field, multi-field, and invalid-value cases). Adds two optional fields to KubeletConfigSpec: AutoSizingReserved (*bool) and LogLevel (*int32) with validation (0–10). Updates generated Swagger/docs and the CRD: clarifies kubeletConfig and machineConfigPoolSelector descriptions, expands logLevel and tlsSecurityProfile descriptions, and adds x-kubernetes-validations to restrict tlsSecurityProfile to Old and Intermediate. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (2.5.0)Error: build linters: unable to load custom analyzer "kubeapilinter": tools/_output/bin/kube-api-linter.so, plugin: not implemented Comment |
|
Hello @ngopalak-redhat! Some important instructions when contributing to openshift/api: |
|
/test all |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
12dcb66 to
8e0b9d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@payload-manifests/crds/0000_80_machine-config_01_kubeletconfigs.crd.yaml`:
- Around line 118-123: The tlsSecurityProfile description in the KubeletConfig
CRD is inconsistent with the schema: the text claims "Only Old and Intermediate
profiles are supported; maximum minTLSVersion is VersionTLS12" while the schema
allows Modern and Custom (and VersionTLS13) because it relies on
configv1.TLSSecurityProfile which has no kubelet-specific restrictions; to fix,
either add explicit validation to the CRD (e.g., CEL rules or a validating
webhook) to reject profile.type values "Modern" and "Custom" and enforce max
minTLSVersion of "VersionTLS12", or update the tlsSecurityProfile description to
accurately reflect that the schema permits Modern and Custom and VersionTLS13 by
referencing configv1.TLSSecurityProfile semantics; locate and change the
tlsSecurityProfile block in the KubeletConfig CRD (symbol: tlsSecurityProfile,
resource: KubeletConfig) and implement one of the two options consistently
(validation rules if you want to forbid Modern/Custom, otherwise update the
descriptive text).
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
⛔ Files ignored due to path filters (2)
machineconfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_kubeletconfigs.crd.yamlis excluded by!**/zz_generated.crd-manifests/*machineconfiguration/v1/zz_generated.featuregated-crd-manifests/kubeletconfigs.machineconfiguration.openshift.io/AAA_ungated.yamlis excluded by!**/zz_generated.featuregated-crd-manifests/**
📒 Files selected for processing (4)
machineconfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yamlmachineconfiguration/v1/types.gomachineconfiguration/v1/zz_generated.swagger_doc_generated.gopayload-manifests/crds/0000_80_machine-config_01_kubeletconfigs.crd.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
- machineconfiguration/v1/types.go
🔇 Additional comments (2)
machineconfiguration/v1/zz_generated.swagger_doc_generated.go (1)
216-223: Docs read well and are consistent with the CRD updates.
The KubeletConfigSpec descriptions are clear and actionable.machineconfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml (1)
1-275: Solid coverage for create/update scenarios.
The matrix of single-field and combined updates looks thorough.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
payload-manifests/crds/0000_80_machine-config_01_kubeletconfigs.crd.yaml
Show resolved
Hide resolved
|
@ngopalak-redhat: This pull request explicitly references no jira issue. DetailsIn response to this:
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. |
...onfiguration/v1/zz_generated.crd-manifests/0000_80_machine-config_01_kubeletconfigs.crd.yaml
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Show resolved
Hide resolved
saschagrunert
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR, I have a bunch of improvements sggested.
Please note that we need to add integration tests for the new validations.
8e0b9d6 to
b52d6d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@machineconfiguration/v1/types.go`:
- Around line 769-774: The CEL XValidation currently permits profiles without an
explicit type and thus allows Modern/Custom via embedded fields; update the
validation on TLSSecurityProfile to require that the type field is present and
equal to either "Old" or "Intermediate" (e.g. change the rule to require
has(self.type) && (self.type == 'Old' || self.type == 'Intermediate')), so
TLSSecurityProfile (the TLSSecurityProfile *configv1.TLSSecurityProfile field)
cannot be set to Modern/Custom without an explicit allowed type.
♻️ Duplicate comments (1)
payload-manifests/crds/0000_80_machine-config_01_kubeletconfigs.crd.yaml (1)
268-271: Keep the CRD validation in sync with the tightened TLS rule.Same concern as in
machineconfiguration/v1/types.go: regenerate this CRD after tightening the CEL rule so missingtypecan’t bypass the restriction.
🧹 Nitpick comments (1)
machineconfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml (1)
173-220: Add a negative case fortlsSecurityProfilewithouttype.This will lock in the stricter validation and prevent bypasses if the object is provided without a
type.🧪 Suggested test case
@@ - name: Should reject tlsSecurityProfile with Custom type initial: | apiVersion: machineconfiguration.openshift.io/v1 kind: KubeletConfig spec: tlsSecurityProfile: type: Custom custom: ciphers: - ECDHE-ECDSA-AES128-GCM-SHA256 minTLSVersion: VersionTLS12 expectedError: "only Old and Intermediate TLS profiles are supported for kubelet" + - name: Should reject tlsSecurityProfile without type + initial: | + apiVersion: machineconfiguration.openshift.io/v1 + kind: KubeletConfig + spec: + tlsSecurityProfile: + custom: + ciphers: + - ECDHE-ECDSA-AES128-GCM-SHA256 + minTLSVersion: VersionTLS12 + expectedError: "only Old and Intermediate TLS profiles are supported for kubelet"
b52d6d1 to
cb2ecfa
Compare
@saschagrunert I made the code changes as suggested. I also added the validations and tests to machineconfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml. Are these the integration tests you were referring to? |
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Outdated
Show resolved
Hide resolved
...nfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml
Show resolved
Hide resolved
| // +kubebuilder:validation:Minimum=0 | ||
| // +kubebuilder:validation:Maximum=10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we have not enforced this in production clusters? Hm, then it would be a breaking change and we can't apply it now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good opportunity to fix this. I understand it's a breaking change from an API perspective, but it's already validated in the MCO: https://github.com/openshift/machine-config-operator/blob/main/pkg/controller/kubelet-config/helpers.go#L353
We are effectively adding a first line of defense to reject values < 0 or > 10 immediately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, but two things to clarify:
- Does the cluster degrade when this is being enforced now and users put in an invalid value?
- Let's compare the scenarios of putting an invalid value in a running cluster. What are the error messages and is the user feedback now more or less useful?
8fc15e8 to
33fda82
Compare
33fda82 to
1b89d6b
Compare
|
@saschagrunert Thanks for the review. I have addressed your comments. Could you take another look? I also replied to the specific discussion here: #2651 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are still many redundant CRUD tests part of this file, which don't validate anything.
- Lines 7-37: autoSizingReserved true/false/omitted - Basic CRUD, no validation
- Lines 40-50: logLevel = 4 - Not a boundary, no validation value
- Lines 51-59: logLevel omitted - Redundant
- Lines 98-136: machineConfigPoolSelector worker/master/omitted - No validation logic
- Lines 139-160: kubeletConfig with maxPods/omitted - Basic CRUD
- Lines 163-188: tlsSecurityProfile Old/Intermediate - Redundant (both valid values, no validation difference)
- Lines 220-228: tlsSecurityProfile omitted - Redundant
- Lines 231-253: Combined fields - No validation logic
- Lines 257-272: Update autoSizingReserved - No validation logic
- Lines 275-288: Remove logLevel - Redundant with onCreate omit
Tests that should be kept (validation logic):
- Lines 60-70: logLevel = 0 (minimum boundary)
- Lines 71-81: logLevel = 10 (maximum boundary)
- Lines 82-88: logLevel = -1 (reject below min)
- Lines 89-95: logLevel = 11 (reject above max)
- Lines 189-196: tlsSecurityProfile Modern (CEL XValidation rejection)
- Lines 197-208: tlsSecurityProfile Custom (CEL XValidation rejection)
- Lines 209-219: tlsSecurityProfile without type (CEL XValidation rejection)
|
@ngopalak-redhat: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. |
This PR improves the documentation for the KubeletConfigSpec API to make it more accurate and user-friendly.
Fixes the doc: https://docs.redhat.com/en/documentation/openshift_container_platform/4.20/html/machine_apis/kubeletconfig-machineconfiguration-openshift-io-v1#spec-4
It also adds test coverage similar to the pattern established in #2370.
AutoSizingReserved will default to true from 4.21 onwards. The default value and the description was not documented until now.
Why is this a breaking change?
Test Coverage
Created test file: machineconfiguration/v1/tests/kubeletconfigs.machineconfiguration.openshift.io/KubeletConfigSpec.yaml