Skip to content

Commit decc9ee

Browse files
GCP Server AutoDiscover: only log when the script fails
When running Auto Discover for GCP VMs, teleport always logs the output in debug level. Now, it only logs the stdout/stderr when the installation fails. It also adds some context on which VMs it failed and the log level is now Error.
1 parent 0550380 commit decc9ee

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/cloud/gcp/vm.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,13 +578,17 @@ https://cloud.google.com/solutions/connecting-securely#storing_host_keys_by_enab
578578
for _, ip := range ipAddrs {
579579
addr := net.JoinHostPort(ip, req.SSHPort)
580580
stdout, stderr, err := sshutils.RunSSH(ctx, addr, req.Script, config, sshutils.WithDialer(req.dialContext))
581-
slog.DebugContext(ctx, "Command completed",
582-
"stdoout", string(stdout),
583-
"stderr", string(stderr),
584-
)
585581
if err == nil {
586582
return nil
587583
}
584+
slog.ErrorContext(ctx, "Installing teleport in GCP VM completed with error",
585+
"project_id", req.ProjectID,
586+
"zone", req.Zone,
587+
"vm_name", req.Name,
588+
"error", err,
589+
"stdoout", string(stdout),
590+
"stderr", string(stderr),
591+
)
588592

589593
// An exit error means the connection was successful, so don't try another address.
590594
if errors.Is(err, &ssh.ExitError{}) {

0 commit comments

Comments
 (0)