Repository: code-ready/crc
Pull request #2334 (2021-05-11 12:40:53)

http api: return only the error instead of a full object
This PR cleans up the http a little bit. It forces consumers to not rely on success field but use the status code. 

When an error occurs, 
* returns a 500 error code (to be refine when the binary protocol will be gone)
* returns error text (instead of a full object)

All API objects contains success and eventually error. 


Before

``` 
$ curl  --unix-socket ~/.crc/crc-http.sock http:/unix/api/start -v | jq .
< HTTP/1.1 200 OK
{
  "Name": "crc",
  "Status": "",
  "Error": "Bundle 'crc_libvirt_4.7.8.crcbundle' was requested, but the existing VM is using 'crc_libvirt_4.7.7.crcbundle'",
  "ClusterConfig": {
    "ClusterCACert": "",
    "KubeConfig": "",
    "KubeAdminPass": "",
    "ClusterAPI": "",
    "WebConsoleURL": "",
    "ProxyConfig": null
  },
  "KubeletStarted": false
}
```

After

``` 
$ curl  --unix-socket ~/.crc/crc-http.sock http:/unix/api/start -v | jq .
< HTTP/1.1 500 Internal Server Error
Bundle 'crc_libvirt_4.7.8.crcbundle' was requested, but the existing VM is using 'crc_libvirt_4.7.7.crcbundle.
```



Patch:
diff --git a/pkg/crc/api/adapter.go b/pkg/crc/api/adapter.go
index da9e498a5..c48d19ca1 100644
--- a/pkg/crc/api/adapter.go
+++ b/pkg/crc/api/adapter.go
@@ -11,7 +11,6 @@ import (
 )
 
 type AdaptedClient interface {
-	GetName() string
 	Delete() client.Result
 	GetConsoleURL() client.ConsoleResult
 	Start(ctx context.Context, startConfig types.StartConfig) client.StartResult
@@ -23,22 +22,16 @@ type Adapter struct {
 	Underlying machine.Client
 }
 
-func (a *Adapter) GetName() string {
-	return a.Underlying.GetName()
-}
-
 func (a *Adapter) Delete() client.Result {
 	err := a.Underlying.Delete()
 	if err != nil {
 		logging.Error(err)
 		return client.Result{
-			Name:    a.Underlying.GetName(),
 			Success: false,
 			Error:   err.Error(),
 		}
 	}
 	return client.Result{
-		Name:    a.Underlying.GetName(),
 		Success: true,
 	}
 }
@@ -63,12 +56,12 @@ func (a *Adapter) Start(ctx context.Context, startConfig types.StartConfig) clie
 	if err != nil {
 		logging.Error(err)
 		return client.StartResult{
-			Name:  a.Underlying.GetName(),
-			Error: err.Error(),
+			Success: false,
+			Error:   err.Error(),
 		}
 	}
 	return client.StartResult{
-		Name:           a.Underlying.GetName(),
+		Success:        true,
 		Status:         res.Status.String(),
 		ClusterConfig:  res.ClusterConfig,
 		KubeletStarted: res.KubeletStarted,
@@ -80,13 +73,11 @@ func (a *Adapter) Status() client.ClusterStatusResult {
 	if err != nil {
 		logging.Error(err)
 		return client.ClusterStatusResult{
-			Name:    a.Underlying.GetName(),
 			Error:   err.Error(),
 			Success: false,
 		}
 	}
 	return client.ClusterStatusResult{
-		Name:             a.Underlying.GetName(),
 		CrcStatus:        res.CrcStatus.String(),
 		OpenshiftStatus:  string(res.OpenshiftStatus),
 		OpenshiftVersion: res.OpenshiftVersion,
@@ -105,7 +96,6 @@ func (a *Adapter) Stop() client.Result {
 			if err != nil {
 				logging.Error(err)
 				return client.Result{
-					Name:    a.Underlying.GetName(),
 					Success: false,
 					Error:   err.Error(),
 				}
@@ -113,7 +103,6 @@ func (a *Adapter) Stop() client.Result {
 		}
 	}
 	return client.Result{
-		Name:    a.Underlying.GetName(),
 		Success: true,
 	}
 }
diff --git a/pkg/crc/api/api_http.go b/pkg/crc/api/api_http.go
index 423bd1c6d..4cb50852f 100644
--- a/pkg/crc/api/api_http.go
+++ b/pkg/crc/api/api_http.go
@@ -1,12 +1,14 @@
 package api
 
 import (
+	"encoding/json"
 	"fmt"
 	"io"
 	"io/ioutil"
 	"net/http"
 	"strings"
 
+	"github.com/code-ready/crc/pkg/crc/api/client"
 	crcConfig "github.com/code-ready/crc/pkg/crc/config"
 	"github.com/code-ready/crc/pkg/crc/logging"
 	"github.com/code-ready/crc/pkg/crc/machine"
@@ -126,9 +128,26 @@ func wrongHTTPMethodUsed(r *http.Request, w http.ResponseWriter, allowedMethods
 }
 
 func sendResponse(w http.ResponseWriter, response string) {
-	w.Header().Set("Content-Type", "application/json")
-	if _, err := io.WriteString(w, response); err != nil {
-		logging.Error("Failed to send response: ", err)
+	var result client.Result
+	if err := json.Unmarshal([]byte(response), &result); err != nil {
+		w.WriteHeader(http.StatusInternalServerError)
+		if _, err := io.WriteString(w, err.Error()); err != nil {
+			logging.Error("Failed to send response: ", err)
+		}
+		return
+	}
+
+	if result.Success {
+		w.Header().Set("Content-Type", "application/json")
+		w.WriteHeader(http.StatusOK)
+		if _, err := io.WriteString(w, response); err != nil {
+			logging.Error("Failed to send response: ", err)
+		}
+	} else {
+		w.WriteHeader(http.StatusInternalServerError)
+		if _, err := io.WriteString(w, result.Error); err != nil {
+			logging.Error("Failed to send response: ", err)
+		}
 	}
 }
 
diff --git a/pkg/crc/api/client/types.go b/pkg/crc/api/client/types.go
index 7bd0ff8c4..41d5053e2 100644
--- a/pkg/crc/api/client/types.go
+++ b/pkg/crc/api/client/types.go
@@ -12,13 +12,12 @@ type VersionResult struct {
 }
 
 type Result struct {
-	Name    string
 	Success bool
 	Error   string
 }
 
 type StartResult struct {
-	Name           string
+	Success        bool
 	Status         string
 	Error          string
 	ClusterConfig  types.ClusterConfig
@@ -26,7 +25,6 @@ type StartResult struct {
 }
 
 type ClusterStatusResult struct {
-	Name             string
 	CrcStatus        string
 	OpenshiftStatus  string
 	OpenshiftVersion string
@@ -45,12 +43,14 @@ type ConsoleResult struct {
 // setOrUnsetConfigResult struct is used to return the result of
 // setconfig/unsetconfig command
 type SetOrUnsetConfigResult struct {
+	Success    bool
 	Error      string
 	Properties []string
 }
 
 // getConfigResult struct is used to return the result of getconfig command
 type GetConfigResult struct {
+	Success bool
 	Error   string
 	Configs map[string]interface{}
 }
diff --git a/pkg/crc/api/handlers.go b/pkg/crc/api/handlers.go
index 8be6b74a3..59fb392bc 100644
--- a/pkg/crc/api/handlers.go
+++ b/pkg/crc/api/handlers.go
@@ -67,16 +67,16 @@ func (h *Handler) Start(args json.RawMessage) string {
 		parsedArgs, err = parseStartArgs(args)
 		if err != nil {
 			startErr := &client.StartResult{
-				Name:  h.MachineClient.GetName(),
-				Error: fmt.Sprintf("Incorrect arguments given: %s", err.Error()),
+				Success: false,
+				Error:   fmt.Sprintf("Incorrect arguments given: %s", err.Error()),
 			}
 			return encodeStructToJSON(startErr)
 		}
 	}
 	if err := preflight.StartPreflightChecks(h.Config); err != nil {
 		startErr := &client.StartResult{
-			Name:  h.MachineClient.GetName(),
-			Error: err.Error(),
+			Success: false,
+			Error:   err.Error(),
 		}
 		return encodeStructToJSON(startErr)
 	}
@@ -127,8 +127,11 @@ func (h *Handler) GetWebconsoleInfo() string {
 }
 
 func (h *Handler) SetConfig(args json.RawMessage) string {
-	setConfigResult := client.SetOrUnsetConfigResult{}
+	setConfigResult := client.SetOrUnsetConfigResult{
+		Success: true,
+	}
 	if args == nil {
+		setConfigResult.Success = false
 		setConfigResult.Error = "No config keys provided"
 		return encodeStructToJSON(setConfigResult)
 	}
@@ -138,12 +141,14 @@ func (h *Handler) SetConfig(args json.RawMessage) string {
 
 	err := json.Unmarshal(args, &a)
 	if err != nil {
+		setConfigResult.Success = false
 		setConfigResult.Error = fmt.Sprintf("%v", err)
 		return encodeStructToJSON(setConfigResult)
 	}
 
 	configs, ok := a["properties"].(map[string]interface{})
 	if !ok {
+		setConfigResult.Success = false
 		setConfigResult.Error = "No config keys provided"
 		return encodeStructToJSON(setConfigResult)
 	}
@@ -161,6 +166,7 @@ func (h *Handler) SetConfig(args json.RawMessage) string {
 	}
 
 	if len(multiError.Errors) != 0 {
+		setConfigResult.Success = false
 		setConfigResult.Error = fmt.Sprintf("%v", multiError)
 	}
 
@@ -169,8 +175,11 @@ func (h *Handler) SetConfig(args json.RawMessage) string {
 }
 
 func (h *Handler) UnsetConfig(args json.RawMessage) string {
-	unsetConfigResult := client.SetOrUnsetConfigResult{}
+	unsetConfigResult := client.SetOrUnsetConfigResult{
+		Success: true,
+	}
 	if args == nil {
+		unsetConfigResult.Success = false
 		unsetConfigResult.Error = "No config keys provided"
 		return encodeStructToJSON(unsetConfigResult)
 	}
@@ -180,6 +189,7 @@ func (h *Handler) UnsetConfig(args json.RawMessage) string {
 
 	err := json.Unmarshal(args, &keys)
 	if err != nil {
+		unsetConfigResult.Success = false
 		unsetConfigResult.Error = fmt.Sprintf("%v", err)
 		return encodeStructToJSON(unsetConfigResult)
 	}
@@ -197,6 +207,7 @@ func (h *Handler) UnsetConfig(args json.RawMessage) string {
 		successProps = append(successProps, key)
 	}
 	if len(multiError.Errors) != 0 {
+		unsetConfigResult.Success = false
 		unsetConfigResult.Error = fmt.Sprintf("%v", multiError)
 	}
 	unsetConfigResult.Properties = successProps
@@ -204,7 +215,9 @@ func (h *Handler) UnsetConfig(args json.RawMessage) string {
 }
 
 func (h *Handler) GetConfig(args json.RawMessage) string {
-	configResult := client.GetConfigResult{}
+	configResult := client.GetConfigResult{
+		Success: true,
+	}
 	if args == nil {
 		allConfigs := h.Config.AllConfigs()
 		configResult.Error = ""
@@ -219,6 +232,7 @@ func (h *Handler) GetConfig(args json.RawMessage) string {
 
 	err := json.Unmarshal(args, &a)
 	if err != nil {
+		configResult.Success = false
 		configResult.Error = fmt.Sprintf("%v", err)
 		return encodeStructToJSON(configResult)
 	}
@@ -235,6 +249,7 @@ func (h *Handler) GetConfig(args json.RawMessage) string {
 		configs[key] = v.Value
 	}
 	if len(configs) == 0 {
+		configResult.Success = false
 		configResult.Error = "Unable to get configs"
 		configResult.Configs = nil
 	} else {
diff --git a/pkg/crc/cluster/clusteroperator.go b/pkg/crc/cluster/clusteroperator.go
index 0d56d8835..fcf234747 100644
--- a/pkg/crc/cluster/clusteroperator.go
+++ b/pkg/crc/cluster/clusteroperator.go
@@ -71,10 +71,6 @@ func (status *Status) IsReady() bool {
 	return status.Available && !status.Progressing && !status.Degraded && !status.Disabled
 }
 
-func GetClusterOperatorStatus(ocConfig oc.Config, operator string) (*Status, error) {
-	return getStatus(ocConfig, []string{operator})
-}
-
 func GetClusterOperatorsStatus(ocConfig oc.Config) (*Status, error) {
 	return getStatus(ocConfig, []string{})
 }
@@ -102,31 +98,33 @@ func getStatus(ocConfig oc.Config, selector []string) (*Status, error) {
 		found = true
 		for _, con := range c.Status.Conditions {
 			switch con.Type {
-			case "Available":
-				if con.Status != "True" {
+			case openshiftapi.OperatorAvailable:
+				if con.Status != openshiftapi.ConditionTrue {
 					logging.Debug(c.ObjectMeta.Name, " operator not available, Reason: ", con.Reason)
 					cs.unavailable = append(cs.unavailable, c.ObjectMeta.Name)
 					cs.Available = false
 				}
-			case "Degraded":
-				if con.Status == "True" {
+			case openshiftapi.OperatorDegraded:
+				if con.Status == openshiftapi.ConditionTrue {
 					logging.Debug(c.ObjectMeta.Name, " operator is degraded, Reason: ", con.Reason)
 					cs.degraded = append(cs.degraded, c.ObjectMeta.Name)
 					cs.Degraded = true
 				}
-			case "Progressing":
-				if con.Status == "True" {
+			case openshiftapi.OperatorProgressing:
+				if con.Status == openshiftapi.ConditionTrue {
 					logging.Debug(c.ObjectMeta.Name, " operator is still progressing, Reason: ", con.Reason)
 					cs.progressing = append(cs.progressing, c.ObjectMeta.Name)
 					cs.Progressing = true
 				}
-			case "Upgradeable":
+			case openshiftapi.OperatorUpgradeable:
 				continue
-			case "Disabled":
-				if con.Status == "True" {
+			case "Disabled": // non official status, used by insights and cluster baremetal operators
+				if con.Status == openshiftapi.ConditionTrue {
 					logging.Debug(c.ObjectMeta.Name, " operator is disabled, Reason: ", con.Reason)
 					cs.Disabled = true
 				}
+			case "ManagementStateDegraded": // only for the network operator
+				continue
 			default:
 				logging.Debugf("Unexpected operator status for %s: %s", c.ObjectMeta.Name, con.Type)
 			}
diff --git a/pkg/crc/cluster/status.go b/pkg/crc/cluster/status.go
index 39f918b12..671ef44ec 100644
--- a/pkg/crc/cluster/status.go
+++ b/pkg/crc/cluster/status.go
@@ -10,7 +10,7 @@ import (
 )
 
 // WaitForClusterStable checks that the cluster is running a number of consecutive times
-func WaitForClusterStable(ctx context.Context, ocConfig oc.Config, monitoringEnabled bool) error {
+func WaitForClusterStable(ctx context.Context, ocConfig oc.Config) error {
 	if ctx.Err() != nil {
 		return ctx.Err()
 	}
diff --git a/pkg/crc/config/settings.go b/pkg/crc/config/settings.go
index f65a52e31..6a21855f2 100644
--- a/pkg/crc/config/settings.go
+++ b/pkg/crc/config/settings.go
@@ -79,7 +79,7 @@ func RegisterSettings(cfg *Config) {
 	cfg.AddSetting(ExperimentalFeatures, false, ValidateBool, SuccessfullyApplied,
 		"Enable experimental features (true/false, default: false)")
 	cfg.AddSetting(NetworkMode, string(defaultNetworkMode()), network.ValidateMode, network.SuccessfullyAppliedMode,
-		"Network mode (default or vsock)")
+		fmt.Sprintf("Network mode (%s or %s)", network.UserNetworkingMode, network.SystemNetworkingMode))
 	cfg.AddSetting(HostNetworkAccess, false, validateHostNetworkAccess, SuccessfullyApplied,
 		"Allow TCP/IP connections from the CodeReady Containers VM to services running on the host (true/false, default: false)")
 	// System tray auto-start config
diff --git a/pkg/crc/machine/kubeconfig.go b/pkg/crc/machine/kubeconfig.go
index fd6b950bd..20371c213 100644
--- a/pkg/crc/machine/kubeconfig.go
+++ b/pkg/crc/machine/kubeconfig.go
@@ -16,6 +16,7 @@ import (
 	"github.com/code-ready/crc/pkg/crc/constants"
 	"github.com/code-ready/crc/pkg/crc/machine/types"
 	"github.com/openshift/oc/pkg/helpers/tokencmd"
+	"k8s.io/apimachinery/third_party/forked/golang/netutil"
 	restclient "k8s.io/client-go/rest"
 	"k8s.io/client-go/tools/clientcmd"
 	"k8s.io/client-go/tools/clientcmd/api"
@@ -79,12 +80,14 @@ func certificateAuthority(kubeconfigFile string) ([]byte, error) {
 	return cluster.CertificateAuthorityData, nil
 }
 
+// https://github.com/openshift/oc/blob/f94afb52dc8a3185b3b9eacaf92ec34d80f8708d/pkg/helpers/kubeconfig/smart_merge.go#L21
 func hostname(clusterAPI string) (string, error) {
 	p, err := url.Parse(clusterAPI)
 	if err != nil {
 		return "", err
 	}
-	return p.Host, nil
+	h := netutil.CanonicalAddr(p)
+	return strings.ReplaceAll(h, ".", "-"), nil
 }
 
 func addContext(cfg *api.Config, ip string, clusterConfig *types.ClusterConfig, ca []byte, context, username, password string) error {
diff --git a/pkg/crc/machine/start.go b/pkg/crc/machine/start.go
index 8c1cfa571..f511a5213 100644
--- a/pkg/crc/machine/start.go
+++ b/pkg/crc/machine/start.go
@@ -443,7 +443,7 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
 
 	logging.Info("Starting OpenShift cluster... [waiting for the cluster to stabilize]")
 
-	if err := cluster.WaitForClusterStable(ctx, ocConfig, client.monitoringEnabled()); err != nil {
+	if err := cluster.WaitForClusterStable(ctx, ocConfig); err != nil {
 		logging.Errorf("Cluster is not ready: %v", err)
 	}
 
diff --git a/pkg/crc/preflight/preflight_linux.go b/pkg/crc/preflight/preflight_linux.go
index b47e34f97..265d60e49 100644
--- a/pkg/crc/preflight/preflight_linux.go
+++ b/pkg/crc/preflight/preflight_linux.go
@@ -228,16 +228,13 @@ func removeVsockCrcSettings() error {
 func getAllPreflightChecks() []Check {
 	usingSystemdResolved := checkSystemdResolvedIsRunning()
 	checks := getPreflightChecksForDistro(distro(), network.SystemNetworkingMode, usingSystemdResolved == nil)
-	checks = append(checks, wsl2PreflightChecks)
 	checks = append(checks, vsockPreflightChecks)
 	return checks
 }
 
 func getPreflightChecks(_ bool, _ bool, networkMode network.Mode) []Check {
 	usingSystemdResolved := checkSystemdResolvedIsRunning()
-	checks := getPreflightChecksForDistro(distro(), networkMode, usingSystemdResolved == nil)
-	checks = append(checks, wsl2PreflightChecks)
-	return checks
+	return getPreflightChecksForDistro(distro(), networkMode, usingSystemdResolved == nil)
 }
 
 func getNetworkChecks(networkMode network.Mode, systemdResolved bool) []Check {
@@ -260,6 +257,7 @@ func getNetworkChecks(networkMode network.Mode, systemdResolved bool) []Check {
 func getPreflightChecksForDistro(distro *linux.OsRelease, networkMode network.Mode, systemdResolved bool) []Check {
 	var checks []Check
 	checks = append(checks, nonWinPreflightChecks[:]...)
+	checks = append(checks, wsl2PreflightChecks)
 	checks = append(checks, genericPreflightChecks[:]...)
 	checks = append(checks, libvirtPreflightChecks(distro)...)
 	networkChecks := getNetworkChecks(networkMode, systemdResolved)


Test patch:
diff --git a/pkg/crc/api/api_http_test.go b/pkg/crc/api/api_http_test.go
index f02566b2b..d86d73fdf 100644
--- a/pkg/crc/api/api_http_test.go
+++ b/pkg/crc/api/api_http_test.go
@@ -38,7 +38,6 @@ func TestHTTPApi(t *testing.T) {
 	assert.Equal(
 		t,
 		apiClient.ClusterStatusResult{
-			Name:             "crc",
 			CrcStatus:        "Running",
 			OpenshiftStatus:  "Running",
 			OpenshiftVersion: "4.5.1",
@@ -55,10 +54,10 @@ func TestHTTPApi(t *testing.T) {
 	assert.Equal(
 		t,
 		apiClient.StartResult{
-			Name:           "crc",
 			Status:         "",
 			Error:          "",
 			KubeletStarted: true,
+			Success:        true,
 			ClusterConfig: types.ClusterConfig{
 				ClusterCACert: "MIIDODCCAiCgAwIBAgIIRVfCKNUa1wIwDQYJ",
 				KubeConfig:    "/tmp/kubeconfig",
@@ -76,7 +75,6 @@ func TestHTTPApi(t *testing.T) {
 	assert.Equal(
 		t,
 		apiClient.Result{
-			Name:    "crc",
 			Success: true,
 			Error:   "",
 		},
@@ -88,7 +86,6 @@ func TestHTTPApi(t *testing.T) {
 	assert.Equal(
 		t,
 		apiClient.Result{
-			Name:    "crc",
 			Success: true,
 			Error:   "",
 		},
@@ -100,7 +97,8 @@ func TestHTTPApi(t *testing.T) {
 	assert.Equal(
 		t,
 		apiClient.GetConfigResult{
-			Error: "",
+			Success: true,
+			Error:   "",
 			Configs: map[string]interface{}{
 				"cpus": float64(4),
 			},
@@ -117,6 +115,7 @@ func TestHTTPApi(t *testing.T) {
 	assert.Equal(
 		t,
 		apiClient.SetOrUnsetConfigResult{
+			Success:    true,
 			Error:      "",
 			Properties: []string{"cpus"},
 		},
diff --git a/pkg/crc/api/api_test.go b/pkg/crc/api/api_test.go
index fe1f03a86..9ce8faeba 100644
--- a/pkg/crc/api/api_test.go
+++ b/pkg/crc/api/api_test.go
@@ -54,7 +54,6 @@ func TestApi(t *testing.T) {
 		{
 			command: "status",
 			expected: map[string]interface{}{
-				"Name":             "crc",
 				"CrcStatus":        "Running",
 				"OpenshiftStatus":  "Running",
 				"OpenshiftVersion": "4.5.1",
@@ -68,7 +67,6 @@ func TestApi(t *testing.T) {
 			command:       "status",
 			clientFailing: true,
 			expected: map[string]interface{}{
-				"Name":             "crc",
 				"CrcStatus":        "",
 				"OpenshiftStatus":  "",
 				"OpenshiftVersion": "",
@@ -83,10 +81,10 @@ func TestApi(t *testing.T) {
 			clientFailing: true,
 			args:          json.RawMessage(`{"pull-secret":"/Users/fake/pull-secret"}`),
 			expected: map[string]interface{}{
-				"Name":           "crc",
 				"Status":         "",
 				"Error":          "Incorrect arguments given: json: unknown field \"pull-secret\"",
 				"KubeletStarted": false,
+				"Success":        false,
 				"ClusterConfig": map[string]interface{}{
 					"KubeConfig":    "",
 					"KubeAdminPass": "",
@@ -101,10 +99,10 @@ func TestApi(t *testing.T) {
 			command: "start",
 			args:    json.RawMessage(`{"pullSecretFile":"/Users/fake/pull-secret"}`),
 			expected: map[string]interface{}{
-				"Name":           "crc",
 				"Status":         "",
 				"Error":          "",
 				"KubeletStarted": true,
+				"Success":        true,
 				"ClusterConfig": map[string]interface{}{
 					"ClusterCACert": "MIIDODCCAiCgAwIBAgIIRVfCKNUa1wIwDQYJ",
 					"KubeConfig":    "/tmp/kubeconfig",
@@ -127,7 +125,6 @@ func TestApi(t *testing.T) {
 			args:    json.RawMessage(`{"action":"click start"}`),
 			expected: map[string]interface{}{
 				"Success": true,
-				"Name":    "",
 				"Error":   "",
 			},
 		},
@@ -176,6 +173,7 @@ func TestSetconfigApi(t *testing.T) {
 	var setconfigRes apiClient.SetOrUnsetConfigResult
 	assert.NoError(t, json.Unmarshal(payload[:n], &setconfigRes))
 	assert.Equal(t, apiClient.SetOrUnsetConfigResult{
+		Success:    true,
 		Error:      "",
 		Properties: []string{"cpus"},
 	}, setconfigRes)
@@ -206,6 +204,7 @@ func TestGetconfigApi(t *testing.T) {
 	configs["cpus"] = 4.0
 
 	assert.Equal(t, apiClient.GetConfigResult{
+		Success: true,
 		Error:   "",
 		Configs: configs,
 	}, getconfigRes)
diff --git a/pkg/crc/cluster/clusteroperator_test.go b/pkg/crc/cluster/clusteroperator_test.go
index 3740c65fb..fea4afa03 100644
--- a/pkg/crc/cluster/clusteroperator_test.go
+++ b/pkg/crc/cluster/clusteroperator_test.go
@@ -32,25 +32,6 @@ func TestGetClusterOperatorsStatusProgressing(t *testing.T) {
 	assert.Equal(t, progressing, status)
 }
 
-func TestGetClusterOperatorStatus(t *testing.T) {
-	status, err := GetClusterOperatorStatus(ocConfig("co.json"), "authentication")
-	assert.NoError(t, err)
-	assert.Equal(t, available, status)
-
-	status, err = GetClusterOperatorStatus(ocConfig("co-progressing.json"), "authentication")
-	assert.NoError(t, err)
-	assert.Equal(t, progressing, status)
-
-	status, err = GetClusterOperatorStatus(ocConfig("co-progressing.json"), "cloud-credential")
-	assert.NoError(t, err)
-	assert.Equal(t, available, status)
-}
-
-func TestGetClusterOperatorStatusNotFound(t *testing.T) {
-	_, err := GetClusterOperatorStatus(ocConfig("co-progressing.json"), "not-found")
-	assert.EqualError(t, err, "no cluster operator found")
-}
-
 func ocConfig(s string) oc.Config {
 	return oc.Config{
 		Runner: &mockRunner{file: filepath.Join("testdata", s)},
diff --git a/pkg/crc/preflight/preflight_linux_test.go b/pkg/crc/preflight/preflight_linux_test.go
index ff2127ebb..526cea9f5 100644
--- a/pkg/crc/preflight/preflight_linux_test.go
+++ b/pkg/crc/preflight/preflight_linux_test.go
@@ -63,6 +63,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: true,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},
@@ -96,6 +97,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: false,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},
@@ -128,6 +130,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: false,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},
@@ -154,6 +157,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: true,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},
@@ -187,6 +191,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: false,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},
@@ -219,6 +224,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: false,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},
@@ -245,6 +251,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: true,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},
@@ -278,6 +285,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: false,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},
@@ -310,6 +318,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: false,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},
@@ -336,6 +345,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: true,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},
@@ -370,6 +380,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: false,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},
@@ -403,6 +414,7 @@ var checkListForDistros = []checkListForDistro{
 		systemdResolved: false,
 		checks: []Check{
 			{check: checkIfRunningAsNormalUser},
+			{check: checkRunningInsideWSL2},
 			{check: checkAdminHelperExecutableCached},
 			{check: checkSupportedCPUArch},
 			{configKeySuffix: "check-ram"},