Repository: code-ready/crc
Pull request #2308 (2021-05-06 06:44:03)

Remove default operator ignore list for status
From 4.7 we are already removing operators from being part of
final bundle as part of snc so we don't need any list of ignore
operators. All the operators which are part of bundle should be
available and working as expected.

openshift-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/code-ready/crc/pull/2308#" title="Author self-approved">praveenkumar</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=code-ready%2Fcrc).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/code-ready/crc/blob/master/OWNERS)~~ [praveenkumar]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
openshift-ci-robot: [APPROVALNOTIFIER] This PR is **APPROVED**

This pull-request has been approved by: *<a href="https://github.com/code-ready/crc/pull/2308#pullrequestreview-653025230" title="Approved">guillaumerose</a>*, *<a href="https://github.com/code-ready/crc/pull/2308#" title="Author self-approved">praveenkumar</a>*

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=code-ready%2Fcrc).

The pull request process is described [here](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process)

<details >
Needs approval from an approver in each of these files:

- ~~[OWNERS](https://github.com/code-ready/crc/blob/master/OWNERS)~~ [guillaumerose,praveenkumar]

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":[]} -->
guillaumerose: Good catch!
openshift-ci[bot]: @praveenkumar: The following test **failed**, say `/retest` to rerun all failed tests:

Test name | Commit | Details | Rerun command
--- | --- | --- | ---
ci/prow/e2e-crc | bed9444093ed74974468bb01fb4f0fead26c373a | [link](https://prow.ci.openshift.org/view/gs/origin-ci-test/pr-logs/pull/code-ready_crc/2308/pull-ci-code-ready-crc-master-e2e-crc/1390195643649101824) | `/test e2e-crc`

[Full PR test history](https://prow.ci.openshift.org/pr-history?org=code-ready&repo=crc&pr=2308). [Your PR dashboard](https://prow.ci.openshift.org/pr?query=is:pr+state:open+author:praveenkumar).

<details>

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md).  If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository. I understand the commands that are listed [here](https://go.k8s.io/bot-commands).
</details>
<!-- test report -->

Patch:
diff --git a/pkg/crc/cluster/clusteroperator.go b/pkg/crc/cluster/clusteroperator.go
index 594f34400..0d56d8835 100644
--- a/pkg/crc/cluster/clusteroperator.go
+++ b/pkg/crc/cluster/clusteroperator.go
@@ -12,8 +12,6 @@ import (
 	openshiftapi "github.com/openshift/api/config/v1"
 )
 
-var defaultIgnoredClusterOperators = []string{"machine-config", "marketplace", "insights"}
-
 // https://github.com/openshift/cluster-version-operator/blob/master/docs/dev/clusteroperator.md#what-should-an-operator-report-with-clusteroperator-custom-resource
 type Status struct {
 	Available   bool
@@ -74,18 +72,14 @@ func (status *Status) IsReady() bool {
 }
 
 func GetClusterOperatorStatus(ocConfig oc.Config, operator string) (*Status, error) {
-	return getStatus(ocConfig, defaultIgnoredClusterOperators, []string{operator})
+	return getStatus(ocConfig, []string{operator})
 }
 
-func GetClusterOperatorsStatus(ocConfig oc.Config, monitoringEnabled bool) (*Status, error) {
-	ignoredOperators := defaultIgnoredClusterOperators
-	if !monitoringEnabled {
-		ignoredOperators = append(ignoredOperators, "monitoring")
-	}
-	return getStatus(ocConfig, ignoredOperators, []string{})
+func GetClusterOperatorsStatus(ocConfig oc.Config) (*Status, error) {
+	return getStatus(ocConfig, []string{})
 }
 
-func getStatus(ocConfig oc.Config, ignoreClusterOperators, selector []string) (*Status, error) {
+func getStatus(ocConfig oc.Config, selector []string) (*Status, error) {
 	cs := &Status{
 		Available: true,
 	}
@@ -102,9 +96,6 @@ func getStatus(ocConfig oc.Config, ignoreClusterOperators, selector []string) (*
 
 	found := false
 	for _, c := range co.Items {
-		if contains(c.ObjectMeta.Name, ignoreClusterOperators) {
-			continue
-		}
 		if len(selector) > 0 && !contains(c.ObjectMeta.Name, selector) {
 			continue
 		}
diff --git a/pkg/crc/cluster/status.go b/pkg/crc/cluster/status.go
index 31836935e..39f918b12 100644
--- a/pkg/crc/cluster/status.go
+++ b/pkg/crc/cluster/status.go
@@ -24,7 +24,7 @@ func WaitForClusterStable(ctx context.Context, ocConfig oc.Config, monitoringEna
 	var count int // holds num of consecutive matches
 
 	for i := 0; i < retryCount; i++ {
-		status, err := GetClusterOperatorsStatus(ocConfig, monitoringEnabled)
+		status, err := GetClusterOperatorsStatus(ocConfig)
 		if err == nil {
 			// update counter for consecutive matches
 			if status.IsReady() {
diff --git a/pkg/crc/machine/status.go b/pkg/crc/machine/status.go
index 31d21519d..2db999e1b 100644
--- a/pkg/crc/machine/status.go
+++ b/pkg/crc/machine/status.go
@@ -58,15 +58,15 @@ func (client *client) Status() (*types.ClusterStatusResult, error) {
 	}
 	return &types.ClusterStatusResult{
 		CrcStatus:        state.Running,
-		OpenshiftStatus:  getOpenShiftStatus(sshRunner, client.monitoringEnabled()),
+		OpenshiftStatus:  getOpenShiftStatus(sshRunner),
 		OpenshiftVersion: crcBundleMetadata.GetOpenshiftVersion(),
 		DiskUse:          diskUse,
 		DiskSize:         diskSize,
 	}, nil
 }
 
-func getOpenShiftStatus(sshRunner *crcssh.Runner, monitoringEnabled bool) types.OpenshiftStatus {
-	status, err := cluster.GetClusterOperatorsStatus(oc.UseOCWithSSH(sshRunner), monitoringEnabled)
+func getOpenShiftStatus(sshRunner *crcssh.Runner) types.OpenshiftStatus {
+	status, err := cluster.GetClusterOperatorsStatus(oc.UseOCWithSSH(sshRunner))
 	if err != nil {
 		logging.Debugf("cannot get OpenShift status: %v", err)
 		return types.OpenshiftUnreachable
diff --git a/pkg/crc/machine/stop.go b/pkg/crc/machine/stop.go
index f9a4a4921..7b5a78f46 100644
--- a/pkg/crc/machine/stop.go
+++ b/pkg/crc/machine/stop.go
@@ -12,7 +12,7 @@ func (client *client) Stop() (state.State, error) {
 	host, err := libMachineAPIClient.Load(client.name)
 
 	if err != nil {
-		return state.None, errors.Wrap(err, "Cannot load machine")
+		return state.Error, errors.Wrap(err, "Cannot load machine")
 	}
 
 	logging.Info("Stopping the OpenShift cluster, this may take a few minutes...")
diff --git a/pkg/drivers/hyperv/hyperv.go b/pkg/drivers/hyperv/hyperv.go
index 4fecda068..7d8340118 100644
--- a/pkg/drivers/hyperv/hyperv.go
+++ b/pkg/drivers/hyperv/hyperv.go
@@ -87,21 +87,21 @@ func (d *Driver) DriverName() string {
 func (d *Driver) GetState() (state.State, error) {
 	stdout, err := cmdOut("(", "Hyper-V\\Get-VM", d.MachineName, ").state")
 	if err != nil {
-		return state.None, fmt.Errorf("Failed to find the VM status")
+		return state.Error, fmt.Errorf("Failed to find the VM status")
 	}
 
 	resp := parseLines(stdout)
 	if len(resp) < 1 {
-		return state.None, nil
+		return state.Error, fmt.Errorf("unexpected Hyper-V state %s", resp)
 	}
 
 	switch resp[0] {
-	case "Running":
+	case "Starting", "Running", "Stopping":
 		return state.Running, nil
 	case "Off":
 		return state.Stopped, nil
 	default:
-		return state.None, nil
+		return state.Error, fmt.Errorf("unexpected Hyper-V state %s", resp[0])
 	}
 }
 


Test patch:
diff --git a/pkg/crc/cluster/clusteroperator_test.go b/pkg/crc/cluster/clusteroperator_test.go
index 02ac9aff2..3740c65fb 100644
--- a/pkg/crc/cluster/clusteroperator_test.go
+++ b/pkg/crc/cluster/clusteroperator_test.go
@@ -21,13 +21,13 @@ var (
 )
 
 func TestGetClusterOperatorsStatus(t *testing.T) {
-	status, err := GetClusterOperatorsStatus(ocConfig("co.json"), false)
+	status, err := GetClusterOperatorsStatus(ocConfig("co.json"))
 	assert.NoError(t, err)
 	assert.Equal(t, available, status)
 }
 
 func TestGetClusterOperatorsStatusProgressing(t *testing.T) {
-	status, err := GetClusterOperatorsStatus(ocConfig("co-progressing.json"), false)
+	status, err := GetClusterOperatorsStatus(ocConfig("co-progressing.json"))
 	assert.NoError(t, err)
 	assert.Equal(t, progressing, status)
 }