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

Conversation

jdef
Copy link
Contributor

@jdef jdef commented Jun 8, 2015

…kubelet extensions, e.g. kubernetes-mesos

xref mesosphere/kubernetes-mesos#332
xref #8882 -- this PR is a prerequisite for kubernetes-mesos integration

/cc @davidopp @guenter @bgrant0607 @thockin

@k8s-bot
Copy link

k8s-bot commented Jun 8, 2015

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain to ixdy.

@bgrant0607
Copy link
Member

cc @dchen1107

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'm confused about the change you made starting here. To avoid changing the existing logic, shouldn't it be

if err != nil {
  ...log something...
}
apiclient, err = client.New(clientconfig)
if (err != nil) {
  apiclient = nil
}

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ugh! you're right ... I accidentally blew away my first change for this, and when I re-wrote it I reversed the logic. will remedy ASAP

@jdef
Copy link
Contributor Author

jdef commented Jun 8, 2015

not sure why shippable is failing, can't see the build logs there (shippable just hangs)

@davidopp
Copy link
Member

davidopp commented Jun 8, 2015

Some integration test is failing. I'll re-run shippable to see if it's a flake.

F0608 22:53:13.316182   26960 integration.go:800] FAILED: unexpected endpoints: timed out waiting for the condition
!!! Error in ./hack/test-integration.sh:49
  '"${KUBE_OUTPUT_HOSTBIN}/integration" --v=${LOG_LEVEL} --api-version="$1" --max-concurrency="${KUBE_INTEGRATION_TEST_MAX_CONCURRENCY}"' exited with status 255
Call stack:
  1: ./hack/test-integration.sh:49 runTests(...)
  2: ./hack/test-integration.sh:63 main(...)
Exiting with status 1

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.

@jdef jdef force-pushed the create-api-server-client branch from 634f69c to f87bd39 Compare June 9, 2015 12:32
@davidopp
Copy link
Member

davidopp commented Jun 9, 2015

change looks fine, re-running shippable (was a flake)

@davidopp
Copy link
Member

davidopp commented Jun 9, 2015

I don't know why this is failing shippable but it does not seem to be a flake. The test that is failing is the second test in "script" namely

PATH=$HOME/gopath/bin:./third_party/etcd:$PATH ./hack/test-cmd.sh

Here is the output from the failed run:

tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified

etcd -data-dir /tmp/test-etcd.AeUIwp --bind-addr 127.0.0.1:4001 >/dev/null 2>/dev/null

Waiting for etcd to come up.
+++ [0609 17:47:29] etcd:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100    87  100    87    0     0     68      0  0:00:01  0:00:01 --:--:--    68
{"action":"set","node":{"key":"/_test","value":"","modifiedIndex":3,"createdIndex":3}}
+++ [0609 17:47:31] Running kubectl with no options
kubectl controls the Kubernetes cluster manager.

Find more information at https://github.com/GoogleCloudPlatform/kubernetes.

Usage: 
  kubectl [flags]
  kubectl [command]

Available Commands: 
  get            Display one or many resources
  describe       Show details of a specific resource
  create         Create a resource by filename or stdin
  update         Update a resource by filename or stdin.
  delete         Delete a resource by filename, stdin, resource and ID, or by resources and label selector.
  namespace      SUPERCEDED: Set and view the current Kubernetes namespace
  logs           Print the logs for a container in a pod.
  rolling-update Perform a rolling update of the given ReplicationController.
  scale          Set a new size for a Replication Controller.
  exec           Execute a command in a container.
  port-forward   Forward one or more local ports to a pod.
  proxy          Run a proxy to the Kubernetes API server
  run            Run a particular image on the cluster.
  stop           Gracefully shut down a resource by id or filename.
  expose         Take a replicated application and expose it as Kubernetes Service
  label          Update the labels on a resource
  config         config modifies kubeconfig files
  cluster-info   Display cluster info
  api-versions   Print available API versions.
  version        Print the client and server version information.
  help           Help about any command

Flags:
      --alsologtostderr=false: log to standard error as well as files
      --api-version="": The API version to use when talking to the server
      --certificate-authority="": Path to a cert. file for the certificate authority.
      --client-certificate="": Path to a client key file for TLS.
      --client-key="": Path to a client key file for TLS.
      --cluster="": The name of the kubeconfig cluster to use
      --context="": The name of the kubeconfig context to use
  -h, --help=false: help for kubectl
      --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
      --kubeconfig="": Path to the kubeconfig file to use for CLI requests.
      --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace
      --log-dir=: If non-empty, write log files in this directory
      --log-flush-frequency=5s: Maximum number of seconds between log flushes
      --logtostderr=true: log to standard error instead of files
      --match-server-version=false: Require server version to match client version
      --namespace="": If present, the namespace scope for this CLI request.
      --password="": Password for basic authentication to the API server.
  -s, --server="": The address and port of the Kubernetes API server
      --stderrthreshold=2: logs at or above this threshold go to stderr
      --token="": Bearer token for authentication to the API server.
      --user="": The name of the kubeconfig user to use
      --username="": Username for basic authentication to the API server.
      --v=0: log level for V logs
      --validate=false: If true, use a schema to validate the input before sending it
      --vmodule=: comma-separated list of pattern=N settings for file-filtered logging


Use "kubectl help [command]" for more information about a command.

+++ [0609 17:47:31] Starting kubelet in masterless mode
W0609 17:47:31.259440   21214 server.go:253] failed to set oom_score_adj to -900: write /proc/self/oom_score_adj: permission denied
no api servers specified
!!! [0609 17:47:36] Timed out waiting for http://127.0.0.1:10248/healthz
!!! Error in ./hack/test-cmd.sh:43
  'return 1' exited with status 1
Call stack:
  1: ./hack/test-cmd.sh:43 main(...)
Exiting with status 1

Here is the first part of the output from a run (of a different PR) that passes:

tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified

etcd -data-dir /tmp/test-etcd.BmRWQq --bind-addr 127.0.0.1:4001 >/dev/null 2>/dev/null

Waiting for etcd to come up.
+++ [0609 19:08:38] etcd:
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100    87  100    87    0     0     68      0  0:00:01  0:00:01 --:--:--    68
{"action":"set","node":{"key":"/_test","value":"","modifiedIndex":3,"createdIndex":3}}
+++ [0609 19:08:39] Running kubectl with no options
kubectl controls the Kubernetes cluster manager.

Find more information at https://github.com/GoogleCloudPlatform/kubernetes.

Usage: 
  kubectl [flags]
  kubectl [command]

Available Commands: 
  get            Display one or many resources
  describe       Show details of a specific resource
  create         Create a resource by filename or stdin
  update         Update a resource by filename or stdin.
  delete         Delete a resource by filename, stdin, resource and ID, or by resources and label selector.
  namespace      SUPERCEDED: Set and view the current Kubernetes namespace
  logs           Print the logs for a container in a pod.
  rolling-update Perform a rolling update of the given ReplicationController.
  scale          Set a new size for a Replication Controller.
  exec           Execute a command in a container.
  port-forward   Forward one or more local ports to a pod.
  proxy          Run a proxy to the Kubernetes API server
  run            Run a particular image on the cluster.
  stop           Gracefully shut down a resource by id or filename.
  expose         Take a replicated application and expose it as Kubernetes Service
  label          Update the labels on a resource
  config         config modifies kubeconfig files
  cluster-info   Display cluster info
  api-versions   Print available API versions.
  version        Print the client and server version information.
  help           Help about any command

Flags:
      --alsologtostderr=false: log to standard error as well as files
      --api-version="": The API version to use when talking to the server
      --certificate-authority="": Path to a cert. file for the certificate authority.
      --client-certificate="": Path to a client key file for TLS.
      --client-key="": Path to a client key file for TLS.
      --cluster="": The name of the kubeconfig cluster to use
      --context="": The name of the kubeconfig context to use
  -h, --help=false: help for kubectl
      --insecure-skip-tls-verify=false: If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
      --kubeconfig="": Path to the kubeconfig file to use for CLI requests.
      --log-backtrace-at=:0: when logging hits line file:N, emit a stack trace
      --log-dir=: If non-empty, write log files in this directory
      --log-flush-frequency=5s: Maximum number of seconds between log flushes
      --logtostderr=true: log to standard error instead of files
      --match-server-version=false: Require server version to match client version
      --namespace="": If present, the namespace scope for this CLI request.
      --password="": Password for basic authentication to the API server.
  -s, --server="": The address and port of the Kubernetes API server
      --stderrthreshold=2: logs at or above this threshold go to stderr
      --token="": Bearer token for authentication to the API server.
      --user="": The name of the kubeconfig user to use
      --username="": Username for basic authentication to the API server.
      --v=0: log level for V logs
      --validate=false: If true, use a schema to validate the input before sending it
      --vmodule=: comma-separated list of pattern=N settings for file-filtered logging


Use "kubectl help [command]" for more information about a command.

+++ [0609 19:08:40] Starting kubelet in masterless mode
W0609 19:08:40.174835   21324 server.go:253] failed to set oom_score_adj to -900: write /proc/self/oom_score_adj: permission denied
I0609 19:08:40.175367   21324 manager.go:126] cAdvisor running in container: "/docker/a19f3a853d32848c1ba2ef3f47cd5779fe39cc349c9c828c3dbc9d79c4a912d8"
I0609 19:08:40.176483   21324 fs.go:88] Filesystem partitions: map[/dev/disk/by-label/DOROOT:{mountpoint:/ds major:253 minor:1}]
I0609 19:08:40.239154   21324 machine.go:224] Couldn't collect info from any of the files in "/etc/machine-id,/var/lib/dbus/machine-id"
I0609 19:08:40.239358   21324 manager.go:147] Machine: {NumCores:16 CpuFrequency:2399998 MemoryCapacity:50650255360 MachineID: SystemUUID:847B5603-62B4-43E4-92D9-F11DD1B48A53 BootID:27d64fa5-fd87-43bd-9711-62d923438109 Filesystems:[{Device:/dev/disk/by-label/DOROOT Capacity:507172954112}] DiskMap:map[253:0:{Name:vda Major:253 Minor:0 Size:515396075520 Scheduler:none}] NetworkDevices:[{Name:eth0 MacAddress:02:42:ac:11:09:96 Speed:10000 Mtu:1500}] Topology:[{Id:0 Memory:50650255360 Cores:[{Id:0 Threads:[0] Caches:[]}] Caches:[]} {Id:1 Memory:0 Cores:[{Id:0 Threads:[1] Caches:[]}] Caches:[]} {Id:2 Memory:0 Cores:[{Id:0 Threads:[2] Caches:[]}] Caches:[]} {Id:3 Memory:0 Cores:[{Id:0 Threads:[3] Caches:[]}] Caches:[]} {Id:4 Memory:0 Cores:[{Id:0 Threads:[4] Caches:[]}] Caches:[]} {Id:5 Memory:0 Cores:[{Id:0 Threads:[5] Caches:[]}] Caches:[]} {Id:6 Memory:0 Cores:[{Id:0 Threads:[6] Caches:[]}] Caches:[]} {Id:7 Memory:0 Cores:[{Id:0 Threads:[7] Caches:[]}] Caches:[]} {Id:8 Memory:0 Cores:[{Id:0 Threads:[8] Caches:[]}] Caches:[]} {Id:9 Memory:0 Cores:[{Id:0 Threads:[9] Caches:[]}] Caches:[]} {Id:10 Memory:0 Cores:[{Id:0 Threads:[10] Caches:[]}] Caches:[]} {Id:11 Memory:0 Cores:[{Id:0 Threads:[11] Caches:[]}] Caches:[]} {Id:12 Memory:0 Cores:[{Id:0 Threads:[12] Caches:[]}] Caches:[]} {Id:13 Memory:0 Cores:[{Id:0 Threads:[13] Caches:[]}] Caches:[]} {Id:14 Memory:0 Cores:[{Id:0 Threads:[14] Caches:[]}] Caches:[]} {Id:15 Memory:0 Cores:[{Id:0 Threads:[15] Caches:[]}] Caches:[]}]}
I0609 19:08:40.240674   21324 manager.go:154] Version: {KernelVersion:3.13.0-43-generic ContainerOsVersion:Ubuntu precise (12.04.5 LTS) DockerVersion:Unknown CadvisorVersion:0.14.0}
I0609 19:08:40.243968   21324 plugins.go:69] No cloud provider specified.

It looks like they diverge starting at the message "no api servers specified"
I didn't have a chance to look into it yet, but it seems that this PR is causing that.

@davidopp
Copy link
Member

davidopp commented Jun 9, 2015

You might want to try running that test manually on the command line to debug this.

@jdef
Copy link
Contributor Author

jdef commented Jun 9, 2015

Thanks, will take a look.

On Tue, Jun 9, 2015 at 5:05 PM, David Oppenheimer notifications@github.com
wrote:

You might want to try running that test manually on the command line to
debug this.


Reply to this email directly or view it on GitHub
#9423 (comment)
.

client, err := s.createAPIServerClient()
clientConfig, err := s.CreateAPIServerClientConfig()
if err != nil {
return err
Copy link
Contributor Author

Choose a reason for hiding this comment

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

pretty sure that this is the problem. the code never used to work this way

@davidopp
Copy link
Member

davidopp commented Jun 9, 2015

Can you squash your two commits, and we'll let the tests run again, and then I think it will be OK?

@jdef jdef force-pushed the create-api-server-client branch from e3dceb2 to f54eeeb Compare June 10, 2015 02:14
@jdef
Copy link
Contributor Author

jdef commented Jun 10, 2015

ok, squashed

@davidopp
Copy link
Member

LGTM

@davidopp davidopp added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 10, 2015
@k8s-bot
Copy link

k8s-bot commented Jun 10, 2015

Can one of the admins verify that this patch is reasonable to test? (reply "ok to test", or if you trust the user, reply "add to whitelist")

If this message is too spammy, please complain to ixdy.

ArtfulCoder added a commit that referenced this pull request Jun 10, 2015
refactor createAPIServerClient for easier integration with 3rd party …
@ArtfulCoder ArtfulCoder merged commit 0fbd490 into kubernetes:master Jun 10, 2015
@jdef jdef deleted the create-api-server-client branch June 12, 2015 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants