]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.23] cmd: vendor golang.org/x/telemetry@internal-branch.go1.23...
authorMichael Pratt <mpratt@google.com>
Wed, 28 Aug 2024 21:45:44 +0000 (17:45 -0400)
committerGopher Robot <gobot@golang.org>
Thu, 29 Aug 2024 00:09:27 +0000 (00:09 +0000)
Update x/telemetry to fix #68976 and #68946.

Commands run:
  go get golang.org/x/telemetry@internal-branch.go1.23-vendor
  go mod tidy
  go mod vendor

Fixes #68994.
Fixes #68995.

Change-Id: I63b892ad4c313aa92f21fbd4f519a0b19d725849
Reviewed-on: https://go-review.googlesource.com/c/go/+/609355
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Robert Findley <rfindley@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 49f02012d3103a9cea5e7676252431aca3e897f9..484fef03d10a16934bf95810e104310bc34a1809 100644 (file)
@@ -9,7 +9,7 @@ require (
        golang.org/x/mod v0.19.0
        golang.org/x/sync v0.7.0
        golang.org/x/sys v0.22.0
-       golang.org/x/telemetry v0.0.0-20240717194752-0b706e19b701
+       golang.org/x/telemetry v0.0.0-20240828213427-40b6b7fe7147
        golang.org/x/term v0.20.0
        golang.org/x/tools v0.22.1-0.20240618181713-f2d2ebe43e72
 )
index ee671f951223443300036508fca0d7c6a9a914e8..919dbd2dc74c74e1f715985af9e31bee1c871ad6 100644 (file)
@@ -16,8 +16,8 @@ golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
 golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
 golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
 golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
-golang.org/x/telemetry v0.0.0-20240717194752-0b706e19b701 h1:+bltxAtk8YFEQ61B/lcYQM8e+7XjLwSDbpspVaVYkz8=
-golang.org/x/telemetry v0.0.0-20240717194752-0b706e19b701/go.mod h1:amNmu/SBSm2GAF3X+9U2C0epLocdh+r5Z+7oMYO5cLM=
+golang.org/x/telemetry v0.0.0-20240828213427-40b6b7fe7147 h1:Lj8KbuZmoFUbI6pQ28G3Diz/5bRYD2UY5vfAmhrLZWo=
+golang.org/x/telemetry v0.0.0-20240828213427-40b6b7fe7147/go.mod h1:amNmu/SBSm2GAF3X+9U2C0epLocdh+r5Z+7oMYO5cLM=
 golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
 golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
 golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
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 bf9c1341b94f739260421cb6c8737bae773d612a..22d40b9e4c13855eec5417a9878b0314f88edf7c 100644 (file)
@@ -45,7 +45,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-20240717194752-0b706e19b701
+# golang.org/x/telemetry v0.0.0-20240828213427-40b6b7fe7147
 ## explicit; go 1.20
 golang.org/x/telemetry
 golang.org/x/telemetry/counter