Skip to content

kubectl does not work - timing issues #3399

Closed

Description

  • Your Windows build number: Microsoft Windows [Version 10.0.17134.48]

  • What you're doing and what's happening:
    Download kubectl Linux binary, try to connect to cluster:

$ kubectl version -v9
I0722 21:30:48.428020   13284 loader.go:359] Config loaded from file /home/cape/.kube/config
I0722 21:30:48.429146   13284 round_trippers.go:386] curl -k -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kubectl/v1.11.1 (linux/amd64) kubernetes/b1b2997" 'https://<cluster>/version?timeout=32s'
E0722 21:30:48.429167   13284 round_trippers.go:375] CancelRequest not implemented
I0722 21:30:48.429509   13284 round_trippers.go:405] GET https://<cluster>/version?timeout=32s  in 0 milliseconds
I0722 21:30:48.429795   13284 round_trippers.go:411] Response Headers:
Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.1", GitCommit:"b1b29978270dc22fecc592ac55d903350454310a", GitTreeState:"clean", BuildDate:"2018-07-17T18:53:20Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
I0722 21:30:48.430235   13284 helpers.go:219] Connection error: Get https://<cluster>/version?timeout=32s: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
F0722 21:30:48.430434   13284 helpers.go:119] Unable to connect to the server: context deadline exceeded (Client.Timeout exceeded while awaiting headers)
glog: Flush took longer than 10s

Trying many times, there's a few different causes reported:

  • Unable to connect to the server: dial tcp <cluster-ip>:443: i/o timeout
  • dial tcp: lookup <cluster> on <dns-server>:53: no such host

Notice the very short span of time executing, vs the timeouts claimed - ~2.414ms, while it says it waits 32s for the version call, and glog claims 10+s. Something seems to be off with how time is calculated, and given it is a Go program I'd guess that the reading of the monotonic clock doesn't work?

Note that the curl call mentioned in the log output works well if executed manually. Also, the Windows binary of kubectl works (even from within WSL).

  • What's wrong / what should be happening instead:
    It should work

  • Strace of the failing command, if applicable:
    kubectl.strace

Activity

  1. therealkenc commented on Jul 22, 2018

    @therealkenc

    The strace log here appears to be single threaded. Need strace -f -o kubectl.strace strace kubectl version -v9 and CLI repro steps. That said, this looks configy to me from 40,000 feet. It appears to be using the literal string https://<cluster>/version?timeout=32s. Chances of that being due to a syscall diverge is nonzero but small.

  2. carlpett commented on Jul 23, 2018

    @carlpett
    Author

    Oops, sorry. Updated the gist with correct trace.
    Also, the <cluster> thing was a redaction, apologies for not making that clear. As I mentioned in the end there, the url works if I call it from curl in WSL for example. And the same config+command works with kubectl.exe, so I'm quite confident this is not config-related.

    Repro steps:

    1. Download kubectl from https://kubernetes.io/docs/tasks/tools/install-kubectl/
    2. If you do not have access to a real kubernetes cluster or want to run minikube (), the issue seems to happen even with a configuration not pointing to an actual cluster. I put a "correct" (syntax-wise) config file here. Write it to .kube/config.
  3. carlpett commented on Jul 23, 2018

    @carlpett
    Author

    Actually, I have an even simpler repo pointing to the monotonic timer. Compile and run this Go program:

    package main
    
    import (
            "time"
            "fmt"
    )
    
    func main() {
            fmt.Println(time.Now())
            time.Sleep(10*time.Second)
            fmt.Println(time.Now())
    }

    This should print current time, sleep 10 s, then print current time. This is the output in WSL:

    $ go run test.go
    2018-07-23 06:44:40.453536 +0200 DST m=+0.000390001
    2018-07-23 06:44:40.4540098 +0200 DST m=+0.000864001

    Not 10 seconds. I'm not familiar with the low level Linux calls, but is this line really right? clock_gettime(CLOCK_MONOTONIC, {tv_sec=-2059958, tv_nsec=18446744073122952616})
    Should tv_sec be negative?

    Trace is here.

  4. therealkenc commented on Jul 23, 2018

    @therealkenc

    Nice dig. This went from "looks like silly config thing" to "yeah, that ain't right" in no time flat.

    I'm not familiar with the low level Linux calls, but is this line really right?
    clock_gettime(CLOCK_MONOTONIC, {tv_sec=-2059958, tv_nsec=18446744073122952616})

    Nope. Smells a little like #3252 if you know you have a few weeks uptime. Could be something different. Either way, yeah "there's your problem".

  5. therealkenc commented on Jul 23, 2018

    @therealkenc

    Smells a little exactly like #3252

    Yep. Behaves here, but I've only been up since Wednesday.

    $ go run gotime.go
    2018-07-22 23:23:26.2849182 -0700 DST
    2018-07-22 23:23:36.2882977 -0700 DST
    

    Appreciate your persistence.

  6. carlpett commented on Jul 23, 2018

    @carlpett
    Author

    Ah, right. Windows claims uptime of 63 days, and WSL...

    $ uptime
     10:18:51 up -24855 days, -3:-14,  0 users,  load average: 0.52, 0.58, 0.59
    

    Thanks, will track #3252 then!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions