-
Notifications
You must be signed in to change notification settings - Fork 126
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 filtering logic for a PriorityClass
that the name is prefixed with system-
#108
Add filtering logic for a PriorityClass
that the name is prefixed with system-
#108
Conversation
Hi @196Ikuchil. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
export/export.go
Outdated
// The name of a PriorityClass object cannot be prefixed with `system-`. | ||
// It is reserved by the system and we cannot recreate it. No need to export. | ||
for _, i := range pcs.Items { | ||
if !strings.HasPrefix(i.GetObjectMeta().GetName(), "system-") { |
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.
Is it better to filter out the exact match of system-cluster-critical
and system-node-critical
? In case users create system-xxx
PriorityClass by themselves.
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.
Users cannot create system-xxx
PriorityClasses. So, it looks good.
The name of a PriorityClass object must be a valid DNS subdomain name, and it cannot be prefixed with system-.
https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass
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.
@196Ikuchil
Could you create a function (named like filterPriorityClass
) to filter PriorityClasses and change the logic to use that?
/ok-to-test |
Fixed it👌 |
export/export.go
Outdated
@@ -501,3 +515,8 @@ func (s *Service) applyPods(ctx context.Context, r *ResourcesForImport, eg *util | |||
} | |||
return nil | |||
} | |||
|
|||
// The name of PriorityClass that is prefixed with `system-`, is reserved by the system. | |||
func filterPriorityClass(name string) bool { |
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.
Okay. Rename it to isSystemPriorityClass
. (IMO, I feel a little strange iffilterXX
returns bool.)
Co-authored-by: Kensei Nakada <handbomusic@gmail.com>
Co-authored-by: Kensei Nakada <handbomusic@gmail.com>
Co-authored-by: Kensei Nakada <handbomusic@gmail.com>
@sanposhiho |
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.
Only wording of comments. otherwise looks good.
export/export.go
Outdated
// The name of a PriorityClass object cannot be prefixed with `system-`. | ||
// It is reserved by the system and we cannot recreate it. No need to export. |
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.
Remove these lines (the doc of isSystemPriorityClass
will describe it.)
export/export.go
Outdated
// The name of PriorityClass that is prefixed with `system-`, is reserved by the system and we cannot recreate it. | ||
// Therefore, filter it. |
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.
Remove these lines as well
export/export.go
Outdated
@@ -501,3 +515,10 @@ func (s *Service) applyPods(ctx context.Context, r *ResourcesForImport, eg *util | |||
} | |||
return nil | |||
} | |||
|
|||
// isSystemPriorityClass returns whether the given name of PriorityClass is prefixed with `system-` or not. | |||
// The prefix `system-` is reserved by Kubernetes and cannot be used in the name of PriorityClass. |
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.
Sorry, my wording is not good 😓
// The prefix `system-` is reserved by Kubernetes and cannot be used in the name of PriorityClass. | |
// The prefix `system-` is reserved by Kubernetes and users cannot create PriorityClass that name is prefixed with `system-`. |
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.
@sanposhiho How is this?
The `system-` prefix is reserved by Kubernetes, and users cannot create a PriorityClass with such a name.
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 good 👍
|
||
// isSystemPriorityClass returns whether the given name of PriorityClass is prefixed with `system-` or not. | ||
// The prefix `system-` is reserved by Kubernetes and cannot be used in the name of PriorityClass. | ||
// See: https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass |
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.
// See: https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass | |
// See: https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass | |
// | |
// So, we need to exclude these PriorityClasses when import/export PriorityClasses. |
@sanposhiho |
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.
Thanks!
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 196Ikuchil, sanposhiho 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 |
What type of PR is this?
/kind bug
What this PR does / why we need it:
The
priorityclass
,system-cluster-critical
andsystem-node-critical
, are created automatically, but it can't delete and is unable to modify some fields.The name of PriorityClass that is prefixed with
system-
, is reserved by the system.So, we add filtering logic to
import/export
functions.Which issue(s) this PR fixes:
Fixes #98
Special notes for your reviewer:
https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#how-to-use-priority-and-preemption
/label tide/merge-method-squash
/assign @sanposhiho