-
Notifications
You must be signed in to change notification settings - Fork 979
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
Support for Subnets specification/override #454
Conversation
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 you have some merge/rebase conflicts you still need to resolve?
60887fe
to
4d50be5
Compare
d44104b
to
9e0a438
Compare
b15ce16
to
0097c90
Compare
10add0b
to
70b6f27
Compare
OperatingSystem: p.Spec.Constraints.getOperatingSystem(pod), | ||
} | ||
func (c *Constraints) WithLabel(key string, value string) *Constraints { | ||
c.Labels = functional.UnionStringMaps(c.Labels, map[string]string{key: value}) |
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.
Could this also be done with c.Labels[key] = value
?
functional.UnionStringMaps()
works with "last write wins", so it seems like we overwrite an existing entry in c.labels
with either versions, so it might be cleaner just to add it in.
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.
Oopsie, nice call!
ProvisionerNameLabelKey, | ||
ProvisionerNamespaceLabelKey, | ||
ProvisionerPhaseLabel, | ||
ProvisionerTTLKey, |
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 an annotation, so you may not need to check this in labels.
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.
Good catch!
func() error { return f.matchesProvisioner(ctx, &pod, provisioner) }, | ||
func() error { return f.hasSupportedSchedulingConstraints(ctx, &pod) }, | ||
func() error { return f.toleratesTaints(ctx, &pod, provisioner) }, | ||
func() error { return f.withValidConstraints(ctx, &pod, provisioner) }, |
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.
Maybe I'm missing something, but it looks like none of these 5 validation functions and their sub-functions use contexts. Do we need these contexts here?
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.
Knative has a logging construct (logger.FromContext(ctx).Info ...) and other amazing utilities around the ctx object (i.e. reading global configuration values from a configmap).
I had left this in as a best practice for passing contexts around. However, I think this is probably premature, and easy to add as necessary in the future, so I'll rip this out for now. Thanks!
ExpectCreatedWithStatus(c, pod) | ||
ExpectCreated(c, provisioner) | ||
ExpectEventuallyReconciled(c, provisioner) | ||
return ExpectPodExists(c, pod.GetName(), pod.GetNamespace()) |
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.
I like this. It looks much cleaner. I have some quick sanity checks:
- Is it possible for us to
Get
the pod before a node has been provisioned for it? If so, it's possible for this to succeed, but have the following command in tests (ExpectNodeExists
) to fail undesirably. - Additionally, after using this in tests, we check to see if the node exists based on the pod's nodeName. Can we ensure the pod's nodeName will exist before we finish this function?
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.
As long as the reconciliation loop has executed, we're guaranteed that if a node/scheduling decisions would have been made, it's made by the time the reconcile loop is complete.
pkg/test/pods.go
Outdated
func defaults(options PodOptions) *v1.Pod { | ||
// Pod creates a test pod with defaults that can be overriden by PodOptions. | ||
// Overrides are applied in order, with a last write wins semantic. | ||
func Pod(optionss ...PodOptions) *v1.Pod { |
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.
nit: Is this normal? lol. Seems a little weird. Maybe options
-> opts
-> o
?
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 overrides.
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 just one question and a comment typo nit.
func (s *ProvisionerSpec) validate(ctx context.Context) (errs *apis.FieldError) { | ||
return errs.Also( | ||
s.Cluster.validate(ctx).ViaField("cluster"), | ||
// This validation is on the ProvisionerSpec despire the fact that |
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.
nit: s/despire/despite/
func() error { return f.hasSupportedSchedulingConstraints(&pod) }, | ||
func() error { return f.toleratesTaints(&pod, provisioner) }, | ||
func() error { return f.hasSupportedLabels(&pod) }, | ||
func() error { return f.isUnschedulable(ctx, &pod) }, |
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.
Do you need to add ctx to all these? Looks like the only one that uses it is withValidConstraints
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.
Done
Issue #, if available:
Description of changes:
node.k8s.aws/subnet-name: dns-compliant-name
node.k8s.aws/subnet-tag-key: kubernetes-label-compliant-tag-key-name
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.