Fix ssh to get logs in e2e tests
@@ -250,6 +250,13 @@ func (cli *CLIProvisioner) FetchProvisioningMetrics(path string, cfg *config.Con
masterFiles := agentFiles
masterFiles = append(masterFiles, "/opt/azure/containers/mountetcd.sh", "/opt/azure/containers/setup-etcd.sh", "/opt/azure/containers/setup-etcd.log")
hostname := fmt.Sprintf("%s.%s.cloudapp.azure.com", cli.Config.Name, cli.Config.Location)
+ cmd := exec.Command("ssh-agent", "-s")
+ out, err := cmd.CombinedOutput()
+ if err != nil {
+ return fmt.Errorf("Error while trying to start ssh agent:%s\nOutput:%s", err, out)
+ }
+ authSock := strings.Split(strings.Split(string(out), "=")[1], ";")
+ os.Setenv("SSH_AUTH_SOCK", authSock[0])
conn, err := remote.NewConnection(hostname, "22", cli.Engine.ClusterDefinition.Properties.LinuxProfile.AdminUsername, cli.Config.GetSSHKeyPath())
if err != nil {
return err
@@ -273,9 +280,9 @@ func (cli *CLIProvisioner) FetchProvisioningMetrics(path string, cfg *config.Con
}
connectString := fmt.Sprintf("%s@%s:/tmp/k8s-*", conn.User, hostname)
logsPath := filepath.Join(cfg.CurrentWorkingDir, "_logs", hostname)
- cmd := exec.Command("scp", "-i", conn.PrivateKeyPath, "-o", "ConnectTimeout=30", "-o", "StrictHostKeyChecking=no", connectString, logsPath)
+ cmd = exec.Command("scp", "-i", conn.PrivateKeyPath, "-o", "ConnectTimeout=30", "-o", "StrictHostKeyChecking=no", connectString, logsPath)
util.PrintCommand(cmd)
- out, err := cmd.CombinedOutput()
+ out, err = cmd.CombinedOutput()
if err != nil {
log.Printf("Error output:%s\n", out)
return err
