@@ -14,6 +14,7 @@ import (
14
14
"time"
15
15
16
16
"github.com/AlecAivazis/survey/v2/terminal"
17
+ "github.com/google/uuid"
17
18
k0sv1beta1 "github.com/k0sproject/k0s/pkg/apis/k0s/v1beta1"
18
19
apitypes "github.com/replicatedhq/embedded-cluster/api/types"
19
20
"github.com/replicatedhq/embedded-cluster/cmd/installer/kotscli"
@@ -37,7 +38,6 @@ import (
37
38
"github.com/replicatedhq/embedded-cluster/pkg/helpers"
38
39
"github.com/replicatedhq/embedded-cluster/pkg/kubernetesinstallation"
39
40
"github.com/replicatedhq/embedded-cluster/pkg/kubeutils"
40
- "github.com/replicatedhq/embedded-cluster/pkg/metrics"
41
41
"github.com/replicatedhq/embedded-cluster/pkg/netutils"
42
42
"github.com/replicatedhq/embedded-cluster/pkg/prompts"
43
43
"github.com/replicatedhq/embedded-cluster/pkg/release"
@@ -87,6 +87,7 @@ type InstallCmdFlags struct {
87
87
}
88
88
89
89
type installConfig struct {
90
+ clusterID string
90
91
license * kotsv1beta1.License
91
92
licenseBytes []byte
92
93
tlsCert tls.Certificate
@@ -129,10 +130,9 @@ func InstallCmd(ctx context.Context, appSlug, appTitle string) *cobra.Command {
129
130
return err
130
131
}
131
132
132
- clusterID := metrics .ClusterID ()
133
133
installReporter := newInstallReporter (
134
- replicatedAppURL (), clusterID , cmd .CalledAs (), flagsToStringSlice (cmd .Flags ()),
135
- flags .license .Spec .LicenseID , flags .license .Spec .AppSlug ,
134
+ replicatedAppURL (), cmd .CalledAs (), flagsToStringSlice (cmd .Flags ()),
135
+ flags .license .Spec .LicenseID , flags .clusterID , flags . license .Spec .AppSlug ,
136
136
)
137
137
installReporter .ReportInstallationStarted (ctx )
138
138
@@ -378,6 +378,8 @@ func preRunInstall(cmd *cobra.Command, flags *InstallCmdFlags, rc runtimeconfig.
378
378
return fmt .Errorf (`invalid --target (must be one of: "linux", "kubernetes")` )
379
379
}
380
380
381
+ flags .clusterID = uuid .New ().String ()
382
+
381
383
if err := preRunInstallCommon (cmd , flags , rc , ki ); err != nil {
382
384
return err
383
385
}
@@ -562,7 +564,10 @@ func cidrConfigFromCmd(cmd *cobra.Command) (*newconfig.CIDRConfig, error) {
562
564
return cidrCfg , nil
563
565
}
564
566
565
- func runManagerExperienceInstall (ctx context.Context , flags InstallCmdFlags , rc runtimeconfig.RuntimeConfig , ki kubernetesinstallation.Installation , installReporter * InstallReporter , appTitle string ) (finalErr error ) {
567
+ func runManagerExperienceInstall (
568
+ ctx context.Context , flags InstallCmdFlags , rc runtimeconfig.RuntimeConfig , ki kubernetesinstallation.Installation ,
569
+ installReporter * InstallReporter , appTitle string ,
570
+ ) (finalErr error ) {
566
571
// this is necessary because the api listens on all interfaces,
567
572
// and we only know the interface to use when the user selects it in the ui
568
573
ipAddresses , err := netutils .ListAllValidIPAddresses ()
@@ -631,6 +636,7 @@ func runManagerExperienceInstall(ctx context.Context, flags InstallCmdFlags, rc
631
636
ConfigValues : flags .configValues ,
632
637
ReleaseData : release .GetReleaseData (),
633
638
EndUserConfig : eucfg ,
639
+ ClusterID : flags .clusterID ,
634
640
635
641
LinuxConfig : apitypes.LinuxConfig {
636
642
RuntimeConfig : rc ,
@@ -697,7 +703,7 @@ func runInstall(ctx context.Context, flags InstallCmdFlags, rc runtimeconfig.Run
697
703
errCh := kubeutils .WaitForKubernetes (ctx , kcli )
698
704
defer logKubernetesErrors (errCh )
699
705
700
- in , err := recordInstallation (ctx , kcli , flags , rc , flags . license )
706
+ in , err := recordInstallation (ctx , kcli , flags , rc )
701
707
if err != nil {
702
708
return fmt .Errorf ("unable to record installation: %w" , err )
703
709
}
@@ -733,7 +739,7 @@ func runInstall(ctx context.Context, flags InstallCmdFlags, rc runtimeconfig.Run
733
739
defer hcli .Close ()
734
740
735
741
logrus .Debugf ("installing addons" )
736
- if err := installAddons (ctx , kcli , mcli , hcli , rc , flags ); err != nil {
742
+ if err := installAddons (ctx , kcli , mcli , hcli , flags , rc ); err != nil {
737
743
return err
738
744
}
739
745
@@ -771,6 +777,7 @@ func getAddonInstallOpts(flags InstallCmdFlags, rc runtimeconfig.RuntimeConfig,
771
777
}
772
778
773
779
opts := & addons.InstallOptions {
780
+ ClusterID : flags .clusterID ,
774
781
AdminConsolePwd : flags .adminConsolePassword ,
775
782
AdminConsolePort : rc .AdminConsolePort (),
776
783
License : flags .license ,
@@ -794,6 +801,7 @@ func getAddonInstallOpts(flags InstallCmdFlags, rc runtimeconfig.RuntimeConfig,
794
801
AppSlug : flags .license .Spec .AppSlug ,
795
802
License : flags .licenseBytes ,
796
803
Namespace : constants .KotsadmNamespace ,
804
+ ClusterID : flags .clusterID ,
797
805
AirgapBundle : flags .airgapBundle ,
798
806
ConfigValuesFile : flags .configValues ,
799
807
ReplicatedAppEndpoint : replicatedAppURL (),
@@ -1068,7 +1076,7 @@ func installAndStartCluster(ctx context.Context, flags InstallCmdFlags, rc runti
1068
1076
return cfg , nil
1069
1077
}
1070
1078
1071
- func installAddons (ctx context.Context , kcli client.Client , mcli metadata.Interface , hcli helm.Client , rc runtimeconfig.RuntimeConfig , flags InstallCmdFlags ) error {
1079
+ func installAddons (ctx context.Context , kcli client.Client , mcli metadata.Interface , hcli helm.Client , flags InstallCmdFlags , rc runtimeconfig.RuntimeConfig ) error {
1072
1080
progressChan := make (chan addontypes.AddOnProgress )
1073
1081
defer close (progressChan )
1074
1082
@@ -1294,7 +1302,7 @@ func waitForNode(ctx context.Context) error {
1294
1302
}
1295
1303
1296
1304
func recordInstallation (
1297
- ctx context.Context , kcli client.Client , flags InstallCmdFlags , rc runtimeconfig.RuntimeConfig , license * kotsv1beta1. License ,
1305
+ ctx context.Context , kcli client.Client , flags InstallCmdFlags , rc runtimeconfig.RuntimeConfig ,
1298
1306
) (* ecv1beta1.Installation , error ) {
1299
1307
// get the embedded cluster config
1300
1308
cfg := release .GetEmbeddedClusterConfig ()
@@ -1311,8 +1319,9 @@ func recordInstallation(
1311
1319
1312
1320
// record the installation
1313
1321
installation , err := kubeutils .RecordInstallation (ctx , kcli , kubeutils.RecordInstallationOptions {
1322
+ ClusterID : flags .clusterID ,
1314
1323
IsAirgap : flags .isAirgap ,
1315
- License : license ,
1324
+ License : flags . license ,
1316
1325
ConfigSpec : cfgspec ,
1317
1326
MetricsBaseURL : replicatedAppURL (),
1318
1327
RuntimeConfig : rc .Get (),
0 commit comments