{"record":{"id":"2706179497118fa3","repo":"kubernetes/kops","slug":"getting-process-name-w","errorCode":null,"errorMessage":"getting process name: %w","messagePattern":"getting process name: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kops/otel.go","lineNumber":123,"sourceCode":"\t}\n\tif dest == \"\" {\n\t\tdest = os.Getenv(\"OTEL_EXPORTER_OTLP_DIR\")\n\t\tif dest != \"\" {\n\t\t\tdestIsDirectory = true\n\t\t}\n\t}\n\tif dest == \"\" {\n\t\treturn nil, nil\n\t}\n\n\t// If we are writing to a directory, construct a (likely) unique name\n\tif destIsDirectory {\n\t\tif err := os.MkdirAll(dest, 0755); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"creating directories %q: %w\", dest, err)\n\t\t}\n\t\tprocessName, err := os.Executable()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"getting process name: %w\", err)\n\t\t}\n\t\tprocessName = filepath.Base(processName)\n\t\tprocessName = strings.TrimSuffix(processName, \".exe\")\n\t\tpid := os.Getpid()\n\t\ttimestamp := time.Now().UTC().Format(time.RFC3339)\n\t\tfilename := fmt.Sprintf(\"%s-%d-%s.otel\", processName, pid, timestamp)\n\t\tdest = filepath.Join(dest, filename)\n\t}\n\n\ttraceExporter, err := otlptracefile.New(ctx, otlptracefile.WithPath(dest))\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\ttraceProvider := trace.NewTracerProvider(\n\t\ttrace.WithBatcher(traceExporter,\n\t\t\t// Default is 5s. Set to 1s for demonstrative purposes.\n\t\t\ttrace.WithBatchTimeout(time.Second)),","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/cmd/kops/otel.go#L105-L141","documentation":"kOps' OpenTelemetry setup derives the trace-exporter filename from the running executable's path. When os.Executable() fails (e.g. the binary path cannot be resolved), newTraceProvider wraps the failure as \"getting process name\" and aborts SDK initialization.","triggerScenarios":"Running the kops binary in an environment where the kernel cannot supply /proc/self/exe or equivalent: the binary was deleted/replaced while running, or running in a minimal container/chroot where procfs is not mounted.","commonSituations":"Running kops inside scratch/DISTROLESS containers without /proc mounted; invoking the binary via a deleted file descriptor; exotic sandbox environments (some CI runners, nsjail) where os.Executable() returns ENOENT.","solutions":["Mount /proc (or ensure procfs is available) in the container/sandbox running kops","Re-download or restore the kops binary if it was deleted or moved while in use","Run the binary from a real filesystem path rather than via /proc/<pid>/fd or a deleted inode","If the failure persists, pass a disable/OTel-off flag so newTraceProvider is not invoked"],"exampleFix":"// before (container without procfs)\n// docker run --restart ... kops ...\n// after\n// docker run --restart ... -v /proc:/proc:rw kops ...  (or use an image with proc mounted)","handlingStrategy":"fallback","validationCode":"if _, err := os.Executable(); err != nil {\n\tlog.Fatalf(\"cannot resolve executable path (is /proc mounted?): %v\", err)\n}","typeGuard":null,"tryCatchPattern":"provider, err := newTraceProvider(ctx)\nif err != nil {\n\tlog.Printf(\"otel disabled, continuing without tracing: %v\", err)\n\treturn nil\n}","preventionTips":["Run kops in containers with /proc mounted","Never delete or replace the binary while it is executing; use atomic rename to a new inode and restart","Verify the binary runs from a real filesystem path, not a deleted fd"],"tags":["otel","telemetry","linux","binary"],"backgroundTag":"executable-path-unresolvable","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}