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

kubeadm: graduate control plane join phase #73452

Merged
merged 1 commit into from
Feb 19, 2019
Merged

kubeadm: graduate control plane join phase #73452

merged 1 commit into from
Feb 19, 2019

Conversation

RA489
Copy link

@RA489 RA489 commented Jan 29, 2019

What this PR does / why we need it:
Graduate control plane join phase

Which issue(s) this PR fixes:
Refs kubernetes/kubeadm#1204

Does this PR introduce a user-facing change?:

NONE
/kind feature

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 29, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @RA489. 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 /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.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Jan 29, 2019
@RA489
Copy link
Author

RA489 commented Jan 29, 2019

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jan 29, 2019
@RA489 RA489 changed the title WIP: kubeadm: graduate control plane join phase kubeadm: graduate control plane join phase Feb 1, 2019
@k8s-ci-robot k8s-ci-robot removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 1, 2019
Copy link
Member

@yagonobre yagonobre left a comment

Choose a reason for hiding this comment

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

Thanks @RA489
/ok-to-test
/priority important-soon

cmd/kubeadm/app/cmd/phases/controlplanejoin.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 5, 2019
Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

i tried reviewing this PR but github is telling me "Sorry, this diff is temporarily unavailable due to heavy server load." :)

the PR about the previous phase is about to merge soon.
please rebase this PR once that is done @RA489 thanks!
#73732

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 7, 2019
@RA489
Copy link
Author

RA489 commented Feb 7, 2019

@neolit123 rebased PTAL

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

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

@RA489, i've added some comments.
this is progressing good.

func NewControlPlaneJoinPhase() workflow.Phase {
return workflow.Phase{
Name: "control-plane-join",
Short: "Prepares the machine to join a control plane.",
Copy link
Member

Choose a reason for hiding this comment

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

Joins a machine as a control plane instance

Copy link
Author

Choose a reason for hiding this comment

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

done

}

// NewControlPlaneJoinPhase creates a kubeadm workflow phase that implements marking the new node as master and update the cluster status
// with information about current node
Copy link
Member

Choose a reason for hiding this comment

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

change to:

NewControlPlaneJoinPhase creates a kubeadm workflow phase that implements joining a machine as a control plane instance

Copy link
Author

Choose a reason for hiding this comment

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

done

Phases: []workflow.Phase{
{
Name: "all",
Short: "Generates all static Pod manifest files",
Copy link
Member

Choose a reason for hiding this comment

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

Joins a machine as a control plane instance

Copy link
Author

Choose a reason for hiding this comment

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

done

},
newControlPlaneJoinSubphase(kubeadmconstants.KubeAPIServer),
newControlPlaneJoinSubphase(kubeadmconstants.KubeControllerManager),
newControlPlaneJoinSubphase(kubeadmconstants.KubeScheduler),
Copy link
Member

Choose a reason for hiding this comment

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

@fabriziopandini are you OK with this ordering of sub-phases or should we create a "control-plane" subphase that holds these 3?

Copy link
Member

Choose a reason for hiding this comment

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

The creation of static manifest should not be part of control-plane-join, because already implemented in the control-plane-prepare phase (as documented in kubernetes/kubeadm#1204).
That means that the three sub phases above can go away toghether with the related code ( runControlPlaneJoinComponentSubphase method, controlPlanePhaseProperties struct, getPhaseDescription method)

Copy link
Author

Choose a reason for hiding this comment

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

@fabriziopandini removed the three subphases and its related codes

}
}

func newMarkControlPlaneSubphases() workflow.Phase {
Copy link
Member

Choose a reason for hiding this comment

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

newMarkControlPlaneSubphase without the s at the end?

Copy link
Author

Choose a reason for hiding this comment

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

done

return workflow.Phase{
Name: "mark-control-plane",
Short: "Mark a node as a control-plane",
Run: runMarkControlPlanePhaseLocal,
Copy link
Member

Choose a reason for hiding this comment

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

try removing Local from the function name.

Copy link
Author

Choose a reason for hiding this comment

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

done

return nil
}

func runMarkControlPlanePhaseLocal(c workflow.RunData) error {
Copy link
Member

Choose a reason for hiding this comment

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

try removing Local from the name here.

Copy link
Author

Choose a reason for hiding this comment

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

done

return workflow.Phase{
Name: controlPlanePhaseProperties[component].name,
Short: controlPlanePhaseProperties[component].short,
Run: runControlPlaneJoinSubphase(component),
Copy link
Member

Choose a reason for hiding this comment

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

rename this to runControlPlaneJoinComponentSubphase

Copy link
Author

Choose a reason for hiding this comment

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

removed because it is already implemented in control-plane-prepare phase

return nil
}

func runControlPlaneJoinSubphase(component string) func(c workflow.RunData) error {
Copy link
Member

Choose a reason for hiding this comment

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

rename this to runControlPlaneJoinComponentSubphase

Copy link
Author

Choose a reason for hiding this comment

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

removed because it is already implemented in control-plane-prepare phase

Copy link
Contributor

@rosti rosti left a comment

Choose a reason for hiding this comment

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

Thanks @RA489 !
This is a huge step in the right direction, but we need to figure a couple of details here.


return nil
// KubeConfigPath returns the path to the kubeconfig file to use for connecting to Kubernetes
func (j *joinData) KubeConfigPath() string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this one? Where is it used?

Copy link
Author

Choose a reason for hiding this comment

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

it is used in the function showControlPlaneJoinCommand in updated PR

return nil
// KubeConfigPath returns the path to the kubeconfig file to use for connecting to Kubernetes
func (j *joinData) KubeConfigPath() string {
j.kubeconfigPath = filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.AdminKubeConfigFileName)
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are going to keep this func, let's at least not reinvent kubeadmconstants.GetAdminKubeConfigPath(). Also, I bet, that this needs to be conditioned and executed only if j.kubeconfigPath is empty.

Copy link
Author

Choose a reason for hiding this comment

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

done

}

// Skip if this is not a control plane
if data.Cfg().ControlPlane == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Now this concerns me kind of indirectly. If I am not mistaken, data.Cfg().ControlPlane is going to be different from nil only if --experimental-control-plane is specified at the command line or it's filled in the config file. Hence, if the is no config file, the UX is going to be a bit odd, because we cannot execute the control-plane-join phase without the above flag at the command line.

The mandatory command line without config file would look something like this:

kubeadm join --experimental-control-plane phase control-plane-join ...

I believe, that we need to fix this.

@fabriziopandini @neolit123 WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is the case, but as @fabriziopandini pointed out this is already taken care by the control plane prepare phase (and needs the flag if no config file is provided).

return errors.New("control-plane-join phase invoked with an invalid data struct")
}

kubeConfigFile := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.AdminKubeConfigFileName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, it's even more complicated than that. The user may supply kubeconfig file in data.Cfg().Discovery.File.KubeConfigPath or via the --discovery-file command line switch. In that case we need to take those into account too.

@neolit123 @fabriziopandini WDYT?

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

@RA489 thanks for this PR!
The overall approach looks fine, but some changes are required before moving on with this effort:

  • creating manifest is out of the scope of this PR/this phases
  • all the code currently in Run should find a new home after refactor

If something is not clear, let me know!

return nil
// KubeConfigPath returns the path to the kubeconfig file to use for connecting to Kubernetes
func (j *joinData) KubeConfigPath() string {
j.kubeconfigPath = filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.AdminKubeConfigFileName)
Copy link
Member

Choose a reason for hiding this comment

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

Might be I'm missing something, but I don't understand why we should manage joinData. kubeconfigPath when this is always set to a constant value...

Copy link
Author

Choose a reason for hiding this comment

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

it is called in showControlPlaneJoinCommand function

Copy link
Author

Choose a reason for hiding this comment

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

might be i am missing something but i need it in showControlPlaneJoinCommand in updated PR

},
newControlPlaneJoinSubphase(kubeadmconstants.KubeAPIServer),
newControlPlaneJoinSubphase(kubeadmconstants.KubeControllerManager),
newControlPlaneJoinSubphase(kubeadmconstants.KubeScheduler),
Copy link
Member

Choose a reason for hiding this comment

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

The creation of static manifest should not be part of control-plane-join, because already implemented in the control-plane-prepare phase (as documented in kubernetes/kubeadm#1204).
That means that the three sub phases above can go away toghether with the related code ( runControlPlaneJoinComponentSubphase method, controlPlanePhaseProperties struct, getPhaseDescription method)

cmd/kubeadm/app/cmd/join.go Show resolved Hide resolved
cmd/kubeadm/app/cmd/join.go Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Feb 12, 2019
@RA489
Copy link
Author

RA489 commented Feb 12, 2019

@fabriziopandini updated the PR PTAL.

@RA489
Copy link
Author

RA489 commented Feb 13, 2019

/test pull-kubernetes-integration
/test pull-kubernetes-e2e-gce-100-performance

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

@RA489 thanks for being so collaborative in addressing comments!
Few nits and one little misunderstanding to be addressed on the management of the final error, and then this is ready for lgtm

cmd/kubeadm/app/cmd/join.go Outdated Show resolved Hide resolved
cmd/kubeadm/app/cmd/join.go Outdated Show resolved Hide resolved
return errors.New("control-plane-join phase invoked with an invalid data struct")
}

kubeConfigFile := filepath.Join(kubeadmconstants.KubernetesDir, kubeadmconstants.AdminKubeConfigFileName)
Copy link
Member

Choose a reason for hiding this comment

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

I was forgetting the addition of the --kubeconfig flag, please change this into
kubeConfigFile := j.KubeConfigFile()
(the same apply to all the other subphases)

@RA489
Copy link
Author

RA489 commented Feb 14, 2019

@fabriziopandini Thanks for reviewing! I will update your suggestions ASAP.

@RA489
Copy link
Author

RA489 commented Feb 15, 2019

/test pull-kubernetes-e2e-gce

@RA489
Copy link
Author

RA489 commented Feb 15, 2019

@fabriziopandini updated the PR as per your suggestion. Please let me know if anything missed incorporating. Thanks!

@k8s-ci-robot k8s-ci-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 Feb 17, 2019
@RA489
Copy link
Author

RA489 commented Feb 18, 2019

/test pull-kubernetes-integration

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

@RA489
I'm trying to test your changes but when I execute kubeadm join I got

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x13d2003]

goroutine 1 [running]:
k8s.io/kubernetes/cmd/kubeadm/app/cmd.NewCmdJoin.func1(0xc0001bef00, 0xc0000aaff0, 0x1, 0x5)
	cmd/kubeadm/app/cmd/join.go:165 +0xc3
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).execute(0xc0001bef00, 0xc0000aafa0, 0x5, 0x5, 0xc0001bef00, 0xc0000aafa0)
	vendor/github.com/spf13/cobra/command.go:760 +0x2cc
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc0003a0280, 0xc0000caa00, 0xc0003a1180, 0xc00012c0a0)
	vendor/github.com/spf13/cobra/command.go:846 +0x2fd
k8s.io/kubernetes/vendor/github.com/spf13/cobra.(*Command).Execute(0xc0003a0280, 0xc00000c010, 0x1904b00)
	vendor/github.com/spf13/cobra/command.go:794 +0x2b
k8s.io/kubernetes/cmd/kubeadm/app.Run(0xc000084180, 0x960)
	cmd/kubeadm/app/kubeadm.go:50 +0x202
main.main()
	cmd/kubeadm/kubeadm.go:29 +0x33

Could you kindly check?

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

@RA489 Looks great!
I have tested both join worker and join control-plane with phases, thank you to all the people who contributed to this effort!

/approve
@neolit123 @ereslibre @rosti could you kindly give final check + lgtm

Copy link
Contributor

@ereslibre ereslibre left a comment

Choose a reason for hiding this comment

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

Thank you! Final nit to keep structs as small as possible with only the attributes they need, and almost ready for LGTM.

cmd/kubeadm/app/cmd/join.go Outdated Show resolved Hide resolved
Copy link
Contributor

@rosti rosti left a comment

Choose a reason for hiding this comment

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

Thanks @RA489 !
We are on the final stretch here.

cmd/kubeadm/app/cmd/phases/join/controlplanejoin.go Outdated Show resolved Hide resolved
cmd/kubeadm/app/cmd/join.go Outdated Show resolved Hide resolved
cmd/kubeadm/app/cmd/join.go Outdated Show resolved Hide resolved
@neolit123
Copy link
Member

@RA489 please address the latest comments and mark the conversations as resolved (there is a button under each one).

if this PR can be merged this week, great, as this will give us more time for auditing.

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 19, 2019
@fabriziopandini
Copy link
Member

fabriziopandini commented Feb 19, 2019

All the comments seems to be addressed!
Let's get this merged and then we will eventually iterate after auditing as suggested by @neolit123
/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 19, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini, RA489

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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. area/kubeadm cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants