Skip to content

Commit

Permalink
fix: return error first before accessing fields that might be nil in …
Browse files Browse the repository at this point in the history
…extractLogsFromVM (Azure#4855)

Co-authored-by: Mikolaj Umanski <[email protected]>
  • Loading branch information
UtheMan and Mikolaj Umanski authored Aug 21, 2024
1 parent b435639 commit 549be25
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions e2e/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func extractLogsFromVM(ctx context.Context, t *testing.T, vmssName, privateIP, s
t.Logf("executing command on remote VM at %s of VMSS %s: %q", privateIP, vmssName, sourceCmd)

execResult, err := execOnVM(ctx, opts.clusterConfig.Kube, privateIP, podName, sshPrivateKey, sourceCmd, false)
if err != nil {
t.Logf("error executing command on remote VM at %s of VMSS %s: %s", privateIP, vmssName, err)
return nil, err
}

if execResult.stdout != nil {
out := execResult.stdout.String()
if out != "" {
Expand All @@ -84,10 +89,6 @@ func extractLogsFromVM(ctx context.Context, t *testing.T, vmssName, privateIP, s
result[file+".stderr.txt"] = out
}
}

if err != nil {
t.Logf("error executing command on remote VM at %s of VMSS %s: %s", privateIP, vmssName, err)
}
}
return result, nil
}
Expand Down

0 comments on commit 549be25

Please sign in to comment.