Repository: code-ready/crc
Pull request #2209 (2021-04-12 06:51:59)

pkg: remove destination select step
Application path is set at compilation time and cannot be changed. If the user
moves the application, crc won’t be able to find helper binaries, etc.

This option disables the select destination menu as per:
https://stackoverflow.com/questions/16458656/disable-change-install-location-button-in-installer-created-using-productbu

Fix https://github.com/code-ready/crc/issues/2190


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

This pull-request has been approved by: *<a href="https://github.com/code-ready/crc/pull/2209#" title="Author self-approved">guillaumerose</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]

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":[]} -->

Patch:
diff --git a/packaging/darwin/Distribution.in b/packaging/darwin/Distribution.in
index 2b458c3cf..e131fa46b 100755
--- a/packaging/darwin/Distribution.in
+++ b/packaging/darwin/Distribution.in
@@ -7,6 +7,7 @@
     <license file="LICENSE.txt"/>
     <options customize="never" allow-external-scripts="no"/>
     <domains enable_localSystem="true" />
+    <options rootVolumeOnly="true"/>
     <installation-check script="installCheck();"/>
     <script>
 function installCheck() {
diff --git a/pkg/crc/machine/vsock.go b/pkg/crc/machine/vsock.go
index b09601ec5..e1efd0da3 100644
--- a/pkg/crc/machine/vsock.go
+++ b/pkg/crc/machine/vsock.go
@@ -5,6 +5,7 @@ import (
 
 	"github.com/code-ready/crc/pkg/crc/constants"
 	"github.com/code-ready/crc/pkg/crc/daemonclient"
+	"github.com/code-ready/crc/pkg/crc/logging"
 	"github.com/code-ready/gvisor-tap-vsock/pkg/types"
 	"github.com/pkg/errors"
 )
@@ -14,6 +15,7 @@ func exposePorts() error {
 	portsToExpose := vsockPorts()
 	alreadyOpenedPorts, err := daemonClient.NetworkClient.List()
 	if err != nil {
+		logging.Error("Is 'crc daemon' running? Network mode 'vsock' requires 'crc daemon' to be running, run it manually on different terminal/tab")
 		return err
 	}
 	var missingPorts []types.ExposeRequest
diff --git a/pkg/crc/preflight/preflight_checks_nondarwin.go b/pkg/crc/preflight/preflight_checks_nondarwin.go
deleted file mode 100644
index 6d498088f..000000000
--- a/pkg/crc/preflight/preflight_checks_nondarwin.go
+++ /dev/null
@@ -1,36 +0,0 @@
-// +build !darwin
-
-package preflight
-
-import (
-	"errors"
-	"net"
-
-	"github.com/code-ready/crc/pkg/crc/constants"
-)
-
-const daemonNotRunningErrMsg = "Network mode 'vsock' requires 'crc daemon' to be running, run it manually on different terminal/tab"
-
-var daemonRunningChecks = Check{
-	configKeySuffix:  "check-if-daemon-running",
-	checkDescription: "Checking if crc daemon is running",
-	check:            checkIfCRCDaemonRunning,
-	fixDescription:   daemonNotRunningErrMsg,
-	flags:            NoFix,
-}
-
-func checkIfCRCDaemonRunning() error {
-	l, err := net.Dial("unix", constants.DaemonSocketPath)
-	if err != nil {
-		// Log or report the error here
-		return errors.New(daemonNotRunningErrMsg)
-	}
-
-	defer func() {
-		if l != nil {
-			l.Close()
-		}
-	}()
-
-	return nil
-}
diff --git a/pkg/crc/preflight/preflight_linux.go b/pkg/crc/preflight/preflight_linux.go
index c06c7d27a..a9cd469c8 100644
--- a/pkg/crc/preflight/preflight_linux.go
+++ b/pkg/crc/preflight/preflight_linux.go
@@ -232,8 +232,7 @@ func getNetworkChecks(networkMode network.Mode, systemdResolved bool) []Check {
 	var checks []Check
 
 	if networkMode == network.VSockMode {
-		checks = append(checks, vsockPreflightChecks)
-		return append(checks, daemonRunningChecks)
+		return append(checks, vsockPreflightChecks)
 	}
 
 	checks = append(checks, nmPreflightChecks[:]...)
diff --git a/pkg/crc/preflight/preflight_windows.go b/pkg/crc/preflight/preflight_windows.go
index 268743d6a..9ced5a2d9 100644
--- a/pkg/crc/preflight/preflight_windows.go
+++ b/pkg/crc/preflight/preflight_windows.go
@@ -148,7 +148,6 @@ func getPreflightChecks(experimentalFeatures bool, _ bool, networkMode network.M
 
 	if networkMode == network.VSockMode {
 		checks = append(checks, vsockChecks[:]...)
-		checks = append(checks, daemonRunningChecks)
 	}
 
 	// Experimental feature
diff --git a/pkg/crc/segment/segment.go b/pkg/crc/segment/segment.go
index b51a57e82..325e10a04 100644
--- a/pkg/crc/segment/segment.go
+++ b/pkg/crc/segment/segment.go
@@ -85,7 +85,8 @@ func (c *Client) Upload(ctx context.Context, action string, duration time.Durati
 	properties = properties.Set("version", version.GetCRCVersion()).
 		Set("success", err == nil).
 		Set("duration", duration.Milliseconds()).
-		Set("tty", crcos.RunningInTerminal())
+		Set("tty", crcos.RunningInTerminal()).
+		Set("remote", crcos.RunningUsingSSH())
 	if err != nil {
 		properties = properties.Set("error", telemetry.SetError(err)).
 			Set("error-type", errorType(err))
diff --git a/pkg/os/util.go b/pkg/os/util.go
index 99a343748..0098fbf7a 100644
--- a/pkg/os/util.go
+++ b/pkg/os/util.go
@@ -115,3 +115,7 @@ func RemoveFileIfExists(path string) error {
 func RunningInTerminal() bool {
 	return terminal.IsTerminal(int(os.Stdin.Fd()))
 }
+
+func RunningUsingSSH() bool {
+	return os.Getenv("SSH_TTY") != ""
+}
diff --git a/usage-data.adoc b/usage-data.adoc
index ee751718b..66a092d08 100644
--- a/usage-data.adoc
+++ b/usage-data.adoc
@@ -20,6 +20,7 @@ The following table describes the opt-in usage data collected by CodeReady Conta
 |                  | Experimental features       | true/false
 |                  | tty                         | true/false
 |                  | duration                    |
+|                  | remotely connected with SSH | true/false
 
 |*Config*          | Num of CPUs                 | 
 |                  | Memory size                 |


Test patch:
diff --git a/pkg/crc/preflight/preflight_linux_test.go b/pkg/crc/preflight/preflight_linux_test.go
index 8e15b6644..a54bc1805 100644
--- a/pkg/crc/preflight/preflight_linux_test.go
+++ b/pkg/crc/preflight/preflight_linux_test.go
@@ -145,7 +145,6 @@ var checkListForDistros = []checkListForDistro{
 			{check: checkMachineDriverLibvirtInstalled},
 			{cleanup: removeCrcVM},
 			{check: checkVsock},
-			{check: checkIfCRCDaemonRunning},
 			{check: checkBundleExtracted},
 		},
 	},
@@ -237,7 +236,6 @@ var checkListForDistros = []checkListForDistro{
 			{check: checkMachineDriverLibvirtInstalled},
 			{cleanup: removeCrcVM},
 			{check: checkVsock},
-			{check: checkIfCRCDaemonRunning},
 			{check: checkBundleExtracted},
 		},
 	},
@@ -329,7 +327,6 @@ var checkListForDistros = []checkListForDistro{
 			{check: checkMachineDriverLibvirtInstalled},
 			{cleanup: removeCrcVM},
 			{check: checkVsock},
-			{check: checkIfCRCDaemonRunning},
 			{check: checkBundleExtracted},
 		},
 	},
@@ -424,7 +421,6 @@ var checkListForDistros = []checkListForDistro{
 			{cleanup: removeCrcVM},
 			{configKeySuffix: "check-apparmor-profile-setup"},
 			{check: checkVsock},
-			{check: checkIfCRCDaemonRunning},
 			{check: checkBundleExtracted},
 		},
 	},
diff --git a/pkg/crc/preflight/preflight_windows_test.go b/pkg/crc/preflight/preflight_windows_test.go
index 34afd227a..77724abe0 100644
--- a/pkg/crc/preflight/preflight_windows_test.go
+++ b/pkg/crc/preflight/preflight_windows_test.go
@@ -11,13 +11,13 @@ import (
 func TestCountConfigurationOptions(t *testing.T) {
 	cfg := config.New(config.NewEmptyInMemoryStorage())
 	RegisterSettings(cfg)
-	assert.Len(t, cfg.AllConfigs(), 13)
+	assert.Len(t, cfg.AllConfigs(), 12)
 }
 
 func TestCountPreflights(t *testing.T) {
 	assert.Len(t, getPreflightChecks(false, false, network.DefaultMode), 16)
 	assert.Len(t, getPreflightChecks(true, true, network.DefaultMode), 19)
 
-	assert.Len(t, getPreflightChecks(false, false, network.VSockMode), 18)
-	assert.Len(t, getPreflightChecks(true, true, network.VSockMode), 21)
+	assert.Len(t, getPreflightChecks(false, false, network.VSockMode), 17)
+	assert.Len(t, getPreflightChecks(true, true, network.VSockMode), 20)
 }
diff --git a/pkg/crc/segment/segment_test.go b/pkg/crc/segment/segment_test.go
index 435fc8fe7..d0c3522ac 100644
--- a/pkg/crc/segment/segment_test.go
+++ b/pkg/crc/segment/segment_test.go
@@ -35,6 +35,7 @@ type segmentResponse struct {
 			ErrorType string `json:"error-type"`
 			Version   string `json:"version"`
 			CPUs      int    `json:"cpus"`
+			Remote    bool   `json:"remote"`
 		} `json:"properties"`
 		Type string `json:"type"`
 	} `json:"batch"`
@@ -76,6 +77,9 @@ func TestClientUploadWithConsentAndWithSerializableError(t *testing.T) {
 	defer server.Close()
 	defer close(body)
 
+	require.NoError(t, os.Setenv("SSH_TTY", "test"))
+	defer os.Unsetenv("SSH_TTY")
+
 	dir, err := ioutil.TempDir("", "cfg")
 	require.NoError(t, err)
 	defer os.RemoveAll(dir)
@@ -107,6 +111,7 @@ func TestClientUploadWithConsentAndWithSerializableError(t *testing.T) {
 		require.Equal(t, s.Batch[1].Properties.Error, crcErr.VMNotExist.Error())
 		require.Equal(t, s.Batch[1].Properties.ErrorType, "errors.vmNotExist")
 		require.Equal(t, s.Batch[1].Properties.Version, version.GetCRCVersion())
+		require.Equal(t, s.Batch[1].Properties.Remote, true)
 	default:
 		require.Fail(t, "server should receive data")
 	}
@@ -141,6 +146,7 @@ func TestClientUploadWithConsentAndWithoutSerializableError(t *testing.T) {
 		require.Equal(t, s.Batch[1].Properties.Error, "an error occurred")
 		require.Equal(t, s.Batch[1].Properties.ErrorType, "*errors.errorString")
 		require.Equal(t, s.Batch[1].Properties.Version, version.GetCRCVersion())
+		require.Equal(t, s.Batch[1].Properties.Remote, false)
 	default:
 		require.Fail(t, "server should receive data")
 	}