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

[BUG] Verbose segmentation fault with --no-lb #750

Closed
jessequinn opened this issue Sep 20, 2021 · 3 comments · Fixed by #775
Closed

[BUG] Verbose segmentation fault with --no-lb #750

jessequinn opened this issue Sep 20, 2021 · 3 comments · Fixed by #775
Labels
bug Something isn't working
Milestone

Comments

@jessequinn
Copy link

What did you do

Running the following command:

k3d cluster create master -s 1 \
--token YtPIwEMJXJebvXfNcZud \
--no-lb \
--network host \
--api-port 6443 \
--verbose

causes the following error:

DEBU[0000] Disabling the load balancer                  
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x1743855]

What did you expect to happen

I expected a cluster without a load balancer to be created.

Which OS & Architecture

  • OSX

Which version of k3d

main-v5 - latest

Which version of docker

Client:
 Cloud integration: 1.0.17
 Version:           20.10.8
 API version:       1.41
 Go version:        go1.16.6
 Git commit:        3967b7d
 Built:             Fri Jul 30 19:55:20 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.8
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.6
  Git commit:       75249d8
  Built:            Fri Jul 30 19:52:10 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.9
  GitCommit:        e25210fe30a0a703442421b0f60afac609f950a3
 runc:
  Version:          1.0.1
  GitCommit:        v1.0.1-0-g4144b63
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Build with BuildKit (Docker Inc., v0.6.1-docker)
  compose: Docker Compose (Docker Inc., v2.0.0-rc.3)
  scan: Docker Scan (Docker Inc., v0.8.0)

Server:
 Containers: 3
  Running: 0
  Paused: 0
  Stopped: 3
 Images: 41
 Server Version: 20.10.8
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
  userxattr: false
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: e25210fe30a0a703442421b0f60afac609f950a3
 runc version: v1.0.1-0-g4144b63
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 5.10.47-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 4
 Total Memory: 1.939GiB
 Name: docker-desktop
 ID: 3C5N:PPMV:24CM:DSA6:4ZVS:NJIU:TLW6:OXMW:XT5K:ZRK7:X4F2:5DCI
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

Issue, I believe, is due to the following code:

	// print generated loadbalancer config
	if l.Log().GetLevel() >= logrus.DebugLevel {
		yamlized, err := yaml.Marshal(cluster.ServerLoadBalancer.Config)
		if err != nil {
			l.Log().Errorf("error printing loadbalancer config: %v", err)
		} else {
			l.Log().Debugf("generated loadbalancer config:\n%s", string(yamlized))
		}
	}

found in ports.go. More specifically, yamlized, err := yaml.Marshal(cluster.ServerLoadBalancer.Config) would be nil due to the fact the LB was NOT added.

@jessequinn jessequinn added the bug Something isn't working label Sep 20, 2021
@jessequinn jessequinn changed the title [BUG] [BUG] Verbose segmentation fault with --no-lb Sep 21, 2021
@benjaminjb
Copy link
Contributor

benjaminjb commented Oct 7, 2021

Yes, I'm running into this same error using k3d v5 -- reran the same command in v4.4.8 and it ran fine. If run with the --no-lb option, should we skip calls to TransformPorts entirely?

EDIT: Just realized, this problem seems particular to --verbose and --trace -- when TransformPorts is invoked, if the logging is set to debug, it tries to marshal the Config. Which means that this problem is masking the error I'm actually trying to track down. Would the solution here be to skip that debug line if --no-lb is true?

EDIT EDIT: Would this work if l.Log().GetLevel() >= logrus.DebugLevel && !cluster.HasLoadBalancer() { for this: https://github.com/rancher/k3d/blob/main/pkg/client/ports.go#L104

EDIT EDIT EDIT: or the more straightforward: && cluster.ServerLoadBalancer != nil

@iwilltry42
Copy link
Member

Hi @jessequinn , thanks for opening this issue!
And special thanks to @benjaminjb for fixing this directly :)

@iwilltry42 iwilltry42 added this to the v5.0.1 milestone Oct 8, 2021
@iwilltry42
Copy link
Member

Will be released in the next patch release 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants