Commit c0024626 authored by Marek Grabowski's avatar Marek Grabowski

Merge pull request #21307 from wojtek-t/store_master_logs_in_kubemark

Store logs from master components from Kubemark runs in GCS
parents 041d6bc7 3509f80b
...@@ -37,55 +37,61 @@ func CoreDump(dir string) { ...@@ -37,55 +37,61 @@ func CoreDump(dir string) {
} }
provider := testContext.Provider provider := testContext.Provider
// requires ssh // requires ssh to master machine
if !providerIs(providersWithSSH...) { if !providerIs(providersWithMasterSSH...) {
fmt.Printf("Skipping SSH core dump, which is not implemented for %s", provider) fmt.Printf("Skipping SSH core dump, which is not implemented for %s", provider)
return return
} }
// Get all nodes' external IPs. // I wish there was a better way to get the master IP...
hosts, err := NodeSSHHosts(c) config, err := loadConfig()
if err != nil { if err != nil {
fmt.Printf("Error getting node hostnames: %v", err) fmt.Printf("Error loading config: %v", err)
return
} }
ix := strings.LastIndex(config.Host, "/")
master := net.JoinHostPort(config.Host[ix+1:], "22")
cmds := []command{{"cat /var/log/kube-proxy.log", "kube-proxy"}} cmds := []command{
if isUsingSystemdKubelet(provider, hosts...) { {"cat /var/log/kube-apiserver.log", "kube-apiserver"},
{"cat /var/log/kube-scheduler.log", "kube-scheduler"},
{"cat /var/log/kube-controller-manager.log", "kube-controller-manager"},
}
if isUsingSystemdKubelet(provider, master) {
cmds = append(cmds, command{"sudo journalctl --output=cat -u kubelet.service", "kubelet"}) cmds = append(cmds, command{"sudo journalctl --output=cat -u kubelet.service", "kubelet"})
} else { } else {
cmds = append(cmds, []command{ cmds = append(cmds, []command{
{"cat /var/log/kubelet.log", "kubelet"}, {"cat /var/log/kubelet.log", "kubelet"},
{"cat /var/log/supervisor/supervisord.log", "supervisord"}, {"cat /var/log/supervisor/supervisord.log", "supervisord"},
{"cat /var/log/dmesg", "dmesg"},
}...) }...)
} }
logCore(cmds, hosts, dir, provider) logCore(cmds, []string{master}, dir, provider)
// I wish there was a better way to get the master IP... // requires ssh
config, err := loadConfig() if !providerIs(providersWithSSH...) {
if err != nil { fmt.Printf("Skipping SSH core dump for nodes, which is not implemented for %s", provider)
fmt.Printf("Error loading config: %v", err) return
} }
ix := strings.LastIndex(config.Host, "/")
master := net.JoinHostPort(config.Host[ix+1:], "22")
cmds = []command{ // Get all nodes' external IPs.
{"cat /var/log/kube-apiserver.log", "kube-apiserver"}, hosts, err := NodeSSHHosts(c)
{"cat /var/log/kube-scheduler.log", "kube-scheduler"}, if err != nil {
{"cat /var/log/kube-controller-manager.log", "kube-controller-manager"}, fmt.Printf("Error getting node hostnames: %v", err)
return
} }
if isUsingSystemdKubelet(provider, master) {
cmds = []command{{"cat /var/log/kube-proxy.log", "kube-proxy"}}
if isUsingSystemdKubelet(provider, hosts...) {
cmds = append(cmds, command{"sudo journalctl --output=cat -u kubelet.service", "kubelet"}) cmds = append(cmds, command{"sudo journalctl --output=cat -u kubelet.service", "kubelet"})
} else { } else {
cmds = append(cmds, []command{ cmds = append(cmds, []command{
{"cat /var/log/kubelet.log", "kubelet"}, {"cat /var/log/kubelet.log", "kubelet"},
{"cat /var/log/supervisor/supervisord.log", "supervisord"}, {"cat /var/log/supervisor/supervisord.log", "supervisord"},
{"cat /var/log/dmesg", "dmesg"},
}...) }...)
} }
logCore(cmds, []string{master}, dir, provider) logCore(cmds, hosts, dir, provider)
} }
func logCore(cmds []command, hosts []string, dir, provider string) { func logCore(cmds []command, hosts []string, dir, provider string) {
......
...@@ -314,6 +314,9 @@ func SkipUnlessServerVersionGTE(v semver.Version, c client.ServerVersionInterfac ...@@ -314,6 +314,9 @@ func SkipUnlessServerVersionGTE(v semver.Version, c client.ServerVersionInterfac
// providersWithSSH are those providers where each node is accessible with SSH // providersWithSSH are those providers where each node is accessible with SSH
var providersWithSSH = []string{"gce", "gke", "aws"} var providersWithSSH = []string{"gce", "gke", "aws"}
// providersWithMasterSSH are those providers where master node is accessible with SSH
var providersWithMasterSSH = []string{"gce", "gke", "kubemark", "aws"}
type podCondition func(pod *api.Pod) (bool, error) type podCondition func(pod *api.Pod) (bool, error)
// podReady returns whether pod has a condition of Ready with a status of true. // podReady returns whether pod has a condition of Ready with a status of true.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment