-
Notifications
You must be signed in to change notification settings - Fork 39.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make various fixes to flex tests and fix some crashes #65536
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,56 +72,58 @@ func testFlexVolume(driver string, cs clientset.Interface, config framework.Volu | |
// installFlex installs the driver found at filePath on the node, and restarts | ||
// kubelet if 'restart' is true. If node is nil, installs on the master, and restarts | ||
// controller-manager if 'restart' is true. | ||
func installFlex(c clientset.Interface, node *v1.Node, vendor, driver, filePath string, restart bool) { | ||
func installFlex(c clientset.Interface, node *v1.Node, vendor, driver, filePath string) { | ||
flexDir := getFlexDir(c, node, vendor, driver) | ||
flexFile := path.Join(flexDir, driver) | ||
|
||
host := "" | ||
var err error | ||
if node != nil { | ||
host = framework.GetNodeExternalIP(node) | ||
host, err = framework.GetNodeExternalIP(node) | ||
if err != nil { | ||
host, err = framework.GetNodeInternalIP(node) | ||
} | ||
} else { | ||
host = net.JoinHostPort(framework.GetMasterHost(), sshPort) | ||
masterHostWithPort := framework.GetMasterHost() | ||
hostName := getHostFromHostPort(masterHostWithPort) | ||
host = net.JoinHostPort(hostName, sshPort) | ||
} | ||
|
||
framework.ExpectNoError(err) | ||
|
||
cmd := fmt.Sprintf("sudo mkdir -p %s", flexDir) | ||
sshAndLog(cmd, host) | ||
sshAndLog(cmd, host, true /*failOnError*/) | ||
|
||
data := generated.ReadOrDie(filePath) | ||
cmd = fmt.Sprintf("sudo tee <<'EOF' %s\n%s\nEOF", flexFile, string(data)) | ||
sshAndLog(cmd, host) | ||
sshAndLog(cmd, host, true /*failOnError*/) | ||
|
||
cmd = fmt.Sprintf("sudo chmod +x %s", flexFile) | ||
sshAndLog(cmd, host) | ||
|
||
if !restart { | ||
return | ||
} | ||
|
||
if node != nil { | ||
err := framework.RestartKubelet(host) | ||
framework.ExpectNoError(err) | ||
err = framework.WaitForKubeletUp(host) | ||
framework.ExpectNoError(err) | ||
} else { | ||
err := framework.RestartControllerManager() | ||
framework.ExpectNoError(err) | ||
err = framework.WaitForControllerManagerUp() | ||
framework.ExpectNoError(err) | ||
} | ||
sshAndLog(cmd, host, true /*failOnError*/) | ||
} | ||
|
||
func uninstallFlex(c clientset.Interface, node *v1.Node, vendor, driver string) { | ||
flexDir := getFlexDir(c, node, vendor, driver) | ||
|
||
host := "" | ||
var err error | ||
if node != nil { | ||
host = framework.GetNodeExternalIP(node) | ||
host, err = framework.GetNodeExternalIP(node) | ||
if err != nil { | ||
host, err = framework.GetNodeInternalIP(node) | ||
} | ||
} else { | ||
host = net.JoinHostPort(framework.GetMasterHost(), sshPort) | ||
masterHostWithPort := framework.GetMasterHost() | ||
hostName := getHostFromHostPort(masterHostWithPort) | ||
host = net.JoinHostPort(hostName, sshPort) | ||
} | ||
|
||
if host == "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this check? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think yes for printing proper error when we can't determine external or internal ip for some reason. Before this change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need to check if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean having Removing this check altogether means - There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry I wasn't clear. I meant that if host == "" {
framework.ExpectNoError(err)
} is equivalent to only
because there's an error only if host == "" in the implementations of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
framework.Failf("Error getting node ip : %v", err) | ||
} | ||
|
||
cmd := fmt.Sprintf("sudo rm -r %s", flexDir) | ||
sshAndLog(cmd, host) | ||
sshAndLog(cmd, host, false /*failOnError*/) | ||
} | ||
|
||
func getFlexDir(c clientset.Interface, node *v1.Node, vendor, driver string) string { | ||
|
@@ -150,11 +152,11 @@ func getFlexDir(c clientset.Interface, node *v1.Node, vendor, driver string) str | |
return flexDir | ||
} | ||
|
||
func sshAndLog(cmd, host string) { | ||
func sshAndLog(cmd, host string, failOnError bool) { | ||
result, err := framework.SSH(cmd, host, framework.TestContext.Provider) | ||
framework.LogSSHResult(result) | ||
framework.ExpectNoError(err) | ||
if result.Code != 0 { | ||
if result.Code != 0 && failOnError { | ||
framework.Failf("%s returned non-zero, stderr: %s", cmd, result.Stderr) | ||
} | ||
} | ||
|
@@ -177,7 +179,18 @@ func getNodeVersion(node *v1.Node) *versionutil.Version { | |
return versionutil.MustParseSemantic(node.Status.NodeInfo.KubeletVersion) | ||
} | ||
|
||
var _ = utils.SIGDescribe("Flexvolumes [Disruptive]", func() { | ||
func getHostFromHostPort(hostPort string) string { | ||
// try to split host and port | ||
var host string | ||
var err error | ||
if host, _, err = net.SplitHostPort(hostPort); err != nil { | ||
// if SplitHostPort returns an error, the entire hostport is considered as host | ||
host = hostPort | ||
} | ||
return host | ||
} | ||
|
||
var _ = utils.SIGDescribe("Flexvolumes", func() { | ||
f := framework.NewDefaultFramework("flexvolume") | ||
|
||
// note that namespace deletion is handled by delete-namespace flag | ||
|
@@ -189,9 +202,9 @@ var _ = utils.SIGDescribe("Flexvolumes [Disruptive]", func() { | |
var suffix string | ||
|
||
BeforeEach(func() { | ||
framework.SkipUnlessProviderIs("gce") | ||
framework.SkipUnlessMasterOSDistroIs("gci") | ||
framework.SkipUnlessNodeOSDistroIs("debian", "gci") | ||
framework.SkipUnlessProviderIs("gce", "local") | ||
framework.SkipUnlessMasterOSDistroIs("debian", "ubuntu", "gci") | ||
framework.SkipUnlessNodeOSDistroIs("debian", "ubuntu", "gci") | ||
framework.SkipUnlessSSHKeyPresent() | ||
|
||
cs = f.ClientSet | ||
|
@@ -211,7 +224,7 @@ var _ = utils.SIGDescribe("Flexvolumes [Disruptive]", func() { | |
driverInstallAs := driver + "-" + suffix | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need the test "should install plugin without kubelet restart" anymore, it's exactly the same as this test There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
||
By(fmt.Sprintf("installing flexvolume %s on node %s as %s", path.Join(driverDir, driver), node.Name, driverInstallAs)) | ||
installFlex(cs, &node, "k8s", driverInstallAs, path.Join(driverDir, driver), true /* restart */) | ||
installFlex(cs, &node, "k8s", driverInstallAs, path.Join(driverDir, driver)) | ||
|
||
testFlexVolume(driverInstallAs, cs, config, f) | ||
|
||
|
@@ -229,9 +242,9 @@ var _ = utils.SIGDescribe("Flexvolumes [Disruptive]", func() { | |
driverInstallAs := driver + "-" + suffix | ||
|
||
By(fmt.Sprintf("installing flexvolume %s on node %s as %s", path.Join(driverDir, driver), node.Name, driverInstallAs)) | ||
installFlex(cs, &node, "k8s", driverInstallAs, path.Join(driverDir, driver), true /* restart */) | ||
installFlex(cs, &node, "k8s", driverInstallAs, path.Join(driverDir, driver)) | ||
By(fmt.Sprintf("installing flexvolume %s on master as %s", path.Join(driverDir, driver), driverInstallAs)) | ||
installFlex(cs, nil, "k8s", driverInstallAs, path.Join(driverDir, driver), true /* restart */) | ||
installFlex(cs, nil, "k8s", driverInstallAs, path.Join(driverDir, driver)) | ||
|
||
testFlexVolume(driverInstallAs, cs, config, f) | ||
|
||
|
@@ -245,22 +258,4 @@ var _ = utils.SIGDescribe("Flexvolumes [Disruptive]", func() { | |
By(fmt.Sprintf("uninstalling flexvolume %s from master", driverInstallAs)) | ||
uninstallFlex(cs, nil, "k8s", driverInstallAs) | ||
}) | ||
|
||
It("should install plugin without kubelet restart", func() { | ||
driver := "dummy" | ||
driverInstallAs := driver + "-" + suffix | ||
|
||
By(fmt.Sprintf("installing flexvolume %s on node %s as %s", path.Join(driverDir, driver), node.Name, driverInstallAs)) | ||
installFlex(cs, &node, "k8s", driverInstallAs, path.Join(driverDir, driver), false /* restart */) | ||
|
||
testFlexVolume(driverInstallAs, cs, config, f) | ||
|
||
By("waiting for flex client pod to terminate") | ||
if err := f.WaitForPodTerminated(config.Prefix+"-client", ""); !apierrs.IsNotFound(err) { | ||
framework.ExpectNoError(err, "Failed to wait client pod terminated: %v", err) | ||
} | ||
|
||
By(fmt.Sprintf("uninstalling flexvolume %s from node %s", driverInstallAs, node.Name)) | ||
uninstallFlex(cs, &node, "k8s", driverInstallAs) | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch!