]> Cypherpunks repositories - gostls13.git/commitdiff
cmd: vendor golang.org/x/telemetry@a797f33
authorRob Findley <rfindley@google.com>
Wed, 28 Aug 2024 20:32:37 +0000 (20:32 +0000)
committerRobert Findley <rfindley@google.com>
Thu, 29 Aug 2024 14:37:27 +0000 (14:37 +0000)
Update x/telemetry to fix #68976 and #68946.

Commands run:
  go get golang.org/x/telemetry@a797f33
  go mod tidy
  go mod vendor

Fixes #68946
Fixes #68946

Change-Id: I321ce609b41ef210a19150dce1f07b204e7c118e
Reviewed-on: https://go-review.googlesource.com/c/go/+/609237
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/cmd/go.mod
src/cmd/go.sum
src/cmd/vendor/golang.org/x/telemetry/internal/configstore/download.go
src/cmd/vendor/golang.org/x/telemetry/internal/crashmonitor/monitor.go
src/cmd/vendor/golang.org/x/telemetry/internal/upload/run.go
src/cmd/vendor/golang.org/x/telemetry/start.go
src/cmd/vendor/modules.txt

index 89a64e906ea826bb586bc6a61854ddfc90dda4e9..7e8860c5b44dd589cd4783e7201efbd7694ce671 100644 (file)
@@ -9,7 +9,7 @@ require (
        golang.org/x/mod v0.20.0
        golang.org/x/sync v0.8.0
        golang.org/x/sys v0.23.0
-       golang.org/x/telemetry v0.0.0-20240807181058-38c23d25f755
+       golang.org/x/telemetry v0.0.0-20240828202201-a797f331ea97
        golang.org/x/term v0.22.1-0.20240716160707-d4346f0be292
        golang.org/x/tools v0.23.1-0.20240722161640-ec1a81bfec7c
 )
index c93d286f1289b4da6fbd247c2f7496fd5fdbddf0..fff1e51f80d0017bf1e2a76175d81e607f176de8 100644 (file)
@@ -16,8 +16,8 @@ golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
 golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 golang.org/x/sys v0.23.0 h1:YfKFowiIMvtgl1UERQoTPPToxltDeZfbj4H7dVUCwmM=
 golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/telemetry v0.0.0-20240807181058-38c23d25f755 h1:Gv9T6gPIHuUCC/THKUdLbAj1GeBKx7auk9c9w/5CHPk=
-golang.org/x/telemetry v0.0.0-20240807181058-38c23d25f755/go.mod h1:m7R/r+o5h7UvF2JD9n2iLSGY4v8v+zNSyTJ6xynLrqs=
+golang.org/x/telemetry v0.0.0-20240828202201-a797f331ea97 h1:5xPN7d0u5VdgF2gFFXUDaeD3NP1pPgFMHocnCQGAh5M=
+golang.org/x/telemetry v0.0.0-20240828202201-a797f331ea97/go.mod h1:m7R/r+o5h7UvF2JD9n2iLSGY4v8v+zNSyTJ6xynLrqs=
 golang.org/x/term v0.22.1-0.20240716160707-d4346f0be292 h1:BOrQi08eIX3cDgGcMgFONf27MxXigcYa9x+iW5JuCXw=
 golang.org/x/term v0.22.1-0.20240716160707-d4346f0be292/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
 golang.org/x/text v0.16.1-0.20240716160804-ae0cf96bbcd9 h1:MlCLrwVF1WvXT14xTzwuKN3u4LpUve8sG/gJUCuBpe8=
index a38f371d0f51b651df832c4162244759d23f5aa5..e60ab7e9fdd73e2dcf08809ea42820731dcd92cc 100644 (file)
@@ -16,6 +16,7 @@ import (
        "os"
        "os/exec"
        "path/filepath"
+       "sync/atomic"
 
        "golang.org/x/telemetry/internal/telemetry"
 )
@@ -29,12 +30,22 @@ const (
 // creation flag.
 var needNoConsole = func(cmd *exec.Cmd) {}
 
+var downloads int64
+
+// Downloads reports, for testing purposes, the number of times [Download] has
+// been called.
+func Downloads() int64 {
+       return atomic.LoadInt64(&downloads)
+}
+
 // Download fetches the requested telemetry UploadConfig using "go mod
 // download". If envOverlay is provided, it is appended to the environment used
 // for invoking the go command.
 //
 // The second result is the canonical version of the requested configuration.
 func Download(version string, envOverlay []string) (*telemetry.UploadConfig, string, error) {
+       atomic.AddInt64(&downloads, 1)
+
        if version == "" {
                version = "latest"
        }
index f475f7eec2dfce94d1c013ad68726591b910a1fe..612f7563a74c9f05b6e6cb3cb6203879018507e2 100644 (file)
@@ -21,12 +21,12 @@ import (
        "golang.org/x/telemetry/internal/counter"
 )
 
-// Supported reports whether the runtime supports [runtime.SetCrashOutput].
+// Supported reports whether the runtime supports [runtime/debug.SetCrashOutput].
 //
 // TODO(adonovan): eliminate once go1.23+ is assured.
 func Supported() bool { return setCrashOutput != nil }
 
-var setCrashOutput func(*os.File) error // = runtime.SetCrashOutput on go1.23+
+var setCrashOutput func(*os.File) error // = runtime/debug.SetCrashOutput on go1.23+
 
 // Parent sets up the parent side of the crashmonitor. It requires
 // exclusive use of a writable pipe connected to the child process's stdin.
index eba13b1a573560d3a4316df4512c735626c7b66c..e9c8dc207126a18cefd26e7d7f7a2092ee562023 100644 (file)
@@ -112,9 +112,24 @@ func newUploader(rcfg RunConfig) (*uploader, error) {
        logger := log.New(logWriter, "", log.Ltime|log.Lmicroseconds|log.Lshortfile)
 
        // Fetch the upload config, if it is not provided.
-       config, configVersion, err := configstore.Download("latest", rcfg.Env)
-       if err != nil {
-               return nil, err
+       var (
+               config        *telemetry.UploadConfig
+               configVersion string
+       )
+
+       if mode, _ := dir.Mode(); mode == "on" {
+               // golang/go#68946: only download the upload config if it will be used.
+               //
+               // TODO(rfindley): This is a narrow change aimed at minimally fixing the
+               // associated bug. In the future, we should read the mode only once during
+               // the upload process.
+               config, configVersion, err = configstore.Download("latest", rcfg.Env)
+               if err != nil {
+                       return nil, err
+               }
+       } else {
+               config = &telemetry.UploadConfig{}
+               configVersion = "v0.0.0-0"
        }
 
        // Set the start time, if it is not provided.
index 4b37a5c3945cd551c6046a5de25f72b33b31f5b5..69ebcc7135940599a88c4cb7506e2088e6a20261 100644 (file)
@@ -206,7 +206,8 @@ func startChild(reportCrashes, upload bool, result *StartResult) {
        fd, err := os.Stat(telemetry.Default.DebugDir())
        if err != nil {
                if !os.IsNotExist(err) {
-                       log.Fatalf("failed to stat debug directory: %v", err)
+                       log.Printf("failed to stat debug directory: %v", err)
+                       return
                }
        } else if fd.IsDir() {
                // local/debug exists and is a directory. Set stderr to a log file path
@@ -214,23 +215,31 @@ func startChild(reportCrashes, upload bool, result *StartResult) {
                childLogPath := filepath.Join(telemetry.Default.DebugDir(), "sidecar.log")
                childLog, err := os.OpenFile(childLogPath, os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0600)
                if err != nil {
-                       log.Fatalf("opening sidecar log file for child: %v", err)
+                       log.Printf("opening sidecar log file for child: %v", err)
+                       return
                }
                defer childLog.Close()
                cmd.Stderr = childLog
        }
 
+       var crashOutputFile *os.File
        if reportCrashes {
                pipe, err := cmd.StdinPipe()
                if err != nil {
-                       log.Fatalf("StdinPipe: %v", err)
+                       log.Printf("StdinPipe: %v", err)
+                       return
                }
 
-               crashmonitor.Parent(pipe.(*os.File)) // (this conversion is safe)
+               crashOutputFile = pipe.(*os.File) // (this conversion is safe)
        }
 
        if err := cmd.Start(); err != nil {
-               log.Fatalf("can't start telemetry child process: %v", err)
+               // The child couldn't be started. Log the failure.
+               log.Printf("can't start telemetry child process: %v", err)
+               return
+       }
+       if reportCrashes {
+               crashmonitor.Parent(crashOutputFile)
        }
        result.wg.Add(1)
        go func() {
index c99bc74ce0fd2fa1c659b90e85181be85307be40..698b0255b310e225f52a9a22442ba249fa82d74b 100644 (file)
@@ -46,7 +46,7 @@ golang.org/x/sync/semaphore
 golang.org/x/sys/plan9
 golang.org/x/sys/unix
 golang.org/x/sys/windows
-# golang.org/x/telemetry v0.0.0-20240807181058-38c23d25f755
+# golang.org/x/telemetry v0.0.0-20240828202201-a797f331ea97
 ## explicit; go 1.20
 golang.org/x/telemetry
 golang.org/x/telemetry/counter