|
8 | 8 | "os"
|
9 | 9 | "os/exec"
|
10 | 10 | "path/filepath"
|
| 11 | + "strings" |
11 | 12 | "time"
|
12 | 13 |
|
13 | 14 | "github.com/Azure/acs-engine/test/e2e/azure"
|
@@ -199,16 +200,57 @@ func (cli *CLIProvisioner) waitForNodes() error {
|
199 | 200 | return nil
|
200 | 201 | }
|
201 | 202 |
|
202 |
| -// FetchProvisioningMetrics gets a file from the master |
203 |
| -func (cli *CLIProvisioner) FetchProvisioningMetrics(path string) ([]byte, error) { |
| 203 | +// FetchProvisioningMetrics gets provisioning files from all hosts in a cluster |
| 204 | +func (cli *CLIProvisioner) FetchProvisioningMetrics(path string, cfg *config.Config, acct *azure.Account) error { |
| 205 | + var masters, agents []string |
| 206 | + hosts, err := acct.GetHosts("") |
| 207 | + if err != nil { |
| 208 | + return err |
| 209 | + } |
| 210 | + for _, host := range hosts { |
| 211 | + if strings.Contains(host.Name, "master") { |
| 212 | + masters = append(masters, host.Name) |
| 213 | + } else if strings.Contains(host.Name, "agent") { |
| 214 | + agents = append(agents, host.Name) |
| 215 | + } |
| 216 | + } |
| 217 | + agentFiles := []string{"/var/log/azure/cluster-provision.log", "/var/log/cloud-init.log", |
| 218 | + "/var/log/cloud-init-output.log", "/var/log/syslog", "/var/log/azure/custom-script/handler.log", |
| 219 | + "/opt/m", "/opt/azure/containers/kubelet.sh", "/opt/azure/containers/provision.sh", |
| 220 | + "/opt/azure/provision-ps.log", "/var/log/azure/dnsdump.pcap"} |
| 221 | + masterFiles := agentFiles |
| 222 | + masterFiles = append(masterFiles, "/opt/azure/containers/mountetcd.sh", "/opt/azure/containers/setup-etcd.sh") |
204 | 223 | hostname := fmt.Sprintf("%s.%s.cloudapp.azure.com", cli.Config.Name, cli.Config.Location)
|
205 | 224 | conn, err := remote.NewConnection(hostname, "22", cli.Engine.ClusterDefinition.Properties.LinuxProfile.AdminUsername, cli.Config.GetSSHKeyPath())
|
206 | 225 | if err != nil {
|
207 |
| - return nil, err |
| 226 | + return err |
| 227 | + } |
| 228 | + for _, master := range masters { |
| 229 | + for _, fp := range masterFiles { |
| 230 | + err := conn.CopyRemote(master, fp) |
| 231 | + if err != nil { |
| 232 | + return fmt.Errorf("Error reading file from path (%s):%s", path, err) |
| 233 | + } |
| 234 | + } |
| 235 | + } |
| 236 | + |
| 237 | + for _, agent := range agents { |
| 238 | + for _, fp := range agentFiles { |
| 239 | + err := conn.CopyRemote(agent, fp) |
| 240 | + if err != nil { |
| 241 | + return fmt.Errorf("Error reading file from path (%s):%s", path, err) |
| 242 | + } |
| 243 | + } |
208 | 244 | }
|
209 |
| - data, err := conn.Read(path) |
| 245 | + connectString := fmt.Sprintf("%s@%s:/tmp/k8s-*", conn.User, hostname) |
| 246 | + logsPath := filepath.Join(cfg.CurrentWorkingDir, "_logs", hostname) |
| 247 | + cmd := exec.Command("scp", "-i", conn.PrivateKeyPath, "-o", "ConnectTimeout=30", "-o", "StrictHostKeyChecking=no", connectString, logsPath) |
| 248 | + util.PrintCommand(cmd) |
| 249 | + out, err := cmd.CombinedOutput() |
210 | 250 | if err != nil {
|
211 |
| - return nil, fmt.Errorf("Error reading file from path (%s):%s", path, err) |
| 251 | + log.Printf("Error output:%s\n", out) |
| 252 | + return err |
212 | 253 | }
|
213 |
| - return data, nil |
| 254 | + |
| 255 | + return nil |
214 | 256 | }
|
0 commit comments