summaryrefslogtreecommitdiff
path: root/pkg/machine/keys.go
diff options
context:
space:
mode:
authoropenshift-ci[bot] <75433959+openshift-ci[bot]@users.noreply.github.com>2022-06-30 17:58:28 +0000
committerGitHub <noreply@github.com>2022-06-30 17:58:28 +0000
commit01beba3667851c1dd68d3df1e0aa6bc8cb1ec0eb (patch)
tree23cf8c7ae65ff511c1f432d1c43c734a33c48e88 /pkg/machine/keys.go
parent5a222a8e601b2ef413c39edf5d49d2f140d7a72b (diff)
parent99f68898c0f1c4564cebd6a3ee18418c74684403 (diff)
downloadpodman-01beba3667851c1dd68d3df1e0aa6bc8cb1ec0eb.tar.gz
podman-01beba3667851c1dd68d3df1e0aa6bc8cb1ec0eb.tar.bz2
podman-01beba3667851c1dd68d3df1e0aa6bc8cb1ec0eb.zip
Merge pull request #14704 from baude/machinestopped
reveal machine error, ignore false state
Diffstat (limited to 'pkg/machine/keys.go')
-rw-r--r--pkg/machine/keys.go21
1 files changed, 19 insertions, 2 deletions
diff --git a/pkg/machine/keys.go b/pkg/machine/keys.go
index 45d9801cc..463271427 100644
--- a/pkg/machine/keys.go
+++ b/pkg/machine/keys.go
@@ -4,14 +4,15 @@
package machine
import (
- "errors"
"fmt"
+ "io"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"strings"
+ "github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -51,7 +52,23 @@ func CreateSSHKeysPrefix(dir string, file string, passThru bool, skipExisting bo
// generatekeys creates an ed25519 set of keys
func generatekeys(writeLocation string) error {
args := append(append([]string{}, sshCommand[1:]...), writeLocation)
- return exec.Command(sshCommand[0], args...).Run()
+ cmd := exec.Command(sshCommand[0], args...)
+ stdErr, err := cmd.StderrPipe()
+ if err != nil {
+ return err
+ }
+ if err := cmd.Start(); err != nil {
+ return err
+ }
+ waitErr := cmd.Wait()
+ if waitErr == nil {
+ return nil
+ }
+ errMsg, err := io.ReadAll(stdErr)
+ if err != nil {
+ return fmt.Errorf("key generation failed, unable to read from stderr: %w", waitErr)
+ }
+ return fmt.Errorf("failed to generate keys: %s: %w", string(errMsg), waitErr)
}
// generatekeys creates an ed25519 set of keys