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

Code improvements #49

Merged
merged 25 commits into from
Mar 15, 2019
Merged

Code improvements #49

merged 25 commits into from
Mar 15, 2019

Conversation

ingvagabund
Copy link
Member

  • simplifying the code
  • making the code more readable

@openshift-ci-robot openshift-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Mar 13, 2019
@@ -117,175 +121,151 @@ func labelMachineSetNodes(client runtimeclient.Client, ms *mapiv1beta1.MachineSe
})
}

// Build default CA resource to allow fast scaling up and down
func clusterAutoscalerResource() *caov1alpha1.ClusterAutoscaler {
Copy link
Member

Choose a reason for hiding this comment

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

can we move this into utils?

Copy link
Member Author

Choose a reason for hiding this comment

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

I prefer to keep it in the same file as it is autoscaling specific. Unless it is needed in a different e2e/PACKAGE suite. The less we expose/export the better.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there's a lot to be said in having it scoped locally if it is only used locally, so +1 from me.

Copy link
Member

Choose a reason for hiding this comment

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

I was suggesting pkg/e2e/autoscaler/utils.go so no details are exposed on the ginkgo file, so it's smaller and just reads user stories. Not a blocker for me though

Copy link
Contributor

@frobware frobware left a comment

Choose a reason for hiding this comment

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

LGTM overall but there is a lot of changes here. I would like other folk on the team to take a pass through, then I'll come back for a second round. One nit is we should safely deref MachineSet.Spec.Replicas using pointer.Int32PtrDerefOr() throughout.

If a List operation fails, there is no point of retrying as the
operation will most likely fail for the second time again.

There is a chance the List operation can fail due to infrastructure issues,
e.g. network down, apiserver unreachable, etc. In those cases, entire
test suite will most likely fail.
If a List operation fails, there is no point of retrying as the
operation will most likely fail for the second time again.

There is a chance the List operation can fail due to infrastructure issues,
e.g. network down, apiserver unreachable, etc. In those cases, entire
test suite will most likely fail.
If a List operation fails, there is no point of retrying as the
operation will most likely fail for the second time again.

There is a chance the List operation can fail due to infrastructure issues,
e.g. network down, apiserver unreachable, etc. In those cases, entire
test suite will most likely fail.
Delete all objects of a given kind that match labels.
To simplify clean up code.
If any of CA/MA is not created right away, they either already
exist (which is not expected) or the communication channel between
apiserver and the client is broken. Both CA and MA CRDs are already
deployed by CVO so the error caused by missing CRDs definitions
is excluded.
@ingvagabund
Copy link
Member Author

/retest

1 similar comment
@ingvagabund
Copy link
Member Author

/retest

@ingvagabund
Copy link
Member Author

/test k8s-e2e

@frobware
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 14, 2019
@ingvagabund
Copy link
Member Author

/retest

@spangenberg
Copy link
Contributor

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 14, 2019
@spangenberg
Copy link
Contributor

/retest

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

5 similar comments
@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link

/retest

Please review the full test history for this PR and help us cut down flakes.

We use ginkgo/gomega as a framework to run our tests.
There is no plan to spread ginkgo/gomega based language
outside of the main execution. In the future, we might switch
to a different framework, thus keeping the dependency on
ginkgo/gomega as minimal as possible.
Given all such functions are already under utils.go,
it's natural to put the remaining two there as well.
Using GetMachineSet allows to force the default machine API namespaces.
Otherwise possibly failing with:

Operation cannot be fulfilled on machines.machine.openshift.io \"kubemark-actuator-testing-machineset-****\": the object has been modified; please apply your changes to the latest version and try again
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 15, 2019
@openshift-ci-robot
Copy link

New changes are detected. LGTM label has been removed.

@ingvagabund
Copy link
Member Author

This obviously is not right:

@@ -162,14 +165,16 @@ var _ = g.Describe("[Feature:Machines] Managed cluster should", func() {
 		o.Expect(err).NotTo(o.HaveOccurred())
 
 		g.By(fmt.Sprintf("waiting for cluster to grow %d nodes. Size should be %d", clusterGrowth, intermediateClusterSize))
-		waitForClusterSizeToBeHealthy(intermediateClusterSize)
+		err = waitForClusterSizeToBeHealthy(client, initialClusterSize)
+		o.Expect(err).NotTo(o.HaveOccurred())
 
 		g.By(fmt.Sprintf("scaling in %q machineSet to %d replicas", machineSet.Name, scaleIn))
 		err = scaleMachineSet(machineSet.Name, scaleIn)
 		o.Expect(err).NotTo(o.HaveOccurred())
 
 		g.By(fmt.Sprintf("waiting for cluster to decrease %d nodes. Final size should be %d nodes", clusterDecrease, finalClusterSize))
-		waitForClusterSizeToBeHealthy(finalClusterSize)
+		err = waitForClusterSizeToBeHealthy(client, initialClusterSize)
+		o.Expect(err).NotTo(o.HaveOccurred())

Just changed back to intermediateClusterSize and finalClusterSize.

@ingvagabund ingvagabund added the lgtm Indicates that a PR is ready to be merged. label Mar 15, 2019
@spangenberg
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: spangenberg

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 47c603f into openshift:master Mar 15, 2019
@ingvagabund ingvagabund deleted the code-improvements branch March 15, 2019 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants