Repository: code-ready/crc
Pull request #2140 (2021-03-23 14:12:21)

telemetry: enable tracking between Red Hat products
It allows us to know if a user also uses others products like vscode or
odo.
Telemetry must be enabled on both products.


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

This pull-request has been approved by: *<a href="https://github.com/code-ready/crc/pull/2140#" 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":[]} -->
openshift-ci[bot]: @guillaumerose: The following test **failed**, say `/retest` to rerun all failed tests:

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

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

<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 -->
praveenkumar: /retest
openshift-ci[bot]: @guillaumerose: The following test **failed**, say `/retest` to rerun all failed tests:

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

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

<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/machine/start.go b/pkg/crc/machine/start.go
index c63ae7cee..1716f5ea0 100644
--- a/pkg/crc/machine/start.go
+++ b/pkg/crc/machine/start.go
@@ -96,17 +96,37 @@ func (client *client) updateVMConfig(startConfig StartConfig, api libmachine.API
 func growRootFileSystem(sshRunner *crcssh.Runner) error {
 	// With 4.7, this is quite a manual process until https://github.com/openshift/installer/pull/4746 gets fixed
 	// See https://github.com/code-ready/crc/issues/2104 for details
-	if _, _, err := sshRunner.Run("sudo /usr/bin/growpart /dev/vda 4"); err != nil {
-		var sshErr *ssh.ExitError
-		if errors.As(err, &sshErr) {
-			logging.Debugf("/dev/vda4 already has the expected size, nothing to do")
-			return nil
+	rootPart, _, err := sshRunner.Run("realpath", "/dev/disk/by-label/root")
+	if err != nil {
+		return err
+	}
+	rootPart = strings.TrimSpace(rootPart)
+	if !strings.HasPrefix(rootPart, "/dev/vda") && !strings.HasPrefix(rootPart, "/dev/sda") {
+		return fmt.Errorf("Unexpected root device: %s", rootPart)
+	}
+	// with '/dev/[sv]da4' as input, run 'growpart /dev/[sv]da 4'
+	if _, _, err := sshRunner.RunPrivileged(fmt.Sprintf("Growing %s partition", rootPart), "/usr/bin/growpart", rootPart[:len("/dev/.da")], rootPart[len(rootPart)-1:]); err != nil {
+		var exitErr *ssh.ExitError
+		if !errors.As(err, &exitErr) {
+			return err
+		}
+		if exitErr.ExitStatus() != 1 {
+			return err
 		}
 
+		logging.Debugf("No free space after %s, nothing to do", rootPart)
+		return nil
+	}
+
+	logging.Infof("Resizing %s filesystem", rootPart)
+	if _, _, err := sshRunner.RunPrivileged("Remounting /sysroot read/write", "mount -o remount,rw /sysroot"); err != nil {
 		return err
 	}
-	_, _, err := sshRunner.Run("sudo mount -o remount,rw /sysroot && sudo xfs_growfs /dev/vda4")
-	return err
+	if _, _, err = sshRunner.RunPrivileged(fmt.Sprintf("Growing %s filesystem", rootPart), "xfs_growfs", rootPart); err != nil {
+		return err
+	}
+
+	return nil
 }
 func (client *client) Start(ctx context.Context, startConfig StartConfig) (*StartResult, error) {
 	telemetry.SetCPUs(ctx, startConfig.CPUs)
diff --git a/pkg/crc/segment/segment.go b/pkg/crc/segment/segment.go
index 776f9f75b..b51a57e82 100644
--- a/pkg/crc/segment/segment.go
+++ b/pkg/crc/segment/segment.go
@@ -65,14 +65,14 @@ func (c *Client) Upload(ctx context.Context, action string, duration time.Durati
 		return nil
 	}
 
-	anonymousID, uerr := getUserIdentity(c.telemetryFilePath)
+	userID, uerr := getUserIdentity(c.telemetryFilePath)
 	if uerr != nil {
 		return uerr
 	}
 
 	if err := c.segmentClient.Enqueue(analytics.Identify{
-		AnonymousId: anonymousID,
-		Traits:      addConfigTraits(c.config, traits()),
+		UserId: userID,
+		Traits: addConfigTraits(c.config, traits()),
 	}); err != nil {
 		return err
 	}
@@ -92,9 +92,9 @@ func (c *Client) Upload(ctx context.Context, action string, duration time.Durati
 	}
 
 	return c.segmentClient.Enqueue(analytics.Track{
-		AnonymousId: anonymousID,
-		Event:       action,
-		Properties:  properties,
+		UserId:     userID,
+		Event:      action,
+		Properties: properties,
 	})
 }
 


Test patch:
diff --git a/pkg/crc/segment/segment_test.go b/pkg/crc/segment/segment_test.go
index d315fbb7e..435fc8fe7 100644
--- a/pkg/crc/segment/segment_test.go
+++ b/pkg/crc/segment/segment_test.go
@@ -24,9 +24,9 @@ import (
 
 type segmentResponse struct {
 	Batch []struct {
-		AnonymousID string `json:"anonymousId"`
-		MessageID   string `json:"messageId"`
-		Traits      struct {
+		UserID    string `json:"userId"`
+		MessageID string `json:"messageId"`
+		Traits    struct {
 			OS                   string `json:"os"`
 			ExperimentalFeatures bool   `json:"enable-experimental-features"`
 		} `json:"traits"`
@@ -83,20 +83,27 @@ func TestClientUploadWithConsentAndWithSerializableError(t *testing.T) {
 	config, err := newTestConfig("yes")
 	require.NoError(t, err)
 
-	c, err := newCustomClient(config, filepath.Join(dir, "telemetry"), server.URL)
+	uuidFile := filepath.Join(dir, "telemetry")
+
+	c, err := newCustomClient(config, uuidFile, server.URL)
 	require.NoError(t, err)
 
 	require.NoError(t, c.Upload(context.Background(), "start", time.Minute, crcErr.ToSerializableError(crcErr.VMNotExist)))
 	require.NoError(t, c.Close())
 
+	uuid, err := ioutil.ReadFile(uuidFile)
+	require.NoError(t, err)
+
 	select {
 	case x := <-body:
 		s := segmentResponse{}
 		require.NoError(t, json.Unmarshal(x, &s))
 		require.Equal(t, s.Batch[0].Type, "identify")
+		require.Equal(t, s.Batch[0].UserID, string(uuid))
 		require.Equal(t, s.Batch[0].Traits.OS, runtime.GOOS)
 		require.Equal(t, s.Batch[0].Traits.ExperimentalFeatures, true)
 		require.Equal(t, s.Batch[1].Type, "track")
+		require.Equal(t, s.Batch[1].UserID, string(uuid))
 		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())
diff --git a/test/e2e/features/story_health.feature b/test/e2e/features/story_health.feature
index d18d40936..a0a259eff 100644
--- a/test/e2e/features/story_health.feature
+++ b/test/e2e/features/story_health.feature
@@ -53,7 +53,7 @@ Feature: End-to-end health check
         Then checking that CRC is stopped
         When starting CRC with default bundle succeeds
         Then checking that CRC is running
-        And with up to "2" retries with wait period of "1m" http response from "http://httpd-example-testproj.apps-crc.testing" has status code "200"
+        And with up to "4" retries with wait period of "1m" http response from "http://httpd-example-testproj.apps-crc.testing" has status code "200"
 
     @darwin @linux @windows
     Scenario: Switch off CRC