Skip to content
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

Merged
merged 3 commits into from
Jun 21, 2021
Merged

Conversation

ellistarn
Copy link
Contributor

@ellistarn ellistarn commented Jun 15, 2021

Issue #, if available:

Description of changes:

  • Users may specify subnets using node.k8s.aws/subnet-name: dns-compliant-name
  • Users may specify subnets using node.k8s.aws/subnet-tag-key: kubernetes-label-compliant-tag-key-name
  • Added a bunch of validation and tests

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ellistarn ellistarn changed the title [WIP] Support for Subnets specification/override [WIP][AWAITING MERGE #447] Support for Subnets specification/override Jun 15, 2021
@ellistarn ellistarn changed the title [WIP][AWAITING MERGE #447] Support for Subnets specification/override Support for Subnets specification/override Jun 15, 2021
njtran
njtran previously requested changes Jun 16, 2021
Copy link
Contributor

@njtran njtran left a 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?

@ellistarn ellistarn changed the title Support for Subnets specification/override [WIP] Support for Subnets specification/override Jun 16, 2021
@ellistarn ellistarn force-pushed the subnets branch 2 times, most recently from 60887fe to 4d50be5 Compare June 16, 2021 23:04
@ellistarn ellistarn force-pushed the subnets branch 4 times, most recently from d44104b to 9e0a438 Compare June 17, 2021 22:26
@ellistarn ellistarn changed the title [WIP] Support for Subnets specification/override Support for Subnets specification/override Jun 17, 2021
@ellistarn ellistarn force-pushed the subnets branch 5 times, most recently from b15ce16 to 0097c90 Compare June 18, 2021 19:39
@ellistarn ellistarn changed the title Support for Subnets specification/override [WIP] Support for Subnets specification/override Jun 18, 2021
@ellistarn ellistarn force-pushed the subnets branch 3 times, most recently from 10add0b to 70b6f27 Compare June 18, 2021 22:52
@ellistarn ellistarn changed the title [WIP] Support for Subnets specification/override Support for Subnets specification/override Jun 18, 2021
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})
Copy link
Contributor

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.

Copy link
Contributor Author

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,
Copy link
Contributor

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.

Copy link
Contributor Author

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) },
Copy link
Contributor

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?

Copy link
Contributor Author

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())
Copy link
Contributor

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?

Copy link
Contributor Author

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about overrides.

Copy link
Contributor

@bwagner5 bwagner5 left a 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
Copy link
Contributor

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) },
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@ellistarn ellistarn merged commit 291e511 into aws:main Jun 21, 2021
@ellistarn ellistarn deleted the subnets branch June 21, 2021 20:04
@akestner akestner linked an issue Jun 28, 2021 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS: Subnet Discovery/Override
4 participants