Repository: code-ready/crc
Pull request #2406 (2021-06-07 22:24:10)

Add section on compiling CRC locally to developing.adoc
Update the developing.adoc developer documentation and add a section on
how to build the `crc` binary locally.


**Fixes:** Issue #N

**Relates to:** Issue #N, PR #N, ...

## Solution/Idea

Describe in plain English what you solved and how. For instance, _Added `start` command to CRC so the user can create a VM and set-up a single-node OpenShift cluster on it with one command. It requires blablabla..._

## Proposed changes

List main as well as consequential changes you introduced or had to introduce.

1. Add `start` command.
2. Add `setup` as prerequisite to `start`.
3. ...

## Testing

What is the _bottom-line_ functionality that needs testing? Describe in pseudo-code or in English. Use verifiable statements that tie your changes to existing functionality.

1. `start` succeeds first time after `setup` succeeded
2. stdout contains ... if `start` succeeded
3. stderr contains ... after `start` failed
4. `status` returns ... if `start` succeeded
5. `status` returns ... if `start` failed
6. `start` fails after `start` succeeded or after `status` says CRC is `Running`
7. ...


centos-ci: Can one of the admins verify this patch?
openshift-ci[bot]: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/code-ready/crc/pull/2406#" title="Author self-approved">timflannagan</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **guillaumerose** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @guillaumerose` in a comment when ready.

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

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

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

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"]} -->
openshift-ci[bot]: Hi @timflannagan. Thanks for your PR.

I'm waiting for a [code-ready](https://github.com/orgs/code-ready/people) member to verify that this patch is reasonable to test. If it is, they should reply with `/ok-to-test` on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should [join the org](https://github.com/orgs/code-ready/people) to skip this step.

Once the patch is verified, the new status will be reflected by the `ok-to-test` label.

I understand the commands that are listed [here](https://go.k8s.io/bot-commands?repo=code-ready%2Fcrc).

<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.
</details>

timflannagan: I took a stab at adding this documentation as it wasn't immediately clear to me how to build the binaries locally when inspecting the root Makefile. I'm open to closing this if we don't think there's value in documenting this behavior here - I just had some free time while waiting for a cluster to spin up.
praveenkumar: @timflannagan Are you planning to update this PR as per review?
timflannagan: @praveenkumar I'm fairly tied up with work atm - I can likely get back to this by Friday.
openshift-ci[bot]: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/code-ready/crc/pull/2406#" title="Author self-approved">timflannagan</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please ask for approval from **robin-owen** after the PR has been reviewed.

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

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

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

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

Patch:
diff --git a/cmd/crc-embedder/cmd/root.go b/cmd/crc-embedder/cmd/root.go
index eb00a0634..e366a28d0 100644
--- a/cmd/crc-embedder/cmd/root.go
+++ b/cmd/crc-embedder/cmd/root.go
@@ -2,6 +2,7 @@ package cmd
 
 import (
 	"fmt"
+	"os"
 
 	"github.com/code-ready/crc/pkg/crc/constants"
 	"github.com/code-ready/crc/pkg/crc/logging"
@@ -26,6 +27,11 @@ when building the crc executable for release`,
 }
 
 func init() {
+	err := constants.EnsureBaseDirectoriesExist()
+	if err != nil {
+		fmt.Println("CRC base directories are missing: ", err)
+		os.Exit(1)
+	}
 	rootCmd.PersistentFlags().StringVar(&logging.LogLevel, "log-level", constants.DefaultLogLevel, "log level (e.g. \"debug | info | warn | error\")")
 }
 
diff --git a/cmd/crc/cmd/root.go b/cmd/crc/cmd/root.go
index 144723b03..063b903ef 100644
--- a/cmd/crc/cmd/root.go
+++ b/cmd/crc/cmd/root.go
@@ -2,9 +2,12 @@ package cmd
 
 import (
 	"context"
+	"crypto/tls"
+	"crypto/x509"
 	"errors"
 	"fmt"
 	"io/ioutil"
+	"net/http"
 	"os"
 	"strings"
 	"time"
@@ -56,7 +59,7 @@ func init() {
 		logging.Fatal(err.Error())
 	}
 	// Initiate segment client
-	if segmentClient, err = segment.NewClient(config); err != nil {
+	if segmentClient, err = segment.NewClient(config, httpTransport()); err != nil {
 		logging.Fatal(err.Error())
 	}
 
@@ -207,3 +210,23 @@ func attachMiddleware(names []string, cmd *cobra.Command) {
 		cmd.RunE = executeWithLogging(fullCmd, src)
 	}
 }
+
+func httpTransport() http.RoundTripper {
+	if config.Get(crcConfig.ProxyCAFile).IsDefault {
+		return http.DefaultTransport
+	}
+	caCert, err := ioutil.ReadFile(config.Get(crcConfig.ProxyCAFile).AsString())
+	if err != nil {
+		logging.Errorf("Cannot read proxy-ca-file, using default http transport: %v", err)
+		return http.DefaultTransport
+	}
+	caCertPool := x509.NewCertPool()
+	caCertPool.AppendCertsFromPEM(caCert)
+	return &http.Transport{
+		Proxy: http.ProxyFromEnvironment,
+		TLSClientConfig: &tls.Config{
+			MinVersion: tls.VersionTLS12,
+			RootCAs:    caCertPool,
+		},
+	}
+}
diff --git a/cmd/crc/cmd/start.go b/cmd/crc/cmd/start.go
index a00df327b..8a7853e26 100644
--- a/cmd/crc/cmd/start.go
+++ b/cmd/crc/cmd/start.go
@@ -208,7 +208,7 @@ func checkIfNewVersionAvailable(noUpdateCheck bool) error {
 }
 
 func newVersionAvailable() (bool, string, string, error) {
-	release, err := crcversion.GetCRCLatestVersionFromMirror()
+	release, err := crcversion.GetCRCLatestVersionFromMirror(httpTransport())
 	if err != nil {
 		return false, "", "", err
 	}
diff --git a/developing.adoc b/developing.adoc
index 6a5b2a114..dd08963bd 100644
--- a/developing.adoc
+++ b/developing.adoc
@@ -46,6 +46,36 @@ For more information, see the following:
 . link:https://github.com/golang/go/wiki/Modules[Introduction to Go modules]
 . link:https://blog.golang.org/using-go-modules[Using Go modules]
 
+[[compiling-binaries]]
+== Compiling the CRC Binary
+
+In order to compile the crc executable for your local platform, run the following command:
+
+----
+$ make
+----
+
+By default, the above command will place the crc executable in the `$GOBIN` path.
+
+Run the following command to cross-compile the crc executable for many platforms:
+
+----
+$ make cross
+----
+
+*Note*: This command will output the cross-compiled crc executable(s) in the `out` directory by default:
+
+----
+$ tree out/
+out/
+├── linux-amd64
+│   └── crc
+├── macos-amd64
+│   └── crc
+└── windows-amd64
+    └── crc.exe
+----
+
 [[running-e2e-tests]]
 == Running e2e tests
 
@@ -71,7 +101,7 @@ To start e2e tests, run:
 $ make e2e
 ```
 
-===== How to run only a subset of all e2e tests
+==== How to run only a subset of all e2e tests
 
 Implicitly, all e2e tests for your operating system are executed. If you want to run only tests from one feature file, you have to override `GODOG_OPTS` environment variable. For example:
 
diff --git a/pkg/crc/cluster/cluster.go b/pkg/crc/cluster/cluster.go
index 93f88c07c..7d710171f 100644
--- a/pkg/crc/cluster/cluster.go
+++ b/pkg/crc/cluster/cluster.go
@@ -23,18 +23,6 @@ import (
 // #nosec G101
 const vmPullSecretPath = "/var/lib/kubelet/config.json"
 
-func WaitForSSH(ctx context.Context, sshRunner *ssh.Runner) error {
-	checkSSHConnectivity := func() error {
-		_, _, err := sshRunner.Run("exit 0")
-		if err != nil {
-			return &errors.RetriableError{Err: err}
-		}
-		return nil
-	}
-
-	return errors.RetryAfterWithContext(ctx, 300*time.Second, checkSSHConnectivity, time.Second)
-}
-
 const (
 	KubeletServerCert = "/var/lib/kubelet/pki/kubelet-server-current.pem"
 	KubeletClientCert = "/var/lib/kubelet/pki/kubelet-client-current.pem"
@@ -102,9 +90,9 @@ func EnsureSSHKeyPresentInTheCluster(ocConfig oc.Config, sshPublicKeyPath string
 	if err := WaitForOpenshiftResource(ocConfig, "machineconfigs"); err != nil {
 		return err
 	}
-	stdout, _, err := ocConfig.RunOcCommand("get", "machineconfigs", "99-master-ssh", "-o", `jsonpath='{.spec.config.passwd.users[0].sshAuthorizedKeys[0]}'`)
+	stdout, stderr, err := ocConfig.RunOcCommand("get", "machineconfigs", "99-master-ssh", "-o", `jsonpath='{.spec.config.passwd.users[0].sshAuthorizedKeys[0]}'`)
 	if err != nil {
-		return err
+		return fmt.Errorf("Failed to get machine configs %v: %s", err, stderr)
 	}
 	if stdout == string(sshPublicKey) {
 		return nil
@@ -113,7 +101,7 @@ func EnsureSSHKeyPresentInTheCluster(ocConfig oc.Config, sshPublicKeyPath string
 	cmdArgs := []string{"patch", "machineconfig", "99-master-ssh", "-p",
 		fmt.Sprintf(`'{"spec": {"config": {"passwd": {"users": [{"name": "core", "sshAuthorizedKeys": ["%s"]}]}}}}'`, sshPublicKey),
 		"--type", "merge"}
-	_, stderr, err := ocConfig.RunOcCommand(cmdArgs...)
+	_, stderr, err = ocConfig.RunOcCommand(cmdArgs...)
 	if err != nil {
 		return fmt.Errorf("Failed to update ssh key %v: %s", err, stderr)
 	}
@@ -125,9 +113,9 @@ func EnsurePullSecretPresentInTheCluster(ocConfig oc.Config, pullSec PullSecretL
 		return err
 	}
 
-	stdout, _, err := ocConfig.RunOcCommandPrivate("get", "secret", "pull-secret", "-n", "openshift-config", "-o", `jsonpath="{['data']['\.dockerconfigjson']}"`)
+	stdout, stderr, err := ocConfig.RunOcCommandPrivate("get", "secret", "pull-secret", "-n", "openshift-config", "-o", `jsonpath="{['data']['\.dockerconfigjson']}"`)
 	if err != nil {
-		return err
+		return fmt.Errorf("Failed to get pull secret %v: %s", err, stderr)
 	}
 	decoded, err := base64.StdEncoding.DecodeString(stdout)
 	if err != nil {
@@ -147,7 +135,7 @@ func EnsurePullSecretPresentInTheCluster(ocConfig oc.Config, pullSec PullSecretL
 		fmt.Sprintf(`'{"data":{".dockerconfigjson":"%s"}}'`, base64OfPullSec),
 		"-n", "openshift-config", "--type", "merge"}
 
-	_, stderr, err := ocConfig.RunOcCommandPrivate(cmdArgs...)
+	_, stderr, err = ocConfig.RunOcCommandPrivate(cmdArgs...)
 	if err != nil {
 		return fmt.Errorf("Failed to add Pull secret %v: %s", err, stderr)
 	}
@@ -188,9 +176,9 @@ func EnsureClusterIDIsNotEmpty(ocConfig oc.Config) error {
 		return err
 	}
 
-	stdout, _, err := ocConfig.RunOcCommand("get", "clusterversion", "version", "-o", `jsonpath="{['spec']['clusterID']}"`)
+	stdout, stderr, err := ocConfig.RunOcCommand("get", "clusterversion", "version", "-o", `jsonpath="{['spec']['clusterID']}"`)
 	if err != nil {
-		return err
+		return fmt.Errorf("Failed to get clusterversion %v: %s", err, stderr)
 	}
 	if strings.TrimSpace(stdout) != "" {
 		return nil
@@ -201,7 +189,7 @@ func EnsureClusterIDIsNotEmpty(ocConfig oc.Config) error {
 	cmdArgs := []string{"patch", "clusterversion", "version", "-p",
 		fmt.Sprintf(`'{"spec":{"clusterID":"%s"}}'`, clusterID), "--type", "merge"}
 
-	_, stderr, err := ocConfig.RunOcCommand(cmdArgs...)
+	_, stderr, err = ocConfig.RunOcCommand(cmdArgs...)
 	if err != nil {
 		return fmt.Errorf("Failed to update cluster ID %v: %s", err, stderr)
 	}
@@ -319,8 +307,8 @@ func addProxyCACertToInstance(sshRunner *ssh.Runner, proxy *network.ProxyConfig)
 	if err := sshRunner.CopyData([]byte(proxy.ProxyCACert), "/etc/pki/ca-trust/source/anchors/openshift-config-user-ca-bundle.crt", 0600); err != nil {
 		return err
 	}
-	if _, _, err := sshRunner.Run("sudo update-ca-trust"); err != nil {
-		return err
+	if _, stderr, err := sshRunner.Run("sudo update-ca-trust"); err != nil {
+		return fmt.Errorf("Failed to run update-ca-trust  %v: %s", err, stderr)
 	}
 	return nil
 }
@@ -388,9 +376,9 @@ func DeleteOpenshiftAPIServerPods(ocConfig oc.Config) error {
 
 	deleteOpenshiftAPIServerPods := func() error {
 		cmdArgs := []string{"delete", "pod", "--all", "-n", "openshift-apiserver"}
-		_, _, err := ocConfig.WithFailFast().RunOcCommand(cmdArgs...)
+		_, stderr, err := ocConfig.WithFailFast().RunOcCommand(cmdArgs...)
 		if err != nil {
-			return &errors.RetriableError{Err: err}
+			return &errors.RetriableError{Err: fmt.Errorf("Failed to delete pod from openshift-apiserver namespace %v: %s", err, stderr)}
 		}
 		return nil
 	}
diff --git a/pkg/crc/constants/constants.go b/pkg/crc/constants/constants.go
index 32f5c7053..e6b07531d 100644
--- a/pkg/crc/constants/constants.go
+++ b/pkg/crc/constants/constants.go
@@ -7,6 +7,7 @@ import (
 	"runtime"
 
 	"github.com/YourFin/binappend"
+	"github.com/code-ready/crc/pkg/crc/logging"
 	"github.com/code-ready/crc/pkg/crc/version"
 )
 
@@ -200,5 +201,11 @@ func GetCRCWindowsTrayDownloadURL() string {
 }
 
 func GetMsiInstallPath() string {
-	return filepath.Join(os.Getenv("PROGRAMFILES"), "CodeReady Containers")
+	// In case of error path will be empty string and upperr layer will handle
+	currentExecutablePath, err := os.Executable()
+	if err != nil {
+		logging.Errorf("Failed to find the MSI installation path: %v", err)
+		return ""
+	}
+	return filepath.Dir(currentExecutablePath)
 }
diff --git a/pkg/crc/logging/logging.go b/pkg/crc/logging/logging.go
index 3f4d761dc..d60627542 100644
--- a/pkg/crc/logging/logging.go
+++ b/pkg/crc/logging/logging.go
@@ -5,7 +5,6 @@ import (
 	"os"
 	"time"
 
-	"github.com/code-ready/crc/pkg/crc/constants"
 	"github.com/sirupsen/logrus"
 	terminal "golang.org/x/term"
 )
@@ -18,10 +17,6 @@ var (
 )
 
 func OpenLogFile(path string) (*os.File, error) {
-	err := constants.EnsureBaseDirectoriesExist()
-	if err != nil {
-		return nil, err
-	}
 	logFile, err := os.OpenFile(path, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0600)
 	if err != nil {
 		return nil, err
diff --git a/pkg/crc/machine/start.go b/pkg/crc/machine/start.go
index f2cf4f488..bafb31ece 100644
--- a/pkg/crc/machine/start.go
+++ b/pkg/crc/machine/start.go
@@ -272,7 +272,7 @@ func (client *client) Start(ctx context.Context, startConfig types.StartConfig)
 	defer sshRunner.Close()
 
 	logging.Debug("Waiting until ssh is available")
-	if err := cluster.WaitForSSH(ctx, sshRunner); err != nil {
+	if err := sshRunner.WaitForConnectivity(ctx, 300*time.Second); err != nil {
 		return nil, errors.Wrap(err, "Failed to connect to the CRC VM with SSH -- host might be unreachable")
 	}
 	logging.Info("CodeReady Containers VM is running")
diff --git a/pkg/crc/preflight/preflight_checks_tray_windows.go b/pkg/crc/preflight/preflight_checks_tray_windows.go
index 98f0a2b18..19d9b2c47 100644
--- a/pkg/crc/preflight/preflight_checks_tray_windows.go
+++ b/pkg/crc/preflight/preflight_checks_tray_windows.go
@@ -31,7 +31,9 @@ func stopTray() error {
 	 * this tries to stop the old tray process, can be removed after a  few releases
 	 */
 	_, _, _ = powershell.Execute(`Stop-Process -Name tray-windows`)
-
+	if err := checkIfTrayRunning(); err != nil {
+		return nil
+	}
 	trayProcessName := strings.TrimSuffix(constants.TrayExecutableName, ".exe")
 	cmd := fmt.Sprintf(`Stop-Process -Name "%s"`, trayProcessName)
 	if _, _, err := powershell.Execute(cmd); err != nil {
@@ -93,7 +95,7 @@ func fixTrayExecutableExists() error {
 }
 
 func checkTrayVersion() bool {
-	cmd := fmt.Sprintf(`(Get-Item %s).VersionInfo.FileVersion`, constants.TrayExecutablePath)
+	cmd := fmt.Sprintf(`(Get-Item "%s").VersionInfo.FileVersion`, constants.TrayExecutablePath)
 	stdOut, _, err := powershell.Execute(cmd)
 	if err != nil {
 		logging.Debugf("Failed to get the version of tray: %v", err)
diff --git a/pkg/crc/preflight/preflight_windows.go b/pkg/crc/preflight/preflight_windows.go
index c79a46cee..368f9454b 100644
--- a/pkg/crc/preflight/preflight_windows.go
+++ b/pkg/crc/preflight/preflight_windows.go
@@ -64,6 +64,10 @@ var hypervPreflightChecks = []Check{
 			_, _, err := powershell.ExecuteAsAdmin("create crc-users group", "New-LocalGroup -Name crc-users")
 			return err
 		},
+		cleanup: func() error {
+			_, _, err := powershell.ExecuteAsAdmin("remove crc-users group", "Remove-LocalGroup -Name crc-users")
+			return err
+		},
 		labels: labels{Os: Windows},
 	},
 	{
diff --git a/pkg/crc/segment/segment.go b/pkg/crc/segment/segment.go
index 84c309ed5..06267977e 100644
--- a/pkg/crc/segment/segment.go
+++ b/pkg/crc/segment/segment.go
@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"io/ioutil"
 	"net"
+	"net/http"
 	"os"
 	"path/filepath"
 	"strings"
@@ -30,19 +31,20 @@ type Client struct {
 	telemetryFilePath string
 }
 
-func NewClient(config *crcConfig.Config) (*Client, error) {
-	return newCustomClient(config,
+func NewClient(config *crcConfig.Config, transport http.RoundTripper) (*Client, error) {
+	return newCustomClient(config, transport,
 		filepath.Join(constants.GetHomeDir(), ".redhat", "anonymousId"),
 		analytics.DefaultEndpoint)
 }
 
-func newCustomClient(config *crcConfig.Config, telemetryFilePath, segmentEndpoint string) (*Client, error) {
+func newCustomClient(config *crcConfig.Config, transport http.RoundTripper, telemetryFilePath, segmentEndpoint string) (*Client, error) {
 	client, err := analytics.NewWithConfig(WriteKey, analytics.Config{
 		Endpoint: segmentEndpoint,
 		Logger:   &loggingAdapter{},
 		DefaultContext: &analytics.Context{
 			IP: net.IPv4(0, 0, 0, 0),
 		},
+		Transport: transport,
 	})
 	if err != nil {
 		return nil, err
diff --git a/pkg/crc/ssh/ssh.go b/pkg/crc/ssh/ssh.go
index 414ffbd14..09d3e2808 100644
--- a/pkg/crc/ssh/ssh.go
+++ b/pkg/crc/ssh/ssh.go
@@ -1,13 +1,16 @@
 package ssh
 
 import (
+	"context"
 	"encoding/base64"
 	"fmt"
 	"io/ioutil"
 	"os"
 	"strings"
+	"time"
 
 	"github.com/code-ready/crc/pkg/crc/constants"
+	"github.com/code-ready/crc/pkg/crc/errors"
 	"github.com/code-ready/crc/pkg/crc/logging"
 )
 
@@ -92,3 +95,15 @@ err     : %w\n`, command, err)
 
 	return string(stdout), string(stderr), nil
 }
+
+func (runner *Runner) WaitForConnectivity(ctx context.Context, timeout time.Duration) error {
+	checkSSHConnectivity := func() error {
+		_, _, err := runner.Run("exit 0")
+		if err != nil {
+			return &errors.RetriableError{Err: err}
+		}
+		return nil
+	}
+
+	return errors.RetryAfterWithContext(ctx, timeout, checkSSHConnectivity, time.Second)
+}
diff --git a/pkg/crc/version/version.go b/pkg/crc/version/version.go
index d75ec7365..8720ab157 100644
--- a/pkg/crc/version/version.go
+++ b/pkg/crc/version/version.go
@@ -31,9 +31,9 @@ var (
 const (
 	releaseInfoLink = "https://developers.redhat.com/content-gateway/rest/mirror/pub/openshift-v4/clients/crc/latest/release-info.json"
 	// Tray version to be embedded in executable
-	crcMacTrayVersion = "1.0.9"
+	crcMacTrayVersion = "1.0.10"
 	// Windows forms application version type major.minor.buildnumber.revesion
-	crcWindowsTrayVersion = "0.7.0.0"
+	crcWindowsTrayVersion = "0.8.0.0"
 )
 
 type CrcReleaseInfo struct {
@@ -83,9 +83,10 @@ func IsMsiBuild() bool {
 	return msiBuild != "false"
 }
 
-func GetCRCLatestVersionFromMirror() (*CrcReleaseInfo, error) {
+func GetCRCLatestVersionFromMirror(transport http.RoundTripper) (*CrcReleaseInfo, error) {
 	client := &http.Client{
-		Timeout: 5 * time.Second,
+		Timeout:   5 * time.Second,
+		Transport: transport,
 	}
 	req, err := http.NewRequest(http.MethodGet, releaseInfoLink, nil)
 	if err != nil {


Test patch:
diff --git a/pkg/crc/segment/segment_test.go b/pkg/crc/segment/segment_test.go
index d7d1eacb4..fbb985d61 100644
--- a/pkg/crc/segment/segment_test.go
+++ b/pkg/crc/segment/segment_test.go
@@ -88,7 +88,7 @@ func TestClientUploadWithConsentAndWithSerializableError(t *testing.T) {
 
 	uuidFile := filepath.Join(dir, "telemetry")
 
-	c, err := newCustomClient(config, uuidFile, server.URL)
+	c, err := newCustomClient(config, http.DefaultTransport, uuidFile, server.URL)
 	require.NoError(t, err)
 
 	require.NoError(t, c.UploadCmd(context.Background(), "start", time.Minute, crcErr.ToSerializableError(crcErr.VMNotExist)))
@@ -128,7 +128,7 @@ func TestClientUploadWithConsentAndWithoutSerializableError(t *testing.T) {
 	config, err := newTestConfig("yes")
 	require.NoError(t, err)
 
-	c, err := newCustomClient(config, filepath.Join(dir, "telemetry"), server.URL)
+	c, err := newCustomClient(config, http.DefaultTransport, filepath.Join(dir, "telemetry"), server.URL)
 	require.NoError(t, err)
 
 	require.NoError(t, c.UploadCmd(context.Background(), "start", time.Minute, errors.New("an error occurred")))
@@ -163,7 +163,7 @@ func TestClientUploadWithContext(t *testing.T) {
 	config, err := newTestConfig("yes")
 	require.NoError(t, err)
 
-	c, err := newCustomClient(config, filepath.Join(dir, "telemetry"), server.URL)
+	c, err := newCustomClient(config, http.DefaultTransport, filepath.Join(dir, "telemetry"), server.URL)
 	require.NoError(t, err)
 
 	ctx := telemetry.NewContext(context.Background())
@@ -193,7 +193,7 @@ func TestClientUploadWithOutConsent(t *testing.T) {
 	config, err := newTestConfig("no")
 	require.NoError(t, err)
 
-	c, err := newCustomClient(config, filepath.Join(dir, "telemetry"), server.URL)
+	c, err := newCustomClient(config, http.DefaultTransport, filepath.Join(dir, "telemetry"), server.URL)
 	require.NoError(t, err)
 
 	require.NoError(t, c.UploadCmd(context.Background(), "start", time.Second, errors.New("an error occurred")))