-
Notifications
You must be signed in to change notification settings - Fork 245
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
feat/nfd-master: configure CR restrictions #1592
feat/nfd-master: configure CR restrictions #1592
Conversation
Welcome @AhmedThresh! |
Hi @AhmedThresh. 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. |
✅ Deploy Preview for kubernetes-sigs-nfd ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
/cc @marquiz |
ping @marquiz |
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 for the update @AhmedThresh
/ok-to-test
46daaca
to
6f271b0
Compare
8d7c72c
to
9e4aa7e
Compare
ping @marquiz. Any more thoughts on this? |
/assign @marquiz |
pkg/nfd-master/nfd-master.go
Outdated
features.Labels = addNsToMapKeys(features.Labels, nfdv1alpha1.FeatureLabelNs) | ||
features := filteredObjs[0].Spec.DeepCopy() | ||
|
||
if m.config.Restrictions.DenyNodeFeatureLabels && !m.isThirdPartyNodeFeature(*filteredObjs[0], nodeName, m.namespace) { |
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 still only affects the 'DisableAutoPrefix` feature gate, not whether the NF labels are skipped or not
pkg/nfd-master/nfd-master.go
Outdated
if m.config.Restrictions.DenyNodeFeatureLabels && !m.isThirdPartyNodeFeature(*filteredObjs[0], nodeName, m.namespace) { | ||
klog.V(2).InfoS("node feature labels are disabled in configuration (restrictions.denyNodeFeatureLabels=true)") | ||
} else { | ||
s.Labels = addNsToMapKeys(s.Labels, nfdv1alpha1.FeatureLabelNs) | ||
} |
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.
Looking at this, I think the whole function could be refactored. The outer loop could be rewritten (and we shouldn't need to if len(filteredObjs) > 0
). For example, something like (haven't tested):
features := &nfdv1alpha1.NodeFeatureSpec{}
for _, o := range filteredObjs {
s := o.Spec.DeepCopy()
if m.config.Restrictions.DenyNodeFeatureLabels && m.isThirdPartyNodeFeature(o, nodeName, m.namespace) {
klog.V(2).InfoS("node feature labels are disabled in configuration (restrictions.denyNodeFeatureLabels=true)")
s.Labels = nil
}
if !nfdfeatures.NFDFeatureGate.Enabled(nfdfeatures.DisableAutoPrefix) && m.config.AutoDefaultNs {
s.Labels = addNsToMapKeys(s.Labels, nfdv1alpha1.FeatureLabelNs)
}
s.MergeInto(features)
}
return &nfdv1alpha1.NodeFeature{
ObjectMeta: metav1.ObjectMeta{
Name: nodeName,
},
Spec: *features
}, nil
EDIT: code fixed. We don't need this heavy refactoring but could be done (to keep it simpler). WDYT?
EDIT2: maybe we can keep the original optimization features := filteredObjs[0].Spec.DeepCopy()
ff4b343
to
7a8ff18
Compare
By("Verifying node labels from NodeFeature object #6 are not created") | ||
expectedLabels := map[string]k8sLabels{ | ||
"*": { | ||
"e2e.feature.node.kubernetes.io/restricted-label-1": "true", |
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 has been so much devilish details in this feature that it would be good to verify that the non-3rd-party NF labels ARE still created. Either by deploying nfd-worker or faking a NF.
You could also just add a note and we could add it in a separate PR. WDYT?
targetNodeName := nodes[0].Name | ||
Expect(targetNodeName).ToNot(BeEmpty(), "No suitable worker node found") |
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.
How about this?
pkg/nfd-master/nfd-master.go
Outdated
} else { | ||
if !nfdfeatures.NFDFeatureGate.Enabled(nfdfeatures.DisableAutoPrefix) && m.config.AutoDefaultNs { | ||
features.Labels = addNsToMapKeys(features.Labels, nfdv1alpha1.FeatureLabelNs) | ||
} |
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.
Note: the else is not necessary but
} else { | |
if !nfdfeatures.NFDFeatureGate.Enabled(nfdfeatures.DisableAutoPrefix) && m.config.AutoDefaultNs { | |
features.Labels = addNsToMapKeys(features.Labels, nfdv1alpha1.FeatureLabelNs) | |
} | |
if !nfdfeatures.NFDFeatureGate.Enabled(nfdfeatures.DisableAutoPrefix) && m.config.AutoDefaultNs { | |
features.Labels = addNsToMapKeys(features.Labels, nfdv1alpha1.FeatureLabelNs) | |
} |
pkg/nfd-master/nfd-master.go
Outdated
if m.config.Restrictions.DenyNodeFeatureLabels && m.isThirdPartyNodeFeature(*o, nodeName, m.namespace) { | ||
klog.V(2).InfoS("node feature labels are disabled in configuration (restrictions.denyNodeFeatureLabels=true)") | ||
s.Labels = nil | ||
continue |
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.
We shouldn't skip the whole NF, just set labels to nil.
continue |
Why didn't the e2e tests catch this? 🤔 We should have a NFR there to verify that the features are still present. You can also just add a note about this there for now.
7a8ff18
to
75961e2
Compare
ping @marquiz |
|
||
## restrictions | ||
|
||
The following options specify the restrictions that can be applied by the |
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.
One last comment. Should we call this EXPERIMENTAL in this release(?) There have been so many subtle details during the review process that we've certainly missed something 😊 WDYT?
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.
Yes, please. I will create another issue to cover those unseen details. If you have some bullet points in mind you can leave them here.
Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> Signed-off-by: AhmedThresh <ahmed.grati@insat.ucar.tn> Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> Signed-off-by: AhmedThresh <ahmed.grati@insat.ucar.tn> Signed-off-by: AhmedGrati <ahmedgrati1999@gmail.com> Signed-off-by: AhmedThresh <ahmed.grati@insat.ucar.tn>
75961e2
to
28b40c9
Compare
@marquiz PTAL |
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 @TessaIO for this monumental effort with a lot of twists, turns and surprises 💯 🚀 I'm ready to merge this now.
We have some TODO items to improve the e2e-tests and will address those later
I'll let @ArangoGutierrez to take a final look. E.g. check the docs if you understand what we're trying to do here 😜
/assign @ArangoGutierrez
Thanks for your thorough and precise review! 🚀 |
ping @ArangoGutierrez |
kind reminder @ArangoGutierrez @marquiz |
/test all |
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.
/lgtm
LGTM label has been added. Git tree hash: 491d4d21569336c2bdca3d723df02e1d1af61431
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AhmedThresh, ArangoGutierrez, marquiz 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 |
Ach, finally 🚀 |
Resolves #1380
Features implemented:
Result of e2e tests: