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

[Federation] Generate the secret name in kubefed join. #42513

Merged
merged 1 commit into from
May 2, 2017

Conversation

perotinus
Copy link
Contributor

Addresses part of #42324. A follow-up PR will address annotating Federation resources.

Remove the `--secret-name` flag from `kubefed join`, instead generating the secret name arbitrarily.

@k8s-ci-robot
Copy link
Contributor

Hi @perotinus. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with @k8s-bot ok to test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

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. I understand the commands that are listed here.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 4, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Mar 4, 2017
@grodrigues3 grodrigues3 added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 5, 2017
@perotinus
Copy link
Contributor Author

@madhusudancs Ping? Hopefully this shouldn't be too hard to review.

@madhusudancs
Copy link
Contributor

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 7, 2017
@k8s-github-robot k8s-github-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 7, 2017
@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 14, 2017
@perotinus
Copy link
Contributor Author

@madhusudancs Can you review this when you get a chance?

One question: since kubefed is now beta, do we need to keep supporting the --secret-name flag?

@madhusudancs
Copy link
Contributor

@perotinus I think deprecation policy's rule #5b applies to our case here since kubefed is an admin-facing CLI element and it's in beta. So we need to mark --secret-name as deprecated in v1.7 and remove it in v1.8. There are some examples for marking flags as deprecated here - https://github.com/kubernetes/kubernetes/blob/master/cmd/kube-apiserver/app/options/options.go and in various other commands.

@madhusudancs
Copy link
Contributor

@k8s-bot ok to test

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 28, 2017
@madhusudancs
Copy link
Contributor

@perotinus mostly minor nits. Please ping me once they are addressed.


Reviewed 4 of 4 files at r1.
Review status: all files reviewed at latest revision, 5 unresolved discussions, some commit checks failed.


federation/pkg/kubefed/join.go, line 80 at r1 (raw file):

func (o *joinFederationOptions) Bind(flags *pflag.FlagSet) {
	flags.StringVar(&o.clusterContext, "cluster-context", "", "Name of the cluster's context in the local kubeconfig. Defaults to cluster name if unspecified.")
	flags.StringVar(&o.secretName, "secret-name", "", "Name of the secret where the cluster's credentials will be stored in the host cluster. This name should be a valid RFC 1035 label. Defaults to cluster name if unspecified.")

Just leaving a note to mark this as deprecated.


federation/pkg/kubefed/join.go, line 125 at r1 (raw file):

	if j.options.secretName == "" {
		j.options.secretName = j.commonOptions.Name
	}

Note to bring it back for the deprecated flag.


federation/pkg/kubefed/join.go, line 137 at r1 (raw file):

		return err
	}
	secretName := v1.SimpleNameGenerator.GenerateName(j.commonOptions.Name)

We generally use a - to separate the prefix from the generated part. It is arguably easier to read the generated name that way. I think it is preferable to do it here too. GenerateName() doesn't do that for us unfortunately, so we should do it ourselves.


federation/pkg/kubefed/join_test.go, line 201 at r1 (raw file):

				}
				// The secret name is generated, so replace it with the test secret name
				got.Spec.SecretRef.Name = testSecretName

Feel free to ignore:

Too implementation dependent, but this is a unit test. So instead check if the <prefix>- matches the cluster name?


federation/pkg/kubefed/join_test.go, line 306 at r1 (raw file):

				}
				// The secret name is generated, so replace it with the test secret name
				got.Name = testSecretName

Same here.


Comments from Reviewable

@perotinus
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 5 unresolved discussions, some commit checks failed.


federation/pkg/kubefed/join.go, line 80 at r1 (raw file):

Previously, madhusudancs (Madhusudan.C.S) wrote…

Just leaving a note to mark this as deprecated.

Done.


federation/pkg/kubefed/join.go, line 125 at r1 (raw file):

Previously, madhusudancs (Madhusudan.C.S) wrote…

Note to bring it back for the deprecated flag.

Done.


federation/pkg/kubefed/join_test.go, line 201 at r1 (raw file):

Previously, madhusudancs (Madhusudan.C.S) wrote…

Feel free to ignore:

Too implementation dependent, but this is a unit test. So instead check if the <prefix>- matches the cluster name?

I've done something similar: I think the key thing that we care about in re the generated secret name is that it's not zero length, so I'm testing that.


Comments from Reviewable

@madhusudancs
Copy link
Contributor

@perotinus I have one open question.


Reviewed 2 of 3 files at r2.
Review status: 3 of 4 files reviewed at latest revision, 3 unresolved discussions.


federation/pkg/kubefed/join.go, line 81 at r2 (raw file):

func (o *joinFederationOptions) Bind(flags *pflag.FlagSet) {
	flags.StringVar(&o.clusterContext, "cluster-context", "", "Name of the cluster's context in the local kubeconfig. Defaults to cluster name if unspecified.")
	flags.StringVar(&o.secretName, "secret-name", "", "Name of the secret where the cluster's credentials will be stored in the host cluster. This name should be a valid RFC 1035 label. Defaults to cluster name if unspecified.")

Can we also say "DEPRECATED" in the string somewhere here? Or is that auto-generated by the flags library?


Comments from Reviewable

@perotinus
Copy link
Contributor Author

Review status: 3 of 4 files reviewed at latest revision, 3 unresolved discussions.


federation/pkg/kubefed/join.go, line 81 at r2 (raw file):

Previously, madhusudancs (Madhusudan.C.S) wrote…

Can we also say "DEPRECATED" in the string somewhere here? Or is that auto-generated by the flags library?

The flags library deals with that:

Flag --secret-name has been deprecated, kubefed now generates a secret name, and this flag will be removed in a future release.


Comments from Reviewable

@madhusudancs
Copy link
Contributor

/approve


Reviewed 1 of 3 files at r2.
Review status: all files reviewed at latest revision, 3 unresolved discussions.


federation/pkg/kubefed/join.go, line 81 at r2 (raw file):

Previously, perotinus (Jonathan MacMillan) wrote…

The flags library deals with that:

Flag --secret-name has been deprecated, kubefed now generates a secret name, and this flag will be removed in a future release.

Awesome!


Comments from Reviewable

@k8s-github-robot k8s-github-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 28, 2017
@madhusudancs
Copy link
Contributor

@k8s-bot pull-kubernetes-federation-e2e-gce test this

1 similar comment
@madhusudancs
Copy link
Contributor

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@madhusudancs
Copy link
Contributor

Review status: all files reviewed at latest revision, 4 unresolved discussions.


federation/cluster/federation-up.sh, line 110 at r2 (raw file):

        --federation-system-namespace=${FEDERATION_NAMESPACE} \
        --host-cluster-context="${HOST_CLUSTER_CONTEXT}" \
        --context="${FEDERATION_KUBE_CONTEXT}" \

@perotinus Federation presubmit failed - https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/42513/pull-kubernetes-federation-e2e-gce/2697/?log#log

Sorry, I wasn't paying attention. But I am so happy that we have presubmits now! Trailing \ should be removed here.


Comments from Reviewable

@perotinus
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 4 unresolved discussions.


federation/cluster/federation-up.sh, line 110 at r2 (raw file):

Previously, madhusudancs (Madhusudan.C.S) wrote…

@perotinus Federation presubmit failed - https://k8s-gubernator.appspot.com/build/kubernetes-jenkins/pr-logs/pull/42513/pull-kubernetes-federation-e2e-gce/2697/?log#log

Sorry, I wasn't paying attention. But I am so happy that we have presubmits now! Trailing \ should be removed here.

D'oh! Fixed.


Comments from Reviewable

@perotinus
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 4 unresolved discussions.


federation/pkg/kubefed/join.go, line 137 at r1 (raw file):

Previously, madhusudancs (Madhusudan.C.S) wrote…

We generally use a - to separate the prefix from the generated part. It is arguably easier to read the generated name that way. I think it is preferable to do it here too. GenerateName() doesn't do that for us unfortunately, so we should do it ourselves.

Done.


federation/pkg/kubefed/join_test.go, line 306 at r1 (raw file):

Previously, madhusudancs (Madhusudan.C.S) wrote…

Same here.

Done.


Comments from Reviewable

@perotinus perotinus force-pushed the generatedsecrets branch from 3120898 to 3eb1db3 Compare May 1, 2017 20:26
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented May 1, 2017

@perotinus: The following test(s) failed:

Test name Commit Details Rerun command
pull-kubernetes-federation-e2e-gce 827e0bba8eda9721a0be7b0baa43fb4f0565b957 link @k8s-bot pull-kubernetes-federation-e2e-gce test this

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@perotinus perotinus force-pushed the generatedsecrets branch from 3eb1db3 to 77e71a8 Compare May 1, 2017 21:05
@perotinus
Copy link
Contributor Author

@madhusudancs Can you rerun the Federation e2e tests when you get a chance?

@madhusudancs
Copy link
Contributor

@k8s-bot pull-kubernetes-federation-e2e-gce test this

1 similar comment
@madhusudancs
Copy link
Contributor

@k8s-bot pull-kubernetes-federation-e2e-gce test this

@madhusudancs
Copy link
Contributor

/lgtm


Reviewed 1 of 1 files at r3.
Review status: all files reviewed at latest revision, 1 unresolved discussion.


Comments from Reviewable

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 2, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: madhusudancs, perotinus

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@k8s-github-robot
Copy link

Automatic merge from submit-queue (batch tested with PRs 45100, 45152, 42513, 44796, 45222)

@k8s-github-robot k8s-github-robot merged commit 0487d38 into kubernetes:master May 2, 2017
@perotinus perotinus deleted the generatedsecrets branch May 10, 2017 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants