From 4dd5125f870a42181399acee6584fe44dffc3ccf Mon Sep 17 00:00:00 2001 From: Salah Al Saleh Date: Thu, 15 Feb 2024 20:47:52 +0000 Subject: [PATCH] Report embedded cluster version --- migrations/tables/instance-report.yaml | 2 ++ pkg/api/reporting/types/types.go | 1 + pkg/reporting/app.go | 11 ++++++----- pkg/reporting/app_airgap.go | 1 + pkg/reporting/instance_report.go | 1 + pkg/reporting/report_test.go | 1 + pkg/reporting/util.go | 3 +++ 7 files changed, 15 insertions(+), 5 deletions(-) diff --git a/migrations/tables/instance-report.yaml b/migrations/tables/instance-report.yaml index 77da07e9d7..dae94afd31 100644 --- a/migrations/tables/instance-report.yaml +++ b/migrations/tables/instance-report.yaml @@ -37,6 +37,8 @@ spec: type: text - name: embedded_cluster_id type: text + - name: embedded_cluster_version + type: text - name: is_gitops_enabled type: integer - name: gitops_provider diff --git a/pkg/api/reporting/types/types.go b/pkg/api/reporting/types/types.go index 7dfad1d814..4143e7fb87 100644 --- a/pkg/api/reporting/types/types.go +++ b/pkg/api/reporting/types/types.go @@ -15,6 +15,7 @@ type ReportingInfo struct { KOTSInstallID string `json:"kots_install_id"` KURLInstallID string `json:"kurl_install_id"` EmbeddedClusterID string `json:"embedded_cluster_id"` + EmbeddedClusterVersion string `json:"embedded_cluster_version"` IsGitOpsEnabled bool `json:"is_gitops_enabled"` GitOpsProvider string `json:"gitops_provider"` SnapshotProvider string `json:"snapshot_provider"` diff --git a/pkg/reporting/app.go b/pkg/reporting/app.go index e931d4a2fa..24feb8a4ea 100644 --- a/pkg/reporting/app.go +++ b/pkg/reporting/app.go @@ -191,11 +191,12 @@ func GetReportingInfo(appID string) *types.ReportingInfo { } r := types.ReportingInfo{ - InstanceID: appID, - KOTSInstallID: os.Getenv("KOTS_INSTALL_ID"), - KURLInstallID: os.Getenv("KURL_INSTALL_ID"), - EmbeddedClusterID: os.Getenv("EMBEDDED_CLUSTER_ID"), - UserAgent: buildversion.GetUserAgent(), + InstanceID: appID, + KOTSInstallID: os.Getenv("KOTS_INSTALL_ID"), + KURLInstallID: os.Getenv("KURL_INSTALL_ID"), + EmbeddedClusterID: os.Getenv("EMBEDDED_CLUSTER_ID"), + EmbeddedClusterVersion: os.Getenv("EMBEDDED_CLUSTER_VERSION"), + UserAgent: buildversion.GetUserAgent(), } cfg, err := k8sutil.GetClusterConfig() diff --git a/pkg/reporting/app_airgap.go b/pkg/reporting/app_airgap.go index 86b5ac7c81..16aab9e6a2 100644 --- a/pkg/reporting/app_airgap.go +++ b/pkg/reporting/app_airgap.go @@ -68,6 +68,7 @@ func BuildInstanceReport(licenseID string, reportingInfo *types.ReportingInfo) * KotsInstallID: reportingInfo.KOTSInstallID, KurlInstallID: reportingInfo.KURLInstallID, EmbeddedClusterID: reportingInfo.EmbeddedClusterID, + EmbeddedClusterVersion: reportingInfo.EmbeddedClusterVersion, IsGitOpsEnabled: reportingInfo.IsGitOpsEnabled, GitOpsProvider: reportingInfo.GitOpsProvider, SnapshotProvider: reportingInfo.SnapshotProvider, diff --git a/pkg/reporting/instance_report.go b/pkg/reporting/instance_report.go index 024963afa0..9bf0b3fbf2 100644 --- a/pkg/reporting/instance_report.go +++ b/pkg/reporting/instance_report.go @@ -28,6 +28,7 @@ type InstanceReportEvent struct { KotsInstallID string `json:"kots_install_id,omitempty"` KurlInstallID string `json:"kurl_install_id,omitempty"` EmbeddedClusterID string `json:"embedded_cluster_id,omitempty"` + EmbeddedClusterVersion string `json:"embedded_cluster_version,omitempty"` IsGitOpsEnabled bool `json:"is_gitops_enabled"` GitOpsProvider string `json:"gitops_provider"` SnapshotProvider string `json:"snapshot_provider"` diff --git a/pkg/reporting/report_test.go b/pkg/reporting/report_test.go index 35351be1dc..f4354adf2d 100644 --- a/pkg/reporting/report_test.go +++ b/pkg/reporting/report_test.go @@ -352,6 +352,7 @@ func createTestInstanceEvent(reportedAt int64) InstanceReportEvent { KotsInstallID: "test-kots-install-id", KurlInstallID: "test-kurl-install-id", EmbeddedClusterID: "test-embedded-cluster-id", + EmbeddedClusterVersion: "test-embedded-cluster-version", IsGitOpsEnabled: true, GitOpsProvider: "test-gitops-provider", SnapshotProvider: "test-snapshot-provider", diff --git a/pkg/reporting/util.go b/pkg/reporting/util.go index 4870bc701d..7cd2f5d503 100644 --- a/pkg/reporting/util.go +++ b/pkg/reporting/util.go @@ -64,6 +64,9 @@ func GetReportingInfoHeaders(reportingInfo *types.ReportingInfo) map[string]stri if reportingInfo.EmbeddedClusterID != "" { headers["X-Replicated-EmbeddedClusterID"] = reportingInfo.EmbeddedClusterID } + if reportingInfo.EmbeddedClusterVersion != "" { + headers["X-Replicated-EmbeddedClusterVersion"] = reportingInfo.EmbeddedClusterVersion + } headers["X-Replicated-KurlNodeCountTotal"] = strconv.Itoa(reportingInfo.KurlNodeCountTotal) headers["X-Replicated-KurlNodeCountReady"] = strconv.Itoa(reportingInfo.KurlNodeCountReady)