Bug 2106403 - Nutanix: the e2e-nutanix-operator webhooks test suite does not support provider Nutanix
Summary: Nutanix: the e2e-nutanix-operator webhooks test suite does not support provid...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Cloud Compute
Version: 4.12
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: 4.12.0
Assignee: OpenShift Cluster Infrastructure Bugs
QA Contact: Huali Liu
URL:
Whiteboard:
Depends On:
Blocks: 2108014
TreeView+ depends on / blocked
 
Reported: 2022-07-12 15:09 UTC by Yanhua Li
Modified: 2023-01-17 19:52 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-01-17 19:52:29 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift cluster-api-actuator-pkg pull 236 0 None open Bug 2106403: Add Nutanix as the supported provider platform for e2e-nutanix-operator test 2022-07-13 19:24:08 UTC
Red Hat Product Errata RHSA-2022:7399 0 None None None 2023-01-17 19:52:47 UTC

Description Yanhua Li 2022-07-12 15:09:05 UTC
Description of problem:
The e2e-nutanix-operator webhooks test suite does not support provider Nutanix

Version-Release number of selected component (if applicable):
4.12

How reproducible:
Always

Steps to Reproduce:
1. Create an OCP cluster with Nutanix platform, using the latest 4.12 nightly release image
2. Clone the repo github.com/openshift/cluster-api-actuator-pkg
3. Set the KUBECONFIG to the OCP cluster created in step 1
4. Run the command: 
  NAMESPACE=kube-system ./hack/ci-integration.sh -focus "Webhooks" -v

Actual results:
The tests failed and the the default machineset of the OCP cluster got deleted.

Expected results:
All the tests in the suite pass.

Additional info:

Comment 1 Michael McCune 2022-07-12 16:05:48 UTC
@yanhli does this fail even with the change from Sid? (https://github.com/openshift/machine-api-operator/pull/1034)

Comment 2 Sid Shukla 2022-07-13 13:40:37 UTC
@mimccune The failure is actually due to the setup clause of the webhook spec in the cluster-api-pkg-actuator test skipping out early without setting the labels appropriately and the cleanup phase using unset labels which match all and mark all machinesets and machines for deletion.

Comment 4 Sid Shukla 2022-07-13 13:43:23 UTC
Two things:
- that conditional should be in the very beginning of the spec description and not in the setup clause.
- we need to add nutanix platform to that conditional

Comment 5 Michael McCune 2022-07-13 13:45:52 UTC
(In reply to Sid Shukla from comment #4)
> Two things:
> - that conditional should be in the very beginning of the spec description
> and not in the setup clause.

ah yeah, so it adds the skip instead of failing on non-supported platforms?

Comment 6 Sid Shukla 2022-07-13 15:17:22 UTC
So, here's an example:
```go
package ginkgo_playground_test

import (
	"fmt"
	"testing"

	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

func TestGinkgoPlayground(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "GinkgoPlayground Suite")
}

var _ = Describe("Printing execution order of closures", func() {
		fmt.Println("describe block")
		BeforeEach(func() {
			fmt.Println("before each block")
			Skip("skip")
		})

		AfterEach(func() {
			fmt.Println("after each block")
		})

		It("executes the It block", func() {
			fmt.Println("it block")
		})

	})
```

When you run ginkgo test on this, here's the output
```
$ ginkgo run .
describe block
Running Suite: GinkgoPlayground Suite - /Users/sid.shukla/go/src/github.com/thunderboltsid/ginkgo-playground
============================================================================================================
Random Seed: 1657725350

Will run 1 of 1 specs
before each block
after each block
------------------------------
S [SKIPPED] [0.000 seconds]
Printing execution order of closures [BeforeEach]
/Users/sid.shukla/go/src/github.com/thunderboltsid/ginkgo-playground/ginkgo_playground_suite_test.go:18
  executes the It block
  /Users/sid.shukla/go/src/github.com/thunderboltsid/ginkgo-playground/ginkgo_playground_suite_test.go:27

  skip
  In [BeforeEach] at: /Users/sid.shukla/go/src/github.com/thunderboltsid/ginkgo-playground/ginkgo_playground_suite_test.go:20
------------------------------

Ran 0 of 1 Specs in 0.001 seconds
SUCCESS! -- 0 Passed | 0 Failed | 0 Pending | 1 Skipped
PASS

Ginkgo ran 1 suite in 2.339198756s
Test Suite Passed
```

As you can see, the AfterEach closure and the BeforeEach closure get executed if the skip happens inside the BeforeEach closure.

Comment 7 Sid Shukla 2022-07-13 15:22:45 UTC
If the skip clause is moved over to the Describe closure, the BeforeEach and AfterEach closures are not executed. 
```go
package ginkgo_playground_test

import (
	"fmt"
	"testing"

	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

func TestGinkgoPlayground(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "GinkgoPlayground Suite")
}

var _ = Describe("Printing execution order of closures", func() {
		fmt.Println("describe block")
		defer GinkgoRecover()
		Skip("skip")
		BeforeEach(func() {
			fmt.Println("before each block")
		})

		AfterEach(func() {
			fmt.Println("after each block")
		})

		It("executes the It block", func() {
			fmt.Println("it block")
		})

	})
```
as can be seen from running this
```
$ ginkgo run .
describe block
Running Suite: GinkgoPlayground Suite - /Users/sid.shukla/go/src/github.com/thunderboltsid/ginkgo-playground
============================================================================================================
Random Seed: 1657725679

Will run 0 of 0 specs

Ran 0 of 0 Specs in 0.000 seconds
SUCCESS! -- 0 Passed | 0 Failed | 0 Pending | 0 Skipped
PASS

Ginkgo ran 1 suite in 2.262312576s
Test Suite Passed
```

Comment 8 Sid Shukla 2022-07-13 15:26:41 UTC
What that entails for the Webhook spec is if a platform is not explicitly in this switch (https://github.com/openshift/cluster-api-actuator-pkg/blob/master/pkg/infra/webhooks.go#L39), the testSelector (https://github.com/openshift/cluster-api-actuator-pkg/blob/master/pkg/infra/webhooks.go#L51-L53) never gets initialized. As a result, when the `AfterEach` closure runs, it ends up marking all machines and machinesets for deletion (https://github.com/openshift/cluster-api-actuator-pkg/blob/master/pkg/infra/webhooks.go#L57-L65).

Comment 9 Michael McCune 2022-07-13 16:14:25 UTC
great analysis Sid, it makes sense to me. would you like to propose a patch for this? (otherwise i can make something from your samples here)

Comment 10 Yanhua Li 2022-07-13 18:57:22 UTC
I filed the PR https://github.com/openshift/cluster-api-actuator-pkg/pull/236. And manually tested.

@mimccune Please review the fix at https://github.com/openshift/cluster-api-actuator-pkg/pull/236.

Comment 11 Michael McCune 2022-07-13 19:23:36 UTC
awesome, thank you Yanhua!

Comment 13 Huali Liu 2022-07-20 07:39:33 UTC
Verified on 4.12.0-0.nightly-2022-07-19-212853

Steps:
1. Create an OCP cluster with Nutanix platform, using the latest 4.12 nightly release image
liuhuali@Lius-MacBook-Pro cluster-api-actuator-pkg % oc get clusterversion
NAME      VERSION                              AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.12.0-0.nightly-2022-07-19-212853   True        False         46m     Cluster version is 4.12.0-0.nightly-2022-07-19-212853

2. Clone the repo github.com/openshift/cluster-api-actuator-pkg
3. Set the KUBECONFIG to the OCP cluster created in step 1
4. Run the command: 
  NAMESPACE=kube-system ./hack/ci-integration.sh -focus "Webhooks" -v
liuhuali@Lius-MacBook-Pro cluster-api-actuator-pkg % NAMESPACE=kube-system ./hack/ci-integration.sh -focus "Webhooks" -v

You're using deprecated Ginkgo functionality:
=============================================
Ginkgo 2.0 is under active development and will introduce several new features, improvements, and a small handful of breaking changes.
A release candidate for 2.0 is now available and 2.0 should GA in Fall 2021.  Please give the RC a try and send us feedback!
  - To learn more, view the migration guide at https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md
  - For instructions on using the Release Candidate visit https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md#using-the-beta
  - To comment, chime in at https://github.com/onsi/ginkgo/issues/711

  --stream is deprecated and will be removed in Ginkgo 2.0
  Learn more at: https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md#removed--stream

To silence deprecations that can be silenced set the following environment variable:
  ACK_GINKGO_DEPRECATIONS=1.16.5

I0720 15:22:51.601885    6139 request.go:601] Waited for 1.046381895s due to client-side throttling, not priority and fairness, request: GET:https://api.huliu-n12d.qe.devcluster.openshift.com:6443/apis/flowcontrol.apiserver.k8s.io/v1beta1?timeout=32s
Running Suite: Machine Suite
============================
Random Seed: 1658301752
Will run 4 of 37 specs

SSSSSS
------------------------------
[Feature:Machines] Webhooks 
  should be able to create a machine from a minimal providerSpec
  /Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:68

• [SLOW TEST:201.862 seconds]
[Feature:Machines] Webhooks
/Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:21
  should be able to create a machine from a minimal providerSpec
  /Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:68
------------------------------
[Feature:Machines] Webhooks 
  should be able to create machines from a machineset with a minimal providerSpec
  /Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:94
I0720 15:26:20.893556    6139 request.go:601] Waited for 1.004500511s due to client-side throttling, not priority and fairness, request: GET:https://api.huliu-n12d.qe.devcluster.openshift.com:6443/apis/operator.openshift.io/v1alpha1?timeout=32s

• [SLOW TEST:217.608 seconds]
[Feature:Machines] Webhooks
/Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:21
  should be able to create machines from a machineset with a minimal providerSpec
  /Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:94
------------------------------
[Feature:Machines] Webhooks 
  should return an error when removing required fields from the Machine providerSpec
  /Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:101
I0720 15:29:58.880406    6139 request.go:601] Waited for 1.00445202s due to client-side throttling, not priority and fairness, request: GET:https://api.huliu-n12d.qe.devcluster.openshift.com:6443/apis/metal3.io/v1alpha1?timeout=32s

• [SLOW TEST:29.237 seconds]
[Feature:Machines] Webhooks
/Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:21
  should return an error when removing required fields from the Machine providerSpec
  /Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:101
------------------------------
[Feature:Machines] Webhooks 
  should return an error when removing required fields from the MachineSet providerSpec
  /Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:135
I0720 15:30:28.123744    6139 request.go:601] Waited for 1.004352899s due to client-side throttling, not priority and fairness, request: GET:https://api.huliu-n12d.qe.devcluster.openshift.com:6443/apis/config.openshift.io/v1?timeout=32s

• [SLOW TEST:29.622 seconds]
[Feature:Machines] Webhooks
/Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:21
  should return an error when removing required fields from the MachineSet providerSpec
  /Users/liuhuali/project/cluster-api-actuator-pkg/pkg/infra/webhooks.go:135
------------------------------
SSSSSSSSSSSSSSSSSSSSSSSSSSS
Ran 4 of 37 Specs in 482.280 seconds
SUCCESS! -- 4 Passed | 0 Failed | 0 Pending | 33 Skipped

You're using deprecated Ginkgo functionality:
=============================================
Ginkgo 2.0 is under active development and will introduce several new features, improvements, and a small handful of breaking changes.
A release candidate for 2.0 is now available and 2.0 should GA in Fall 2021.  Please give the RC a try and send us feedback!
  - To learn more, view the migration guide at https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md
  - For instructions on using the Release Candidate visit https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md#using-the-beta
  - To comment, chime in at https://github.com/onsi/ginkgo/issues/711

  You are using a custom reporter.  Support for custom reporters will likely be removed in V2.  Most users were using them to generate junit or teamcity reports and this functionality will be merged into the core reporterPASS
.  In addition, Ginkgo 2.0 will support emitting a JSON-formatted report that users can then manipulate to generate custom reports.

  If this change will be impactful to you please leave a comment on https://github.com/onsi/ginkgo/issues/711
  Learn more at: https://github.com/onsi/ginkgo/blob/ver2/docs/MIGRATING_TO_V2.md#removed-custom-reporters

To silence deprecations that can be silenced set the following environment variable:
  ACK_GINKGO_DEPRECATIONS=1.16.5


Ginkgo ran 1 suite in 8m22.892847901s
Test Suite Passed
liuhuali@Lius-MacBook-Pro cluster-api-actuator-pkg % 

5. The default machineset of the OCP cluster not deleted
liuhuali@Lius-MacBook-Pro cluster-api-actuator-pkg % oc get machine -n openshift-machine-api
NAME                            PHASE     TYPE   REGION   ZONE   AGE
huliu-n12d-p9g7d-master-0       Running                          83m
huliu-n12d-p9g7d-master-1       Running                          83m
huliu-n12d-p9g7d-master-2       Running                          83m
huliu-n12d-p9g7d-worker-ppmw4   Running                          79m
huliu-n12d-p9g7d-worker-sk6gf   Running                          79m
liuhuali@Lius-MacBook-Pro cluster-api-actuator-pkg % oc get machineset -n openshift-machine-api
NAME                      DESIRED   CURRENT   READY   AVAILABLE   AGE
huliu-n12d-p9g7d-worker   2         2         2       2           83m
liuhuali@Lius-MacBook-Pro cluster-api-actuator-pkg %

Comment 16 errata-xmlrpc 2023-01-17 19:52:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: OpenShift Container Platform 4.12.0 bug fix and security update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:7399


Note You need to log in before you can comment on or make changes to this bug.