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

Replace custom /build with go1.18-native "build" directory key #6156

Closed
aarongable opened this issue Jun 13, 2022 · 4 comments
Closed

Replace custom /build with go1.18-native "build" directory key #6156

aarongable opened this issue Jun 13, 2022 · 4 comments

Comments

@aarongable
Copy link
Contributor

This is two ideas in one:

  1. Rather than using our very weird, very custom code to populate the value of the /build endpoint, let's use the new baked-in information available as of go1.18: https://go.dev/doc/go1.18#go-version
  2. Rather than exposing a separate endpoint for it, let's consider moving this information to a sub-key of the meta section of the Directory object
@aarongable
Copy link
Contributor Author

First attempt to get access to the new VCS information is a bust:

…/boulder on use-go-version ? 
❯ bat cmd/buildinfo/buildinfo.go
───────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: cmd/buildinfo/buildinfo.go
───────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ package main
   2   │ 
   3   │ import (
   4   │     "fmt"
   5   │     "runtime/debug"
   6   │ 
   7   │     _ "github.com/letsencrypt/boulder/cmd"
   8   │ )
   9   │ 
  10   │ func main() {
  11   │     bi, ok := debug.ReadBuildInfo()
  12   │     if !ok {
  13   │         fmt.Println("failed to read BuildInfo")
  14   │         return
  15   │     }
  16   │     fmt.Println(bi.String())
  17   │ }
───────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

…/boulder on use-go-version ? 
❯ go run ./cmd/buildinfo        
go      go1.18.2
path    github.com/letsencrypt/boulder/cmd/buildinfo
mod     github.com/letsencrypt/boulder  (devel)
dep     github.com/beorn7/perks v1.0.1  h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
dep     github.com/cespare/xxhash/v2    v2.1.2  h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
dep     github.com/facebookgo/clock     v0.0.0-20150410010913-600d898af40a      h1:yDWHCSQ40h88yih2JAcL6Ls/kVkSE8GFACTGVnMPruw=
dep     github.com/facebookgo/limitgroup        v0.0.0-20150612190941-6abd8d71ec01      h1:IeaD1VDVBPlx3viJT9Md8if8IxxJnO+x0JCGb054heg=
dep     github.com/facebookgo/muster    v0.0.0-20150708232844-fd3d7953fd52      h1:a4DFiKFJiDRGFD1qIcqGLX/WlUMD9dyLSLDt+9QZgt8=
dep     github.com/go-sql-driver/mysql  v1.5.0  h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
dep     github.com/golang/protobuf      v1.5.2  h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
dep     github.com/honeycombio/beeline-go       v1.1.1  h1:sU8r4ae34uEL3/CguSl8Mr+Asz9DL1nfH9Wwk85Pc7U=
dep     github.com/honeycombio/libhoney-go      v1.15.2 h1:5NGcjOxZZma13dmzNcl3OtGbF1hECA0XHJNHEb2t2ck=
dep     github.com/jmhodges/clock       v0.0.0-20160418191101-880ee4c33548      h1:dYTbLf4m0a5u0KLmPfB6mgxbcV7588bOCx79hxa5Sr4=
dep     github.com/klauspost/compress   v1.11.4 h1:kz40R/YWls3iqT9zX9AHN3WoVsrAWVyui5sxuLqiXqU=
dep     github.com/matttproud/golang_protobuf_extensions        v1.0.1  h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
dep     github.com/prometheus/client_golang     v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk=
dep     github.com/prometheus/client_model      v0.2.0  h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
dep     github.com/prometheus/common    v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
dep     github.com/prometheus/procfs    v0.7.3  h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
dep     github.com/vmihailenco/msgpack/v4       v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U=
dep     github.com/vmihailenco/tagparser        v0.1.1  h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
dep     go.opentelemetry.io/contrib/propagators v0.19.0 h1:HrixVNZYFjUl/Db+Tr3DhqzLsVW9GeVf/Gye+C5dNUY=
dep     go.opentelemetry.io/otel        v0.19.0 h1:Lenfy7QHRXPZVsw/12CWpxX6d/JkrX8wrx2vO8G80Ng=
dep     go.opentelemetry.io/otel/trace  v0.19.0 h1:1ucYlenXIDA1OlHVLDZKX0ObXV5RLaq06DtUKz5e5zc=
dep     golang.org/x/crypto     v0.0.0-20210322153248-0c34fe9e7dc2      h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
dep     golang.org/x/sys        v0.0.0-20220114195835-da31bd327af9      h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0=
dep     google.golang.org/grpc  v1.36.1 h1:cmUfbeGKnz9+2DD/UYsMQXeqbHZqZDs4eQwW0sFOpBY=
dep     google.golang.org/protobuf      v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
dep     gopkg.in/alexcesaro/statsd.v2   v2.0.0  h1:FXkZSCZIH17vLCO5sO2UucTHsH9pc+17F6pl3JVCwMc=
dep     gopkg.in/square/go-jose.v2      v2.6.0  h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
build   -compiler=gc
build   CGO_ENABLED=1
build   CGO_CFLAGS=
build   CGO_CPPFLAGS=
build   CGO_CXXFLAGS=
build   CGO_LDFLAGS=
build   GOARCH=amd64
build   GOOS=linux
build   GOAMD64=v1

@aarongable
Copy link
Contributor Author

Ah, looks like this is: golang/go#51279

When I run go run ./cmd/buildinfo, it no longer believes that that binary is part of a module, so it doesn't stamp VCS information.

This works:

…/boulder on use-go-version ? 
❯ go install -mod=vendor ./...

…/boulder on use-go-version ? 
❯ buildinfo                   
go      go1.18.2
path    github.com/letsencrypt/boulder/cmd/buildinfo
mod     github.com/letsencrypt/boulder  (devel)
dep     github.com/beorn7/perks v1.0.1  h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
dep     github.com/cespare/xxhash/v2    v2.1.2  h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
dep     github.com/facebookgo/clock     v0.0.0-20150410010913-600d898af40a      h1:yDWHCSQ40h88yih2JAcL6Ls/kVkSE8GFACTGVnMPruw=
dep     github.com/facebookgo/limitgroup        v0.0.0-20150612190941-6abd8d71ec01      h1:IeaD1VDVBPlx3viJT9Md8if8IxxJnO+x0JCGb054heg=
dep     github.com/facebookgo/muster    v0.0.0-20150708232844-fd3d7953fd52      h1:a4DFiKFJiDRGFD1qIcqGLX/WlUMD9dyLSLDt+9QZgt8=
dep     github.com/go-sql-driver/mysql  v1.5.0  h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
dep     github.com/golang/protobuf      v1.5.2  h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
dep     github.com/honeycombio/beeline-go       v1.1.1  h1:sU8r4ae34uEL3/CguSl8Mr+Asz9DL1nfH9Wwk85Pc7U=
dep     github.com/honeycombio/libhoney-go      v1.15.2 h1:5NGcjOxZZma13dmzNcl3OtGbF1hECA0XHJNHEb2t2ck=
dep     github.com/jmhodges/clock       v0.0.0-20160418191101-880ee4c33548      h1:dYTbLf4m0a5u0KLmPfB6mgxbcV7588bOCx79hxa5Sr4=
dep     github.com/klauspost/compress   v1.11.4 h1:kz40R/YWls3iqT9zX9AHN3WoVsrAWVyui5sxuLqiXqU=
dep     github.com/matttproud/golang_protobuf_extensions        v1.0.1  h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
dep     github.com/prometheus/client_golang     v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk=
dep     github.com/prometheus/client_model      v0.2.0  h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
dep     github.com/prometheus/common    v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=
dep     github.com/prometheus/procfs    v0.7.3  h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=
dep     github.com/vmihailenco/msgpack/v4       v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U=
dep     github.com/vmihailenco/tagparser        v0.1.1  h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
dep     go.opentelemetry.io/contrib/propagators v0.19.0 h1:HrixVNZYFjUl/Db+Tr3DhqzLsVW9GeVf/Gye+C5dNUY=
dep     go.opentelemetry.io/otel        v0.19.0 h1:Lenfy7QHRXPZVsw/12CWpxX6d/JkrX8wrx2vO8G80Ng=
dep     go.opentelemetry.io/otel/trace  v0.19.0 h1:1ucYlenXIDA1OlHVLDZKX0ObXV5RLaq06DtUKz5e5zc=
dep     golang.org/x/crypto     v0.0.0-20210322153248-0c34fe9e7dc2      h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
dep     golang.org/x/sys        v0.0.0-20220114195835-da31bd327af9      h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0=
dep     google.golang.org/grpc  v1.36.1 h1:cmUfbeGKnz9+2DD/UYsMQXeqbHZqZDs4eQwW0sFOpBY=
dep     google.golang.org/protobuf      v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
dep     gopkg.in/alexcesaro/statsd.v2   v2.0.0  h1:FXkZSCZIH17vLCO5sO2UucTHsH9pc+17F6pl3JVCwMc=
dep     gopkg.in/square/go-jose.v2      v2.6.0  h1:NGk74WTnPKBNUhNzQX7PYcTLUjoq7mzKk2OKbvwk2iI=
build   -compiler=gc
build   CGO_ENABLED=1
build   CGO_CFLAGS=
build   CGO_CPPFLAGS=
build   CGO_CXXFLAGS=
build   CGO_LDFLAGS=
build   GOARCH=amd64
build   GOOS=linux
build   GOAMD64=v1
build   vcs=git
build   vcs.revision=e1243993d3621a8f8c75a429f38a6796ce1d3e32
build   vcs.time=2022-06-03T22:16:17Z
build   vcs.modified=true

@aarongable
Copy link
Contributor Author

So unfortunately this isn't a great substitute for our current info:

  • We do get the full git sha1 and a dirty indicator, which is good; but
  • We do not get the build timestamp (just the timestamp of the most recent git commit)
  • We do not get the builder hostname

Probably best to keep getting this info the current way (with -ldflags) for now.

@aarongable
Copy link
Contributor Author

Going to close this as wont-fix, as the benefit here is small enough to not warrant further investigation into how best to get the rest of the desired info.

@aarongable aarongable closed this as not planned Won't fix, can't repro, duplicate, stale Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant