-
Notifications
You must be signed in to change notification settings - Fork 14
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
e2e: mustgather: add missing deployer initialization #1115
Conversation
/cherry-pick release-4.18 |
@shajmakh: once the present PR merges, I will cherry-pick it on top of In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
@@ -71,6 +71,7 @@ var _ = ginkgo.BeforeSuite(func() { | |||
return | |||
} | |||
ginkgo.By("Setting up the cluster") | |||
deployment.Deployer = deploy.NewForPlatform(configuration.Plat) |
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, this is a nice catch. I think I like more a fix like
$ git diff
diff --git a/test/e2e/must-gather/must_gather_suite_test.go b/test/e2e/must-gather/must_gather_suite_test.go
index 838cdc42..2da25052 100644
--- a/test/e2e/must-gather/must_gather_suite_test.go
+++ b/test/e2e/must-gather/must_gather_suite_test.go
@@ -62,12 +62,12 @@ var _ = ginkgo.BeforeSuite(func() {
mustGatherTag = getStringValueFromEnv(envVarMustGatherTag, defaultMustGatherTag)
ginkgo.By(fmt.Sprintf("Using must-gather image %q tag %q", mustGatherImage, mustGatherTag))
- if _, ok := os.LookupEnv("E2E_NROP_INFRA_SETUP_SKIP"); ok {
- ginkgo.By("Fetching up cluster data")
+ var err error
+ deployment, err = deploy.GetDeploymentWithSched(context.TODO())
+ gomega.Expect(err).ToNot(gomega.HaveOccurred())
- var err error
- deployment, err = deploy.GetDeploymentWithSched(context.TODO())
- gomega.Expect(err).ToNot(gomega.HaveOccurred())
+ if _, ok := os.LookupEnv("E2E_NROP_INFRA_SETUP_SKIP"); ok {
+ ginkgo.Expect(deployment.NroSchedObj).ToNot(gomega.BeNil(), "infra setup skip but Scheduler instance not found")
return
}
ginkgo.By("Setting up the cluster")
Do you think the above could work?
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.
nice idea, thanks for raising! I updated GetDeploymentWithSched() a bit to initialize the deployer so even if setup is skipped it won't hurt. let me know if you meant something else please
173bd39
to
432bf77
Compare
Without the deployer initialization, deployment.deployer is nil and causes the test to panic. Fix that by calling deploy.NewForPlatform(). Signed-off-by: Shereen Haj <[email protected]>
432bf77
to
9cd43f1
Compare
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: shajmakh 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 |
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.
your approach can work! let's polish it up
@@ -71,7 +71,10 @@ func NewForPlatform(plat platform.Platform) Deployer { | |||
} | |||
|
|||
func GetDeploymentWithSched(ctx context.Context) (NroDeploymentWithSched, error) { | |||
sd := NroDeploymentWithSched{} | |||
sd := NroDeploymentWithSched{ | |||
Deployer: NewForPlatform(configuration.Plat), |
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.
this seems correct
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.
we need to set it first thing in case the cluster didn't have the scheduler and fails to get it
@@ -62,12 +62,13 @@ var _ = ginkgo.BeforeSuite(func() { | |||
mustGatherTag = getStringValueFromEnv(envVarMustGatherTag, defaultMustGatherTag) | |||
ginkgo.By(fmt.Sprintf("Using must-gather image %q tag %q", mustGatherImage, mustGatherTag)) | |||
|
|||
ginkgo.By("Fetching up cluster data") |
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.
this seems wrong
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.
indeed. I'll make it "collect available data" does that sound better?
ginkgo.By("Fetching up cluster data") | ||
var err error | ||
// the error might be not nil we'll decide if that's fine or not depending on E2E_NROP_INFRA_SETUP_SKIP | ||
deployment, err = deploy.GetDeploymentWithSched(context.TODO()) |
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.
this should never fail anyway so let's check err not occurred
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.
it can fail in case the cluster doesn't have the scheduler and we try to fetch it:
https://github.com/openshift-kni/numaresources-operator/blob/main/test/utils/deploy/deploy.go#L79
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.
I think the question is why the sudden change? why are we always running the deployment, even if E2E_NROP_INFRA_SETUP_SKIP
exists.
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.
my take is that we always want to have an instance of the current scheduler object. If the scheduler does already exist (skip setup), then we should just fetch the existing instance and move on; otherwise we need to setup it and then fetch the setupped instance. This is probably not too evident from the code and we likely need a bit larger refactoring.
/retest |
var err error | ||
deployment, err = deploy.GetDeploymentWithSched(context.TODO()) | ||
gomega.Expect(err).ToNot(gomega.HaveOccurred()) | ||
gomega.Expect(err).ToNot(gomega.HaveOccurred(), "infra setup skip but Scheduler instance not found") |
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.
doesn't make sense to conditionally check the error. If we need to do GetDeploymentWithSched
it must not fail.
Without the deployer initialization, deployment.deployer is nil and causes the test to panic. Fix that by calling deploy.NewForPlatform().