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

Remove user dir from operator binary #1036

Closed
chrsoo opened this issue Jan 31, 2019 · 1 comment
Closed

Remove user dir from operator binary #1036

chrsoo opened this issue Jan 31, 2019 · 1 comment
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@chrsoo
Copy link

chrsoo commented Jan 31, 2019

Bug Report

What did you do?
Panic.

What did you expect to see?
The stack trace should only contain paths relative to the GOROOT

What did you see instead? Under which circumstances?
When the operator panics for whatever reason the stack trace includes the full path to the source code. This discloses information on the host that built the binary, e.g. the home dir of the user that made the build.

Aesthetics apart it obfuscates errors as it looks as-if the operator is running locally on another host than on a kubernetes cluster. The source path should be trimmed and refer to a "canonical" go root such as /usr/local/go/... instead of something like /usr/home/user/go/src/...

Environment

  • operator-sdk version:

operator-sdk version v0.3.0+git

  • Kubernetes version information:

(not relevant for the issue but here goes...)

Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.2", GitCommit:"17c77c7898218073f14c8d573582e8d2313dc740", GitTreeState:"clean", BuildDate:"2018-10-30T21:39:38Z", GoVersion:"go1.11.1", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.3", GitCommit:"2bba0127d85d5a46ab4b778548be28623b32d0b0", GitTreeState:"clean", BuildDate:"2018-05-21T09:05:37Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
  • Kubernetes cluster kind:

Docker CE (local), Docker EE (cluster)

  • Are you writing your operator in ansible, helm, or go?

Go.

Possible Solution
Launch go build with the following two flags

-gcflags=-trimpath=$GOPATH -asmflags=-trimpath=$GOPATH

Cf. golang/go#13809 (reference)

Additional context
To illustrate the issue locally without the operator SDK or a k8s cluster, run the following:

cd /tmp
cat <<EOF > main.go
package main

func main() {
	panic("help!")
}
EOF
go build main.go
echo "With local path info:"
./main
go build -gcflags=-trimpath=$(pwd) -asmflags=-trimpath=$(pwd) main.go
echo "Without local path info:"
./main
@AlexNPavel AlexNPavel added the kind/bug Categorizes issue or PR as related to a bug. label Jan 31, 2019
@AlexNPavel
Copy link
Contributor

Thanks for opening this issue. I tried building but was still getting some of my own home paths (specifically for things in the vendor directory) during panics with the flags you provided. I found that the correct flags to remove the paths even across the vendored packages seems to be -gcflags "all=-trimpath=$GOPATH" -asmflags "all=-trimpath=$GOPATH". I will make a PR with the fixes in the makefile

AlexNPavel added a commit that referenced this issue Feb 1, 2019
**Description of the change:** Trim the GOPATH from binaries built with `install` or `build`.

**Motivation for the change:** Remove the home directory of the builder from the panic path.

Closes #1036
AlexNPavel added a commit to AlexNPavel/operator-sdk that referenced this issue Feb 1, 2019
**Description of the change:** Trim the GOPATH from binaries built with `install` or `build`.

**Motivation for the change:** Remove the home directory of the builder from the panic path.

Closes operator-framework#1036
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants