Skip to content
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

[PA-225] Restart PX on Nodes where pds pods have attached volumes #916

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

bhsrinivasan-px
Copy link
Contributor

What this PR does / why we need it:
Part of the system test automation suite

Which issue(s) this PR fixes (optional)
Closes # PA-225

Special notes for your reviewer:

err = wait.Poll(maxtimeInterval, timeOut, func() (bool, error) {
ss, err = k8sApps.GetStatefulSet(deployment.GetClusterResourceName(), namespace)
if err != nil {
logrus.Warnf("An Error Occured while getting statefulsets %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use new log instance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?

drivers/pds/lib/utils.go Outdated Show resolved Hide resolved
drivers/pds/lib/utils.go Outdated Show resolved Hide resolved
drivers/pds/lib/utils.go Show resolved Hide resolved
drivers/pds/lib/utils.go Show resolved Hide resolved
for _, ds := range params.DataServiceToTest {
isDeploymentsDeleted = false
dataServiceDefaultResourceTemplateID, err = pdslib.GetResourceTemplate(tenantID, ds.Name)
Expect(err).NotTo(HaveOccurred())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use dash for the verifications

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?

Expect(err).NotTo(HaveOccurred())
Expect(dataServiceDefaultAppConfigID).NotTo(BeEmpty())

logrus.Infof(" dataServiceDefaultAppConfigID %v ", dataServiceDefaultAppConfigID)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use log instance for logging

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you mean?

Comment on lines +1366 to +1370
func LabelK8sNode(node *corev1.Node, label string) error {
keyval := strings.Split(label, "=")
err := k8sCore.AddLabelOnNode(node.Name, keyval[0], keyval[1])
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the point of creating this function if it doesn't do anything different than the function you are using inside. Just use the k8sCore.AddLabelOnNode() and remove this func

Comment on lines +1372 to +1375
func RemoveLabelFromK8sNode(node *corev1.Node, label string) error {
err := k8sCore.RemoveLabelOnNode(node.Name, label)
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, here just use the sched-ops func k8sCore.RemoveLabelOnNode(), wrapping it into another func doesn't add any value

Comment on lines +1377 to +1387
func UnCordonK8sNode(node *corev1.Node) error {
err = wait.Poll(maxtimeInterval, timeOut, func() (bool, error) {
err = k8sCore.UnCordonNode(node.Name, timeOut, maxtimeInterval)
if err != nil {
logrus.Errorf("Failed uncordon node %v due to %v", node.Name, err)
return false, nil
}
return true, nil
})
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, why not just use already existing sched-ops func k8sCore.UnCordonNode()? and give it a timeout and interval instead of wrapping it into a whole new func?

Comment on lines +1395 to +1396
logrus.Errorf("Failed to get pods from node %v due to %v", nodeName, err)
return false, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If err is not nil, you need to return it and please remove the logrus.Errorf() and just return the verbose error like so

		if err != nil {
			return false, fmt.Errorf("Failed to get pods from node [%s], Err %v", nodeName, err)
 		}

Comment on lines +1400 to +1403
if err != nil {
logrus.Errorf("Could not fetch pods running on the given node %v", err)
return false, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, just return and add nodeName

	if err != nil {
		return false, fmt.Errorf("Could not fetch pods running on the given node [%s], Err: %v", nodeName, err)
	}

Comment on lines +1328 to +1331
if err != nil {
logrus.Errorf("An Error Occured while getting statefulsets %v", err)
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return verbose error, don't print it, we will print it in the initial place where this func is called

Comment on lines +1333 to +1335
if err != nil {
logrus.Errorf("An error occured while getting the pods belonging to this statefulset %v", err)
return nil, err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, just return verbose error, don't print it, we will print it in the initial place where this func is called

Comment on lines +1342 to +1345
if err != nil {
logrus.Errorf("Could not get the node object for node %v because %v", nodeName, err)
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, just return verbose error, don't print it, we will print it in the initial place where this func is called

Comment on lines +1352 to +1355
if err != nil {
logrus.Errorf("Could not fetch pods running on the given node %v", err)
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, just return verbose error, don't print it, we will print it in the initial place where this func is called

Comment on lines +1358 to +1361
if err != nil {
logrus.Errorf("Could not drain the node %v", err)
return err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, just return verbose error, don't print it, we will print it in the initial place where this func is called

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants