Make NodeReadinessRule spec fields immutable to prevent security issues#164
Open
Priyankasaggu11929 wants to merge 2 commits intokubernetes-sigs:mainfrom
Open
Make NodeReadinessRule spec fields immutable to prevent security issues#164Priyankasaggu11929 wants to merge 2 commits intokubernetes-sigs:mainfrom
Priyankasaggu11929 wants to merge 2 commits intokubernetes-sigs:mainfrom
Conversation
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Priyankasaggu11929 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 |
✅ Deploy Preview for node-readiness-controller ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Member
Author
|
cc: @ajaysundark for review. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently,
NodeReadinessRule.specfields (especiallyspec.taint) are mutable after creation.And so, when these fields are modified in-place, previously managed taints becomes orphaned on nodes selected by the NRR rule.
(please see
Example 1in the testing section to see below case in action)For example, let's say I chnaged the taint effect from
NoScheduletoNoExecute, this will make the NRC controller add a new taint on the node, but without removing the original one (clean up today only happens during NRR rule deletion, not in place updates).So, if a malicious or misconfigured update then reverts the rule back to
NoSchedule, it will leave theNoExecutetaint on the node but the taint will no longer be managed by the NRC controller.This will lead to significant workload disruption (unexpected pod evictions, permanent scheduling failures etc) until these taints are manually removed.
And if we don't make these fields immutable, then that will require NRC controller to track and reconcile previously managed taints (in case of in-place updates), which significantly increase the controller complexity and could introduce potential race conditions.
Proposed Fix
The PR is making the following
NodeReadinessRule.specfields immutable using CRD validation (x-kubernetes-validations):spec.taint.keyspec.taint.valuespec.taint.effectspec.nodeSelectorspec.conditionsThese fields collectively define the identity and scope of the taint managed by the NRC controller.
So, preventing these fields from being modified after creation will ensure that the NRC controller always maintains consistent ownership of the taints it manages.
And If a user indeed needs to change these values, they must delete and recreate the
NodeReadinessRule.Additional, this PR also fixes an issue with
hasTaintBySpecfunction (see the example 2 in the testing section) where taint comparison currently ignores thevaluefield, and thus, causing updates that only changed the taintvalueto be missed during NRC controller reconciliation.Type of Change
/kind bug
/kind api-change
Testing
Example 1
Steps to reproduce the scenario of how mutating the taint effect create an orphaned taint and permanent scheduling failures.
Below are the node events throughout the above testing steps
and
Example 2
Apart from the above immutability issue, currently, the
hasTaintBySpecfunction only checks a taint as a combination of(key+effect)and not(key+effect+value)and so, changing value doesn't trigger NRC controller to reconcile and add a new taint.Because the controller currently considers the following taints as equivalent:
readiness.k8s.io/security-agent-ready=pending:NoSchedulereadiness.k8s.io/security-agent-ready=ready:NoScheduleThis is fixed in the second commt - f8d7b38
Checklist
make testpassesmake test-e2epassesmake lintpassesmake verifypassesDoes this PR introduce a user-facing change?