Exemple #1
0
func coreDump(dir string) {
	c, err := loadClient()
	if err != nil {
		fmt.Printf("Error creating client: %v", err)
		return
	}
	provider := testContext.Provider

	// requires ssh
	if !providerIs("gce", "gke") {
		fmt.Printf("Skipping SSH core dump, which is not implemented for %s", provider)
		return
	}

	// Get all nodes' external IPs.
	hosts, err := ssh.NodeSSHHosts(c)
	if err != nil {
		fmt.Printf("Error getting node hostnames: %v", err)
		return
	}

	cmds := []command{
		{"cat /var/log/kubelet.log", "kubelet"},
		{"cat /var/log/kube-proxy.log", "kube-proxy"},
		{"cat /var/log/monit.log", "monit"},
	}
	logCore(cmds, hosts, dir, provider)

	// I wish there was a better way to get the master IP...
	config, err := loadConfig()
	if err != nil {
		fmt.Printf("Error loading config: %v")
	}
	ix := strings.LastIndex(config.Host, "/")
	master := net.JoinHostPort(config.Host[ix+1:], "22")
	cmds = []command{
		{"cat /var/log/kubelet.log", "kubelet"},
		{"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"},
		{"cat /var/log/monit.log", "monit"},
	}
	logCore(cmds, []string{master}, dir, provider)
}
Exemple #2
0
var _ = Describe("SSH", func() {
	var c *client.Client

	BeforeEach(func() {
		var err error
		c, err = loadClient()
		Expect(err).NotTo(HaveOccurred())

		// When adding more providers here, also implement their functionality in util.go's getSigner(...).
		SkipUnlessProviderIs("gce", "gke")
	})

	It("should SSH to all nodes and run commands", func() {
		// Get all nodes' external IPs.
		By("Getting all nodes' SSH-able IP addresses")
		hosts, err := ssh.NodeSSHHosts(c)
		if err != nil {
			Failf("Error getting node hostnames: %v", err)
		}

		testCases := []struct {
			cmd            string
			checkStdout    bool
			expectedStdout string
			expectedStderr string
			expectedCode   int
			expectedError  error
		}{
			{`echo "Hello"`, true, "Hello", "", 0, nil},
			// Same as previous, but useful for test output diagnostics.
			{`echo "Hello from $(whoami)@$(hostname)"`, false, "", "", 0, nil},