kptdev / kpt

Automate Kubernetes Configuration Editing
https://kpt.dev
Apache License 2.0
1.7k stars 228 forks source link

kpt crashes when it needs a kubeconfig and there isn't one #3656

Open johnbelamaric opened 1 year ago

johnbelamaric commented 1 year ago

Expected behavior

No crashing

Actual behavior

ubuntu@nephio-poc-003:~$ kpt alpha rpkg get
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x63 pc=0x7f721c5f95ca]

runtime stack:
runtime.throw({0x28d0e89?, 0x7f70f8000d53?})
    /usr/local/go/src/runtime/panic.go:992 +0x71
runtime.sigpanic()
    /usr/local/go/src/runtime/signal_unix.go:802 +0x3a9

goroutine 48 [syscall]:
runtime.cgocall(0x19b7870, 0xc000506598)
    /usr/local/go/src/runtime/cgocall.go:157 +0x5c fp=0xc000506570 sp=0xc000506538 pc=0x44f21c
net._C2func_getaddrinfo(0xc000e140b0, 0x0, 0xc001b37950, 0xc000872690)
    _cgo_gotypes.go:94 +0x56 fp=0xc000506598 sp=0xc000506570 pc=0x6bdc96
net.cgoLookupIPCNAME.func1({0xc000e140b0, 0x0?, 0x0?}, 0xc000e14090?, 0x6c455b?)
    /usr/local/go/src/net/cgo_unix.go:160 +0x9f fp=0xc0005065f0 sp=0xc000506598 pc=0x6bf9bf
net.cgoLookupIPCNAME({0x2885eae, 0x3}, {0xc000e14090, 0x9})
    /usr/local/go/src/net/cgo_unix.go:160 +0x16d fp=0xc000506738 sp=0xc0005065f0 pc=0x6bf22d
net.cgoIPLookup(0x3e86730?, {0x2885eae?, 0xc000e140a0?}, {0xc000e14090?, 0xc0000cb8c0?})
    /usr/local/go/src/net/cgo_unix.go:217 +0x3b fp=0xc0005067a8 sp=0xc000506738 pc=0x6bfa7b
net.cgoLookupIP.func1()
    /usr/local/go/src/net/cgo_unix.go:227 +0x36 fp=0xc0005067e0 sp=0xc0005067a8 pc=0x6bfeb6
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc0005067e8 sp=0xc0005067e0 pc=0x4b1e81
created by net.cgoLookupIP
    /usr/local/go/src/net/cgo_unix.go:227 +0x12a

goroutine 1 [select]:
net/http.(*Transport).getConn(0x3d9b280, 0xc0022d52c0, {{}, 0x0, {0xc002307aa0, 0x4}, {0xc000e14090, 0xe}, 0x0})
    /usr/local/go/src/net/http/transport.go:1375 +0x5c6
net/http.(*Transport).roundTrip(0x3d9b280, 0xc002346500)
    /usr/local/go/src/net/http/transport.go:581 +0x76f
net/http.(*Transport).RoundTrip(0x2c3e328?, 0xc000738d08?)
    /usr/local/go/src/net/http/roundtrip.go:17 +0x19
github.com/gregjones/httpcache.(*Transport).RoundTrip(0xc001b363f0, 0xc002346500)
    /go/pkg/mod/github.com/gregjones/httpcache@v0.0.0-20190611155906-901d90724c79/httpcache.go:214 +0x4cc
k8s.io/client-go/discovery/cached/disk.(*cacheRoundTripper).RoundTrip(0x272fa80?, 0xc001b37770?)
    /go/pkg/mod/k8s.io/client-go@v0.24.0/discovery/cached/disk/round_tripper.go:51 +0x1c
k8s.io/client-go/transport.(*userAgentRoundTripper).RoundTrip(0xc00231d380, 0xc002346400)
    /go/pkg/mod/k8s.io/client-go@v0.24.0/transport/round_trippers.go:168 +0x322
net/http.send(0xc002346300, {0x2c33e00, 0xc00231d380}, {0x28293e0?, 0x4d6d01?, 0x3e883e0?})
    /usr/local/go/src/net/http/client.go:252 +0x5d8
net/http.(*Client).send(0xc001b36420, 0xc002346300, {0x7f721c66b290?, 0xf8?, 0x3e883e0?})
    /usr/local/go/src/net/http/client.go:176 +0x9b
net/http.(*Client).do(0xc001b36420, 0xc002346300)
    /usr/local/go/src/net/http/client.go:725 +0x8f5
net/http.(*Client).Do(...)
    /usr/local/go/src/net/http/client.go:593
k8s.io/client-go/rest.(*Request).request(0xc002346100, {0x2c4b220, 0xc0019a5d40}, 0x773594000?)
    /go/pkg/mod/k8s.io/client-go@v0.24.0/rest/request.go:883 +0x3d1
k8s.io/client-go/rest.(*Request).Do(0xc002346100, {0x2c4b1e8, 0xc00012a008})
    /go/pkg/mod/k8s.io/client-go@v0.24.0/rest/request.go:924 +0xc9
k8s.io/client-go/discovery.(*DiscoveryClient).ServerGroups(0xc00231d3c0)
    /go/pkg/mod/k8s.io/client-go@v0.24.0/discovery/discovery_client.go:161 +0xae
k8s.io/client-go/discovery/cached/disk.(*CachedDiscoveryClient).ServerGroups(0xc00199d2c0)
    /go/pkg/mod/k8s.io/client-go@v0.24.0/discovery/cached/disk/cached_discovery.go:117 +0x17e
k8s.io/client-go/discovery.ServerGroupsAndResources({0x2c508a0, 0xc00199d2c0})
    /go/pkg/mod/k8s.io/client-go@v0.24.0/discovery/discovery_client.go:244 +0x42
k8s.io/client-go/discovery/cached/disk.(*CachedDiscoveryClient).ServerGroupsAndResources(0x0?)
    /go/pkg/mod/k8s.io/client-go@v0.24.0/discovery/cached/disk/cached_discovery.go:100 +0x25
k8s.io/client-go/restmapper.GetAPIGroupResources({0x2c508a0?, 0xc00199d2c0?})
    /go/pkg/mod/k8s.io/client-go@v0.24.0/restmapper/discovery.go:148 +0x42
k8s.io/client-go/restmapper.(*DeferredDiscoveryRESTMapper).getDelegate(0xc001b36570)
    /go/pkg/mod/k8s.io/client-go@v0.24.0/restmapper/discovery.go:202 +0xb8
k8s.io/client-go/restmapper.(*DeferredDiscoveryRESTMapper).RESTMapping(0xc001b36570, {{0x0?, 0x0?}, {0x289cd5c?, 0x459247?}}, {0xc001d61490, 0x1, 0x1})
    /go/pkg/mod/k8s.io/client-go@v0.24.0/restmapper/discovery.go:286 +0x65
k8s.io/client-go/restmapper.shortcutExpander.RESTMapping(...)
    /go/pkg/mod/k8s.io/client-go@v0.24.0/restmapper/shortcut.go:71
k8s.io/cli-runtime/pkg/resource.(*Builder).mappingFor(0xc0019dc9a0, {0x289cd5c, 0x10})
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/resource/builder.go:783 +0x4e3
k8s.io/cli-runtime/pkg/resource.(*Builder).resourceMappings(0xc0019dc9a0)
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/resource/builder.go:811 +0x171
k8s.io/cli-runtime/pkg/resource.(*Builder).visitBySelector(0xc0019dc9a0)
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/resource/builder.go:907 +0xd8
k8s.io/cli-runtime/pkg/resource.(*Builder).visitorResult(0xc0019dc9a0)
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/resource/builder.go:864 +0x109
k8s.io/cli-runtime/pkg/resource.(*Builder).Do(0xc0019dc9a0)
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/resource/builder.go:1158 +0x33
github.com/GoogleContainerTools/kpt/commands/alpha/rpkg/get.(*runner).runE(0xc0022c1500, 0x0?, {0x3ec1cb8, 0x0, 0x0})
    /go/src/github.com/GoogleContainerTools/kpt/commands/alpha/rpkg/get/command.go:168 +0x5f6
github.com/spf13/cobra.(*Command).execute(0xc0022db900, {0x3ec1cb8, 0x0, 0x0})
    /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:872 +0x694
github.com/spf13/cobra.(*Command).ExecuteC(0xc0019ab400)
    /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
    /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918
k8s.io/component-base/cli.run(0xc0019ab400)
    /go/pkg/mod/k8s.io/component-base@v0.24.0/cli/run.go:146 +0x305
k8s.io/component-base/cli.RunNoErrOutput(...)
    /go/pkg/mod/k8s.io/component-base@v0.24.0/cli/run.go:84
main.runMain()
    /go/src/github.com/GoogleContainerTools/kpt/main.go:62 +0x45
main.main()
    /go/src/github.com/GoogleContainerTools/kpt/main.go:46 +0x19

goroutine 8 [sleep]:
time.Sleep(0x6fc23ac00)
    /usr/local/go/src/runtime/time.go:194 +0x12e
sigs.k8s.io/controller-runtime/pkg/log.init.0.func1()
    /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.1/pkg/log/log.go:63 +0x38
created by sigs.k8s.io/controller-runtime/pkg/log.init.0
    /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.1/pkg/log/log.go:62 +0x25

goroutine 40 [runnable]:
net/http.setRequestCancel.func4()
    /usr/local/go/src/net/http/client.go:398 +0x8b
created by net/http.setRequestCancel
    /usr/local/go/src/net/http/client.go:397 +0x439

goroutine 45 [runnable]:
net/http.setRequestCancel.func4()
    /usr/local/go/src/net/http/client.go:397
created by net/http.setRequestCancel
    /usr/local/go/src/net/http/client.go:397 +0x439

goroutine 46 [select]:
net.(*Resolver).lookupIPAddr(0x3e86720, {0x2c4b220?, 0xc0019a5f80}, {0x2885eae, 0x3}, {0xc000e14090, 0x9})
    /usr/local/go/src/net/lookup.go:325 +0x51b
net.(*Resolver).internetAddrList(0x2c4b220?, {0x2c4b220?, 0xc0019a5f80?}, {0x2885eae, 0x3}, {0xc000e14090?, 0xe?})
    /usr/local/go/src/net/ipsock.go:288 +0x67a
net.(*Resolver).resolveAddrList(0x3ec1cb8?, {0x2c4b220, 0xc0019a5f80}, {0x288674a, 0x4}, {0x2885eae?, 0x47941b?}, {0xc000e14090, 0xe}, {0x0, ...})
    /usr/local/go/src/net/dial.go:221 +0x41b
net.(*Dialer).DialContext(0xc000114240, {0x2c4b220, 0xc0019a5d40}, {0x2885eae, 0x3}, {0xc000e14090, 0xe})
    /usr/local/go/src/net/dial.go:406 +0x448
net/http.(*Transport).dial(0x7f725480da68?, {0x2c4b220?, 0xc0019a5d40?}, {0x2885eae?, 0x0?}, {0xc000e14090?, 0xc000090a18?})
    /usr/local/go/src/net/http/transport.go:1169 +0xda
net/http.(*Transport).dialConn(0x3d9b280, {0x2c4b220, 0xc0019a5d40}, {{}, 0x0, {0xc002307aa0, 0x4}, {0xc000e14090, 0xe}, 0x0})
    /usr/local/go/src/net/http/transport.go:1607 +0x83f
net/http.(*Transport).dialConnFor(0xc0019c9860?, 0xc0000cba20)
    /usr/local/go/src/net/http/transport.go:1449 +0xb0
created by net/http.(*Transport).queueForDial
    /usr/local/go/src/net/http/transport.go:1418 +0x3d2

goroutine 47 [select]:
net.cgoLookupIP({0x2c4b1b0, 0xc0022d5300}, {0x2885eae, 0x3}, {0xc000e14090, 0x9})
    /usr/local/go/src/net/cgo_unix.go:228 +0x1aa
net.(*Resolver).lookupIP(0x3e86720, {0x2c4b1b0, 0xc0022d5300}, {0x2885eae, 0x3}, {0xc000e14090, 0x9})
    /usr/local/go/src/net/lookup_unix.go:96 +0x128
net.glob..func1({0x2c4b1b0?, 0xc0022d5300?}, 0x0?, {0x2885eae?, 0xc0019a5d38?}, {0xc000e14090?, 0x844a70?})
    /usr/local/go/src/net/hook.go:23 +0x3d
net.(*Resolver).lookupIPAddr.func1()
    /usr/local/go/src/net/lookup.go:319 +0x9f
internal/singleflight.(*Group).doCall(0x3e86730, 0xc00199da40, {0xc000e140a0, 0xd}, 0xc0000cb8c0?)
    /usr/local/go/src/internal/singleflight/singleflight.go:95 +0x3b
created by internal/singleflight.(*Group).DoChan
    /usr/local/go/src/internal/singleflight/singleflight.go:88 +0x2ec

Steps to reproduce the behavior

mortent commented 1 year ago

Which version of kpt are you using? With the kpt built from HEAD of the repo, I'm unable to reproduce this issue. I'm getting:

$ kpt alpha rpkg get
Error: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused
jashandeep-sohi commented 1 year ago

I'm seeing a similar crash, but I'm not able to get around it using --kubeconfig as suggested. I'm guessing this regression was introduced sometime after 1.0.0-beta.20. Reverting back to this version does not give me SIGSEGV.

1.0.0-beta.21 & 1.0.0-beta.23 both do.

If it helps, my env looks something like:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.12", GitCommit:"c6939792865ef0f70f92006081690d77411c8ed5", GitTreeState:"clean", BuildDate:"2022-09-21T12:20:29Z", GoVersion:"go1.17.13", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"23+", GitVersion:"v1.23.13-eks-fb459a0", GitCommit:"55bd5d5cb7d32bc35e4e050f536181196fb8c6f7", GitTreeState:"clean", BuildDate:"2022-10-24T20:35:40Z", GoVersion:"go1.17.13", Compiler:"gc", Platform:"linux/amd64"}

$ aws --version
aws-cli/2.8.12 Python/3.9.11 Linux/6.0.6-arch1-1 exe/x86_64.arch prompt/off

$ kubectl --kubeconfig kubeconfig config view
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://xx.xx.us-east-1.eks.amazonaws.com
  name: arn:aws:eks:us-east-1:xx:cluster/prod-01
contexts:
- context:
    cluster: arn:aws:eks:us-east-1:xx:cluster/prod-01
    user: arn:aws:eks:us-east-1:xx:cluster/prod-01
  name: ptr
current-context: ptr
kind: Config
preferences: {}
users:
- name: arn:aws:eks:us-east-1:xx:cluster/prod-01
  user:
    exec:
      apiVersion: client.authentication.k8s.io/v1beta1
      args:
      - --region
      - us-east-1
      - eks
      - get-token
      - --cluster-name
      - prod-01
      command: aws
      env:
      - name: AWS_PROFILE
        value: ptr
      interactiveMode: IfAvailable
      provideClusterInfo: false

$ kubectl --kubeconfig kubeconfig cluster-info
Kubernetes control plane is running at https://xx.xx.us-east-1.eks.amazonaws.com
CoreDNS is running at https://xx.xx.us-east-1.eks.amazonaws.com/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

$ kpt version
1.0.0-beta.21

$ kpt --kubeconfig kubeconfig live install-resource-group
installing inventory ResourceGroup CRD...fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x23130 pc=0x23130]

runtime stack:
runtime.throw({0x28bf079?, 0x4fd3440?})
    /usr/local/go/src/runtime/panic.go:992 +0x71
runtime.sigpanic()
    /usr/local/go/src/runtime/signal_unix.go:802 +0x3a9

goroutine 38 [syscall]:
runtime.cgocall(0x19ab710, 0xc001840598)
    /usr/local/go/src/runtime/cgocall.go:157 +0x5c fp=0xc001840570 sp=0xc001840538 pc=0x44f21c
net._C2func_getaddrinfo(0xc002225400, 0x0, 0xc000d8d860, 0xc001087cf0)
    _cgo_gotypes.go:94 +0x56 fp=0xc001840598 sp=0xc001840570 pc=0x64a856
net.cgoLookupIPCNAME.func1({0xc002225400, 0x0?, 0x6120000000000000?}, 0xc002225360?, 0x65111b?)
    /usr/local/go/src/net/cgo_unix.go:160 +0x9f fp=0xc0018405f0 sp=0xc001840598 pc=0x64c57f
net.cgoLookupIPCNAME({0x287416c, 0x3}, {0xc002225360, 0x40})
    /usr/local/go/src/net/cgo_unix.go:160 +0x16d fp=0xc001840738 sp=0xc0018405f0 pc=0x64bded
net.cgoIPLookup(0x3e616f0?, {0x287416c?, 0xc0022253b0?}, {0xc002225360?, 0xc0000d58c0?})
    /usr/local/go/src/net/cgo_unix.go:217 +0x3b fp=0xc0018407a8 sp=0xc001840738 pc=0x64c63b
net.cgoLookupIP.func1()
    /usr/local/go/src/net/cgo_unix.go:227 +0x36 fp=0xc0018407e0 sp=0xc0018407a8 pc=0x64ca76
runtime.goexit()
    /usr/local/go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc0018407e8 sp=0xc0018407e0 pc=0x4b1e81
created by net.cgoLookupIP
    /usr/local/go/src/net/cgo_unix.go:227 +0x12a

goroutine 1 [select]:
net/http.(*Transport).getConn(0xc00172cc80, 0xc001811200, {{}, 0x0, {0xc0017726e0, 0x5}, {0xc002225360, 0x44}, 0x0})
    /usr/local/go/src/net/http/transport.go:1375 +0x5c6
net/http.(*Transport).roundTrip(0xc00172cc80, 0xc0018df300)
    /usr/local/go/src/net/http/transport.go:581 +0x76f
net/http.(*Transport).RoundTrip(0x271fb20?, 0xc000d8c6f0?)
    /usr/local/go/src/net/http/roundtrip.go:17 +0x19
k8s.io/client-go/plugin/pkg/client/auth/exec.(*roundTripper).RoundTrip(0xc0016871d0, 0xc0018df300)
    /go/pkg/mod/k8s.io/client-go@v0.24.0/plugin/pkg/client/auth/exec/exec.go:344 +0x1e4
sigs.k8s.io/cli-utils/pkg/flowcontrol.IsEnabled({0x2c37e70, 0xc00077f500}, 0xc0019406c0)
    /go/pkg/mod/sigs.k8s.io/cli-utils@v0.33.0/pkg/flowcontrol/flowcontrol.go:64 +0x33f
github.com/GoogleContainerTools/kpt/commands/util.UpdateQPS.func1(0xc0019406c0)
    /go/src/github.com/GoogleContainerTools/kpt/commands/util/factory.go:64 +0x8e
k8s.io/cli-runtime/pkg/genericclioptions.(*ConfigFlags).ToRESTConfig(0xc001794f00)
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/genericclioptions/config_flags.go:140 +0x42
k8s.io/cli-runtime/pkg/genericclioptions.(*ConfigFlags).toDiscoveryClient(0xc001794f00)
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/genericclioptions/config_flags.go:270 +0x33
k8s.io/cli-runtime/pkg/genericclioptions.(*ConfigFlags).toPersistentDiscoveryClient(0xc001794f00)
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/genericclioptions/config_flags.go:260 +0xa7
k8s.io/cli-runtime/pkg/genericclioptions.(*ConfigFlags).ToDiscoveryClient(0x29?)
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/genericclioptions/config_flags.go:250 +0x25
k8s.io/cli-runtime/pkg/genericclioptions.(*ConfigFlags).toRESTMapper(0xc0000021a0?)
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/genericclioptions/config_flags.go:314 +0x1d
k8s.io/cli-runtime/pkg/genericclioptions.(*ConfigFlags).toPersistentRESTMapper(0xc001794f00)
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/genericclioptions/config_flags.go:304 +0xa7
k8s.io/cli-runtime/pkg/genericclioptions.(*ConfigFlags).ToRESTMapper(0x52c864?)
    /go/pkg/mod/k8s.io/cli-runtime@v0.24.0/pkg/genericclioptions/config_flags.go:294 +0x25
github.com/GoogleContainerTools/kpt/internal/util/cfgflags.(*UserAgentKubeConfigFlags).ToRESTMapper(0x0?)
    /go/src/github.com/GoogleContainerTools/kpt/internal/util/cfgflags/useragent.go:46 +0x22
k8s.io/kubectl/pkg/cmd/util.(*factoryImpl).ToRESTMapper(0x29?)
    /go/pkg/mod/k8s.io/kubectl@v0.24.0/pkg/cmd/util/factory_client_access.go:66 +0x22
github.com/GoogleContainerTools/kpt/pkg/status.NewStatusPoller({0x2c40e20, 0xc001810100})
    /go/src/github.com/GoogleContainerTools/kpt/pkg/status/poller.go:29 +0x3f
github.com/GoogleContainerTools/kpt/pkg/live.(*ResourceGroupInstaller).InstallRG(0xc002195c88, {0x2c37ea8, 0xc000cf0300})
    /go/src/github.com/GoogleContainerTools/kpt/pkg/live/inventoryrg.go:422 +0x50
github.com/GoogleContainerTools/kpt/commands/live/installrg.(*Runner).runE(0xc00077eba0, 0x0?, {0xc001896720?, 0x0?, 0x0?})
    /go/src/github.com/GoogleContainerTools/kpt/commands/live/installrg/cmdinstallrg.go:80 +0x97
github.com/spf13/cobra.(*Command).execute(0xc001824500, {0xc001896700, 0x2, 0x2})
    /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:872 +0x694
github.com/spf13/cobra.(*Command).ExecuteC(0xc0016bf400)
    /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:990 +0x3b4
github.com/spf13/cobra.(*Command).Execute(...)
    /go/pkg/mod/github.com/spf13/cobra@v1.5.0/command.go:918
k8s.io/component-base/cli.run(0xc0016bf400)
    /go/pkg/mod/k8s.io/component-base@v0.24.0/cli/run.go:146 +0x305
k8s.io/component-base/cli.RunNoErrOutput(...)
    /go/pkg/mod/k8s.io/component-base@v0.24.0/cli/run.go:84
main.runMain()
    /go/src/github.com/GoogleContainerTools/kpt/main.go:61 +0x45
main.main()
    /go/src/github.com/GoogleContainerTools/kpt/main.go:45 +0x19

goroutine 5 [sleep]:
time.Sleep(0x6fc23ac00)
    /usr/local/go/src/runtime/time.go:194 +0x12e
sigs.k8s.io/controller-runtime/pkg/log.init.0.func1()
    /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.1/pkg/log/log.go:63 +0x38
created by sigs.k8s.io/controller-runtime/pkg/log.init.0
    /go/pkg/mod/sigs.k8s.io/controller-runtime@v0.11.1/pkg/log/log.go:62 +0x25

goroutine 36 [select]:
net.(*Resolver).lookupIPAddr(0x3e616e0, {0x2c37e70?, 0xc00077f500}, {0x287416c, 0x3}, {0xc002225360, 0x40})
    /usr/local/go/src/net/lookup.go:325 +0x51b
net.(*Resolver).internetAddrList(0x2c37e70?, {0x2c37e70?, 0xc00077f500?}, {0x287416c, 0x3}, {0xc002225360?, 0x44?})
    /usr/local/go/src/net/ipsock.go:288 +0x67a
net.(*Resolver).resolveAddrList(0x3e9cb58?, {0x2c37e70, 0xc00077f500}, {0x2874a08, 0x4}, {0x287416c?, 0xc00009a7b8?}, {0xc002225360, 0x44}, {0x0, ...})
    /usr/local/go/src/net/dial.go:221 +0x41b
net.(*Dialer).DialContext(0xc00077f560, {0x2c37e70, 0xc00077f500}, {0x287416c, 0x3}, {0xc002225360, 0x44})
    /usr/local/go/src/net/dial.go:406 +0x448
k8s.io/client-go/util/connrotation.(*Dialer).DialContext(0xc001604860, {0x2c37e70?, 0xc00077f500?}, {0x287416c?, 0x1898a9b3a68?}, {0xc002225360?, 0x118?})
    /go/pkg/mod/k8s.io/client-go@v0.24.0/util/connrotation/connrotation.go:118 +0x48
net/http.(*Transport).dial(0xc00009aa18?, {0x2c37e70?, 0xc00077f500?}, {0x287416c?, 0x0?}, {0xc002225360?, 0xc00009aa68?})
    /usr/local/go/src/net/http/transport.go:1169 +0xda
net/http.(*Transport).dialConn(0xc00172cc80, {0x2c37e70, 0xc00077f500}, {{}, 0x0, {0xc0017726e0, 0x5}, {0xc002225360, 0x44}, 0x0})
    /usr/local/go/src/net/http/transport.go:1607 +0x83f
net/http.(*Transport).dialConnFor(0x0?, 0xc0000d58c0)
    /usr/local/go/src/net/http/transport.go:1449 +0xb0
created by net/http.(*Transport).queueForDial
    /usr/local/go/src/net/http/transport.go:1418 +0x3d2

goroutine 37 [select]:
net.cgoLookupIP({0x2c37e00, 0xc001811280}, {0x287416c, 0x3}, {0xc002225360, 0x40})
    /usr/local/go/src/net/cgo_unix.go:228 +0x1aa
net.(*Resolver).lookupIP(0x3e616e0, {0x2c37e00, 0xc001811280}, {0x287416c, 0x3}, {0xc002225360, 0x40})
    /usr/local/go/src/net/lookup_unix.go:96 +0x128
net.glob..func1({0x2c37e00?, 0xc001811280?}, 0x0?, {0x287416c?, 0x0?}, {0xc002225360?, 0x7ea7b0?})
    /usr/local/go/src/net/hook.go:23 +0x3d
net.(*Resolver).lookupIPAddr.func1()
    /usr/local/go/src/net/lookup.go:319 +0x9f
internal/singleflight.(*Group).doCall(0x3e616f0, 0xc00077aff0, {0xc0022253b0, 0x44}, 0xc0000d58c0?)
    /usr/local/go/src/internal/singleflight/singleflight.go:95 +0x3b
created by internal/singleflight.(*Group).DoChan
    /usr/local/go/src/internal/singleflight/singleflight.go:88 +0x2ec

I'm able to use kubectl just fine.

Another thing to consider, I'm able to spin up a vanilla kind cluster locally and can use kpt against it just fine.

jashandeep-sohi commented 1 year ago

After some google-fu, I was able to resolve this by forcing the Go runtime to use the builtin DNS resolver (instead of cgo):

GODEBUG=netdns=go kpt live install-resource-group

Any ideas on how to make this the default? Not sure if this the root cause or addressing the actual issue in a round about way.

ChristopherFry commented 1 year ago

Which version of kpt are you using? With the kpt built from HEAD of the repo, I'm unable to reproduce this issue. I'm getting:

$ kpt alpha rpkg get
Error: Get "http://localhost:8080/api?timeout=32s": dial tcp [::1]:8080: connect: connection refused

This is using kpt version 1.0.0-beta.23.

The first time you execute kpt alpha rpkg get I do see the same connect: connection refused message you see, and then every time afterwards I see fatal error: unexpected signal

ubuntu@nephio-poc-002:~$ kpt alpha rpkg get
Error: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused 

ubuntu@nephio-poc-002:~$ kpt alpha rpkg get
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x63 pc=0x7fb7a85e95ca]

runtime stack:
runtime.throw({0x28d0e89?, 0x7fb674000d53?})
        /usr/local/go/src/runtime/panic.go:992 +0x71
runtime.sigpanic()
        /usr/local/go/src/runtime/signal_unix.go:802 +0x3a9
...

ubuntu@nephio-poc-002:~$ kpt version
1.0.0-beta.23

With verbose logging:

ubuntu@nephio-poc-002:~$ kpt -v 9 alpha rpkg get
I1115 21:07:21.007498  463327 round_trippers.go:466] curl -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kpt/1.0.0-beta.23" 'http://localhost:8080/api?timeout=32s'
I1115 21:07:21.008988  463327 round_trippers.go:495] HTTP Trace: DNS Lookup for localhost resolved to [{127.0.0.1 }]
I1115 21:07:21.009289  463327 round_trippers.go:508] HTTP Trace: Dial to tcp:127.0.0.1:8080 failed: dial tcp 127.0.0.1:8080: connect: connection refused
I1115 21:07:21.009347  463327 round_trippers.go:553] GET http://localhost:8080/api?timeout=32s  in 1 milliseconds
I1115 21:07:21.009368  463327 round_trippers.go:570] HTTP Statistics: DNSLookup 0 ms Dial 0 ms TLSHandshake 0 ms Duration 1 ms
I1115 21:07:21.009387  463327 round_trippers.go:577] Response Headers:
I1115 21:07:21.009496  463327 cached_discovery.go:119] skipped caching discovery info due to Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
I1115 21:07:21.009561  463327 shortcut.go:89] Error loading discovery information: Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
I1115 21:07:21.009661  463327 round_trippers.go:466] curl -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kpt/1.0.0-beta.23" 'http://localhost:8080/api?timeout=32s'
I1115 21:07:21.009836  463327 round_trippers.go:495] HTTP Trace: DNS Lookup for localhost resolved to [{127.0.0.1 }]
I1115 21:07:21.010055  463327 round_trippers.go:508] HTTP Trace: Dial to tcp:127.0.0.1:8080 failed: dial tcp 127.0.0.1:8080: connect: connection refused
I1115 21:07:21.010160  463327 round_trippers.go:553] GET http://localhost:8080/api?timeout=32s  in 0 milliseconds
I1115 21:07:21.010187  463327 round_trippers.go:570] HTTP Statistics: DNSLookup 0 ms Dial 0 ms TLSHandshake 0 ms Duration 0 ms
I1115 21:07:21.010204  463327 round_trippers.go:577] Response Headers:
I1115 21:07:21.010304  463327 cached_discovery.go:119] skipped caching discovery info due to Get "http://localhost:8080/api?timeout=32s": dial tcp 127.0.0.1:8080: connect: connection refused
I1115 21:07:21.010436  463327 round_trippers.go:466] curl -v -XGET  -H "Accept: application/json, */*" -H "User-Agent: kpt/1.0.0-beta.23" 'http://localhost:8080/api?timeout=32s'
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x63 pc=0x7fa3802975ca]
mortent commented 1 year ago

Yeah, I can reproduce this when I'm using the kpt 1.0.0-beta.23 binary, but not if I'm building it from source.

johnbelamaric commented 1 year ago

The binary downloadable off of the kpt GitHub, or just the one on the Nephio PoC VM?

mortent commented 1 year ago

I can reproduce it on my own linux machine with the binary downloaded from GitHub.