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 createAPIServerClient for easier integration with 3rd party … #9423

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 12 additions & 8 deletions cmd/kubelet/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,11 @@ func (s *KubeletServer) Run(_ []string) error {
glog.Warning(err)
}

client, err := s.createAPIServerClient()
var apiclient *client.Client
clientConfig, err := s.CreateAPIServerClientConfig()
if err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

I would change this to

if (err != nil) {
return err
}
apiclient, err = client.New(clientConfig)
...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do

On Tue, Jun 9, 2015 at 12:50 AM, David Oppenheimer <notifications@github.com

wrote:

In cmd/kubelet/app/server.go
#9423 (comment)
:

@@ -253,7 +253,11 @@ func (s *KubeletServer) Run(_ []string) error {
glog.Warning(err)
}

  • client, err := s.createAPIServerClient()
  • var apiclient *client.Client
  • clientConfig, err := s.CreateAPIServerClientConfig()
  • if err == nil {

I would change this to

if (err != nil) {
return err
}
apiclient, err = client.New(clientConfig)
...


Reply to this email directly or view it on GitHub
https://github.com/GoogleCloudPlatform/kubernetes/pull/9423/files#r31982539
.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davidopp pretty sure that change is breaking the tests because it causes Run() to abort when there's no API client configured for the kubelet.

apiclient, err = client.New(clientConfig)
}
if err != nil && len(s.APIServerList) > 0 {
glog.Warningf("No API client: %v", err)
}
Expand Down Expand Up @@ -333,7 +337,7 @@ func (s *KubeletServer) Run(_ []string) error {
EnableServer: s.EnableServer,
EnableDebuggingHandlers: s.EnableDebuggingHandlers,
DockerClient: dockertools.ConnectToDockerOrDie(s.DockerEndpoint),
KubeClient: client,
KubeClient: apiclient,
MasterServiceNamespace: s.MasterServiceNamespace,
VolumePlugins: ProbeVolumePlugins(),
NetworkPlugins: ProbeNetworkPlugins(),
Expand Down Expand Up @@ -453,7 +457,11 @@ func (s *KubeletServer) createClientConfig() (*client.Config, error) {
return clientConfig, nil
}

func (s *KubeletServer) createAPIServerClient() (*client.Client, error) {
// CreateAPIServerClientConfig generates a client.Config from command line flags,
// including api-server-list, via createClientConfig and then injects chaos into
// the configuration via addChaosToClientConfig. This func is exported to support
// integration with third party kubelet extensions (e.g. kubernetes-mesos).
func (s *KubeletServer) CreateAPIServerClientConfig() (*client.Config, error) {
if len(s.APIServerList) < 1 {
return nil, fmt.Errorf("no api servers specified")
}
Expand All @@ -467,11 +475,7 @@ func (s *KubeletServer) createAPIServerClient() (*client.Client, error) {
return nil, err
}
s.addChaosToClientConfig(clientConfig)
client, err := client.New(clientConfig)
if err != nil {
return nil, err
}
return client, nil
return clientConfig, nil
}

// addChaosToClientConfig injects random errors into client connections if configured.
Expand Down