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

Provisioner cluster endpoint validation #618

Merged
merged 6 commits into from
Aug 16, 2021

Conversation

JacobGabrielson
Copy link
Contributor

@JacobGabrielson JacobGabrielson commented Aug 14, 2021

Issue, if available:

#600

Description of changes:

Make sure Provisioner.Cluster.Endpoint is a valid absolute URL and at least has a hostname.

Testing: unit test plus example bad input detection in running cluster:

apiVersion: karpenter.sh/v1alpha3
kind: Provisioner
metadata:
  name: default
spec:
  labels:
    node.k8s.aws/launch-template-name: "Karpenter-jacob-karpenter-demo-11759955701874416904"
  cluster:
    name: whatever
    endpoint: lars was here
  ttlSecondsAfterEmpty: 30

Produces expected error from webhook in logs:

karpenter karpenter-webhook-5558ff5745-4st6v webhook 2021-08-14T19:08:18.340Z   ERROR   webhook Failed the resource specific validation {"commit": "4c842c9", "knative.dev/kind": "karpenter.sh/v1alpha3, Kind=Provisioner", "knative.dev/namespace": "", "knative.dev/name": "default", "knative.dev/operation": "UPDATE", "knative.dev/resource": "karpenter.sh/v1alpha3, Resource=pro
visioners", "knative.dev/subresource": "", "knative.dev/userinfo": "{kubernetes-admin heptio-authenticator-aws:741206201142:AROA2ZE2VCM3EKDNAMS6F [system:masters system:authenticated] map[accessKeyId:[ASIA2ZE2VCM3M46XUFLJ] arn:[arn:aws:sts::741206201142:assumed-role/Admin-OneClick/jacob-Isengard] canonicalArn:[arn:aws:iam::741206201142:role/Admin-OneClick] sessionName:[jacob-Isengard]]}", "error": "invalid value: lars was here: spec.cluster.endpoint"}

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

@netlify
Copy link

netlify bot commented Aug 14, 2021

✔️ Deploy Preview for karpenter-docs-prod canceled.

🔨 Explore the source changes: 426409a

🔍 Inspect the deploy log: https://app.netlify.com/sites/karpenter-docs-prod/deploys/6119c1500d02cc00084a866a

@JacobGabrielson JacobGabrielson linked an issue Aug 14, 2021 that may be closed by this pull request
@JacobGabrielson JacobGabrielson added the bug Something isn't working label Aug 14, 2021
@JacobGabrielson JacobGabrielson marked this pull request as ready for review August 14, 2021 19:12
@JacobGabrielson JacobGabrielson changed the title [WIP] Cluster endpoint validation Provisioner cluster endpoint validation Aug 14, 2021
@@ -20,50 +20,77 @@ cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNF
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
cloud.google.com/go/bigquery v1.8.0 h1:PQcPefKFdaIzjQFbiyOgAqyx8q5djaE7x9Sqe712DPA=
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious what caused all these changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know - is it important?

// url.Parse() will accept a lot of input without error; make
// sure it's a real URL
if err != nil || !endpoint.IsAbs() || endpoint.Hostname() == "" {
errs = errs.Also(apis.ErrInvalidValue(c.Endpoint, "endpoint"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you write in a helpful message about what it should be (e.g. a valid uri). IIRC, you can put this message into the .Also()

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

} {
badCluster := cluster
badCluster.Endpoint = endpoint
provisioner.Spec.Cluster = badCluster
Copy link
Contributor

@ellistarn ellistarn Aug 15, 2021

Choose a reason for hiding this comment

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

nit:

provisioner.Spec.Cluster = &ClusterP{
   Endpoint: endpoint
}

or

provisioner.spec.Cluster.Endpoint = endpoint

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 6bfbeaa into aws:main Aug 16, 2021
gfcroft pushed a commit to gfcroft/karpenter-provider-aws that referenced this pull request Nov 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validation for Cluster.Endpoint
2 participants