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

Refactor to simplify the hard-traveled path of the KubeletConfiguration object #29216

Merged
merged 3 commits into from
Aug 25, 2016

Conversation

mtaufen
Copy link
Contributor

@mtaufen mtaufen commented Jul 19, 2016

There are two main goals of this PR:

  • Make NewMainKubelet take KubeletConfiguration and KubeletDeps as its only arguments.
  • Finally eliminate the legacy KubeletConfig type.

Why am I doing this?

Long story short, I started adding an endpoint to the Kubelet to display the current config that the Kubelet was running with, and I realized a few things:

  • There were so many transformations to the configuration, in so many different places, before it was used that I wasn't confident the values initially passed in on the KubeletConfiguration would be the correct values to report by the time someone used the endpoint to check on them.
  • Trying to reconstruct a KubeletConfiguration object from a mix of the Kubelet object and the legacy KubeletConfig object would just add to the mess (not to mention maintenance burden), and it would be much easier if we passed the KubeletConfiguration all the way down to where we construct the Kubelet object, and then just store a reference to the KubeletConfiguration object on the Kubelet for later retrieval.
  • My hope is that by eliminating unnecessary internal transformations to the config information, and by consolidating the remaining ones in a single place (NewMainKubelet), we can have a much clearer understanding of what happens to the config before it makes it to the Kubelet object, and also a better ability to report up-to-date information on the status of the Kubelet.

So I started cleaning things up :-).

Discussion points

It was relatively simple to get NewMainKubelet to just take the legacy KubeletConfig as its only argument, because most of its arguments were just passing through KubeletConfig fields or passing information that was generated solely from KubeletConfig fields.

Completely eliminating the legacy KubeletConfig type has been more difficult, because the fields of the KubeletConfiguration do not have a one-to-one relationship with the fields of the KubeletConfig. While I was able to eliminate many of the KubeletConfig fields, I'm starting to get into the nontrivial stuff and I'd like to get a discussion started on what should happen with the remaining fields (pending cherry-picking notwithstanding).

On my kconf-refactor branch, the legacy KubeletConfig object is down to the following 27 fields (from the initial 93). I'd really appreciate any guidance people have on what should happen with these fields.

type KubeletConfig struct {
    Auth                    server.AuthInterface
    AutoDetectCloudProvider bool
    Builder                 KubeletBuilder
    CAdvisorInterface       cadvisor.Interface
    Cloud                   cloudprovider.Interface
    ContainerManager        cm.ContainerManager
    DockerClient            dockertools.DockerInterface
    EventClient             *clientset.Clientset
    Hostname                string
    HostNetworkSources      []string
    HostPIDSources          []string
    HostIPCSources          []string
    KubeClient              *clientset.Clientset
    Mounter                 mount.Interface
    NetworkPlugins          []network.NetworkPlugin
    NodeName                string
    OOMAdjuster             *oom.OOMAdjuster
    OSInterface             kubecontainer.OSInterface
    PodConfig               *config.PodConfig
    Recorder                record.EventRecorder
    Reservation             kubetypes.Reservation
    TLSOptions              *server.TLSOptions
    Writer                  kubeio.Writer
    VolumePlugins           []volume.VolumePlugin
    EvictionConfig          eviction.Config
    ContainerRuntimeOptions []kubecontainer.Option
    Options                 []Option
}

The patterns I've seen so far with respect to eliminating KubeletConfig fields may be of some help:

  • Some fields could just be eliminated, because they were either the same on KubeletConfiguration or just a typecast away from being the same.
  • Some fields from KubeletConfiguration just ended up in substructures of KubeletConfig; it was easy to just remove those substructure fields from KubeletConfig and construct them using local vars in NewMainKubelet instead.
  • Some fields, e.g. Runonce, were able to move into the KubeletConfiguration.

P.S. Part of the way I'm making the transition is by adding an extra KubeletConfiguration argument to functions that originally took a KubeletConfig, and field-by-field, switching those functions over to using information from the KubeletConfiguration. Once the KubeletConfig is gone, I'll remove the KubeletConfig argument, and the transition will be complete.

Final note:
Please try to keep in mind that this is not a general Kubelet cleanup effort, it is just me cleaning things up that are directly in the path of what I'm trying to do. Let's keep this focused on cleanup related to the path that config takes on it's way to the Kubelet.

Release note:

Removed Flags
- Removes the --auth-path flag. This has been deprecated in favor of --kubeconfig for two releases.

This change is Reviewable

@mtaufen mtaufen added the do-not-merge DEPRECATED. Indicates that a PR should not merge. Label can only be manually applied/removed. label Jul 19, 2016
@mtaufen mtaufen added area/kubelet sig/node Categorizes an issue or PR as relevant to SIG Node. labels Jul 19, 2016
@mtaufen
Copy link
Contributor Author

mtaufen commented Jul 19, 2016

cc @vishh @mikedanese @timstclair

@k8s-github-robot k8s-github-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. release-note-label-needed labels Jul 19, 2016
@mtaufen mtaufen assigned mtaufen and vishh and unassigned dchen1107 Jul 19, 2016
@philips
Copy link
Contributor

philips commented Jul 19, 2016

cc @aaronlevy @derekparker @pbx0

@philips
Copy link
Contributor

philips commented Jul 19, 2016

This is part of #27980.

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 20, 2016
@mtaufen mtaufen force-pushed the kconf-refactor branch 4 times, most recently from 118c815 to 0ad2914 Compare July 20, 2016 22:05
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@k8s-bot
Copy link

k8s-bot commented Aug 24, 2016

GCE e2e build/test passed for commit 652024f1912559b207abcb6997edbc2e25162ae4.

@mtaufen
Copy link
Contributor Author

mtaufen commented Aug 24, 2016

@k8s-bot unit test this please

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Aug 25, 2016

GCE e2e build/test passed for commit 652024f1912559b207abcb6997edbc2e25162ae4.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Aug 25, 2016

GCE e2e build/test passed for commit 652024f1912559b207abcb6997edbc2e25162ae4.

@k8s-github-robot
Copy link

@mtaufen PR needs rebase

@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 25, 2016
This refactor removes the legacy KubeletConfig object and adds a new
KubeletDeps object, which contains injected runtime objects and
separates them from static config. It also reduces NewMainKubelet to two
arguments: a KubeletConfiguration and a KubeletDeps.

Some mesos and kubemark code was affected by this change, and has been
modified accordingly.

And a few final notes:

KubeletDeps:
KubeletDeps will be a temporary bin for things we might consider
"injected dependencies", until we have a better dependency injection
story for the Kubelet. We will have to discuss this eventually.

RunOnce:
We will likely not pull new KubeletConfiguration from the API server
when in runonce mode, so it doesn't make sense to make this something
that can be configured centrally. We will leave it as a flag-only option
for now. Additionally, it is increasingly looking like nobody actually uses the
Kubelet's runonce mode anymore, so it may be a candidate for deprecation
and removal.
It has been deprecated for two releases (1.2 and 1.3).
@mtaufen
Copy link
Contributor Author

mtaufen commented Aug 25, 2016

@vishh Bumping priority due to frequent rebases.

@mtaufen mtaufen added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Aug 25, 2016
@k8s-github-robot
Copy link

/lgtm cancel //PR changed after LGTM, removing LGTM. @mtaufen @vishh

@k8s-github-robot k8s-github-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 25, 2016
@vishh
Copy link
Contributor

vishh commented Aug 25, 2016

Ack. There are PRs that are waiting to be rebased on top of this. So bumping priority makes sense.

@vishh vishh added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 25, 2016
@k8s-bot
Copy link

k8s-bot commented Aug 25, 2016

GCE e2e build/test passed for commit 7ae1458.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-bot
Copy link

k8s-bot commented Aug 25, 2016

GCE e2e build/test passed for commit 7ae1458.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit df54a28 into kubernetes:master Aug 25, 2016
@vishh
Copy link
Contributor

vishh commented Aug 25, 2016

skitt added a commit to skitt/kubernetes that referenced this pull request Jul 24, 2024
These are long gone, removed in 2016:
* AuthPath removal: kubernetes#29216
* Flag removal: kubernetes#40048

This removes the remnants from clientcmd, mostly in the commends
describing how the configuration is loaded.

Since getServerIdentificationPartialConfig can no longer fail (it
copies fields from one struct to another), this drops the error
return, along with the error handling in the caller.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
skitt added a commit to skitt/kubernetes that referenced this pull request Jul 24, 2024
These are long gone, removed in 2016:
* AuthPath removal: kubernetes#29216
* Flag removal: kubernetes#40048

This removes the remnants from clientcmd, mostly in the comments
describing how the configuration is loaded.

Since getServerIdentificationPartialConfig can no longer fail (it
copies fields from one struct to another), this drops the error
return, along with the error handling in the caller.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
skitt added a commit to skitt/kubernetes that referenced this pull request Sep 10, 2024
These are long gone, removed in 2016:
* AuthPath removal: kubernetes#29216
* Flag removal: kubernetes#40048

This removes the remnants from clientcmd, mostly in the comments
describing how the configuration is loaded.

Since getServerIdentificationPartialConfig can no longer fail (it
copies fields from one struct to another), this drops the error
return, along with the error handling in the caller.

Signed-off-by: Stephen Kitt <skitt@redhat.com>
k8s-publishing-bot pushed a commit to kubernetes/client-go that referenced this pull request Sep 25, 2024
These are long gone, removed in 2016:
* AuthPath removal: kubernetes/kubernetes#29216
* Flag removal: kubernetes/kubernetes#40048

This removes the remnants from clientcmd, mostly in the comments
describing how the configuration is loaded.

Since getServerIdentificationPartialConfig can no longer fail (it
copies fields from one struct to another), this drops the error
return, along with the error handling in the caller.

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 8a8238ba7f850241de9c5cc4b22fa1a6b6a19480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubelet lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/node Categorizes an issue or PR as relevant to SIG Node. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.