Skip to content

Commit

Permalink
ROX-22549: Change cluster_id label to cluster_name
Browse files Browse the repository at this point in the history
  • Loading branch information
kovayur committed Jun 10, 2024
1 parent ed33c31 commit 8719423
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 96 deletions.
5 changes: 3 additions & 2 deletions internal/dinosaur/pkg/gitops/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ type CentralOverride struct {

// DataPlaneClusterConfig represents the configuration to be applied for a data plane cluster.
type DataPlaneClusterConfig struct {
ClusterID string `json:"clusterID"`
Addons []AddonConfig `json:"addons"`
ClusterID string `json:"clusterID"`
ClusterName string `json:"clusterName"`
Addons []AddonConfig `json:"addons"`
}

// AddonConfig represents the addon configuration to be installed on a cluster
Expand Down
4 changes: 3 additions & 1 deletion internal/dinosaur/pkg/gitops/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ func TestProviderGet_DataPlaneClusters(t *testing.T) {
file: `
dataPlaneClusters:
- clusterID: 1234567890abcdef1234567890abcdef
clusterName: acs-dev-dp-01
`,
expectedConfigs: []DataPlaneClusterConfig{
{
ClusterID: "1234567890abcdef1234567890abcdef", // pragma: allowlist secret
ClusterID: "1234567890abcdef1234567890abcdef", // pragma: allowlist secret
ClusterName: "acs-dev-dp-01",
},
},
},
Expand Down
12 changes: 6 additions & 6 deletions internal/dinosaur/pkg/services/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func initCustomizations(config ocmImpl.AddonConfig) []addonCustomization {
type addonCustomization func(gitops.AddonConfig) gitops.AddonConfig

// Provision installs, upgrades or uninstalls the addons based on a given config
func (p *AddonProvisioner) Provision(cluster api.Cluster, expectedConfigs []gitops.AddonConfig) error {
func (p *AddonProvisioner) Provision(cluster api.Cluster, dataplaneClusterConfig gitops.DataPlaneClusterConfig) error {
var multiErr *multierror.Error
clusterID := cluster.ClusterID

Expand All @@ -70,7 +70,7 @@ func (p *AddonProvisioner) Provision(cluster api.Cluster, expectedConfigs []gito
multiErr = multierror.Append(multiErr, err)
}

for _, expectedConfig := range expectedConfigs {
for _, expectedConfig := range dataplaneClusterConfig.Addons {
for _, customization := range p.customizations {
expectedConfig = customization(expectedConfig)
}
Expand Down Expand Up @@ -116,11 +116,11 @@ func (p *AddonProvisioner) Provision(cluster api.Cluster, expectedConfigs []gito
}
if clusterInstallationDifferent(installedOnCluster, versionInstalledInOCM) {
multiErr = multierror.Append(multiErr, p.updateAddon(clusterID, expectedConfig))
updateAddonStatusMetric(clusterID, installedOnCluster, versionInstalledInOCM, metrics.AddonUpgrade)
p.updateAddonStatusMetric(dataplaneClusterConfig.ClusterName, installedOnCluster, versionInstalledInOCM, metrics.AddonUpgrade)
} else {
glog.V(10).Infof("Addon %s is already up-to-date", installedOnCluster.ID)
multiErr = validateUpToDateAddon(multiErr, installedInOCM, installedOnCluster)
updateAddonStatusMetric(clusterID, installedOnCluster, versionInstalledInOCM, metrics.AddonUp)
p.updateAddonStatusMetric(dataplaneClusterConfig.ClusterName, installedOnCluster, versionInstalledInOCM, metrics.AddonUp)
}
}

Expand All @@ -132,10 +132,10 @@ func (p *AddonProvisioner) Provision(cluster api.Cluster, expectedConfigs []gito
return errorOrNil(multiErr)
}

func updateAddonStatusMetric(clusterID string, installedOnCluster dbapi.AddonInstallation, versionInstalledInOCM *clustersmgmtv1.AddOnVersion, status metrics.AddonStatus) {
func (p *AddonProvisioner) updateAddonStatusMetric(clusterName string, installedOnCluster dbapi.AddonInstallation, versionInstalledInOCM *clustersmgmtv1.AddOnVersion, status metrics.AddonStatus) {
metrics.UpdateClusterAddonStatusMetric(
installedOnCluster.ID,
clusterID,
clusterName,
versionInstalledInOCM.ID(),
versionInstalledInOCM.SourceImage(),
versionInstalledInOCM.PackageImage(),
Expand Down
Loading

0 comments on commit 8719423

Please sign in to comment.