Skip to content

Commit

Permalink
Rename Clusters field to be InaccessibleClusters
Browse files Browse the repository at this point in the history
  • Loading branch information
nrfox committed Jan 3, 2024
1 parent 23af738 commit b1dd7b2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 21 deletions.
5 changes: 2 additions & 3 deletions business/mesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,10 @@ func (in *MeshService) GetClusters() ([]kubernetes.Cluster, error) {
}

// Add clusters from config.
for _, cluster := range in.conf.Clustering.Clusters {
for _, cluster := range in.conf.Clustering.InaccessibleClusters {
if _, found := clustersByName[cluster.Name]; !found {
clustersByName[cluster.Name] = kubernetes.Cluster{
Name: cluster.Name,
Accessible: cluster.Accessible,
Name: cluster.Name,
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions business/mesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1120,9 +1120,8 @@ func TestGetClustersShowsConfiguredKialiInstances(t *testing.T) {
require := require.New(t)
assert := assert.New(t)
conf := config.NewConfig()
conf.Clustering.Clusters = []config.Cluster{{
Name: "west",
Accessible: false,
conf.Clustering.InaccessibleClusters = []config.Cluster{{
Name: "west",
}}
conf.Clustering.KialiURLs = []config.KialiURL{{
InstanceName: "kiali",
Expand Down
19 changes: 5 additions & 14 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ var overrideSecretsDir = "/kiali-override-secrets"
type Cluster struct {
// Name of the cluster. Must be unique and match what is in telemetry.
Name string `yaml:"name,omitempty"`
// Accessible whether or not the kiali server can access this cluster.
// Only manually specified clusters that kiali cannot access should
// be marked as inaccessible. For example, with two clusters A and B
// and two Kialis A and B where kiali A is on cluster A and kiali B
// is on cluster B, without access to the other cluster, Kiali A should
// add a config for Cluster B and mark it as inaccessbile and Kiali B
// should add a config for Cluster A and mark it as inaccessible.
Accessible bool `yaml:"accessible"`
}

// Metrics provides metrics configuration for the Kiali server.
Expand Down Expand Up @@ -515,10 +507,9 @@ type CertificatesInformationIndicators struct {

// Clustering defines configuration around multi-cluster functionality.
type Clustering struct {
// Clusters represents clusters that are part of the mesh but that Kiali may not have access to.
// For this reason it is not an exhaustive list of clusters and shouldn't be relied on for that.
Clusters []Cluster `yaml:"clusters,omitempty" json:"clusters,omitempty"`
KialiURLs []KialiURL `yaml:"kiali_urls,omitempty" json:"kiali_urls,omitempty"`
// InaccessibleClusters represents clusters that are part of the mesh but that Kiali may not have access to.
InaccessibleClusters []Cluster `yaml:"inaccessible_clusters,omitempty" json:"inaccessible_clusters,omitempty"`
KialiURLs []KialiURL `yaml:"kiali_urls,omitempty" json:"kiali_urls,omitempty"`
}

type FeatureFlagClustering struct {
Expand Down Expand Up @@ -1049,8 +1040,8 @@ func Unmarshal(yamlString string) (conf *Config, err error) {

// Copy over feature flags that have been upgraded to the new format.
// TODO: Remove when we no longer support the old format.
if conf.Clustering.Clusters == nil && conf.KialiFeatureFlags.Clustering.Clusters != nil {
conf.Clustering.Clusters = conf.KialiFeatureFlags.Clustering.Clusters
if conf.Clustering.InaccessibleClusters == nil && conf.KialiFeatureFlags.Clustering.InaccessibleClusters != nil {
conf.Clustering.InaccessibleClusters = conf.KialiFeatureFlags.Clustering.InaccessibleClusters
}

if conf.Clustering.KialiURLs == nil && conf.KialiFeatureFlags.Clustering.KialiURLs != nil {
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/tests/clusters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestRemoteKialiShownInClustersResponse(t *testing.T) {
require.NoError(err)
originalConf := *conf

conf.Clustering.Clusters = []config.Cluster{{Name: "inaccessible", Accessible: false}}
conf.Clustering.InaccessibleClusters = []config.Cluster{{Name: "inaccessible"}}
conf.Clustering.KialiURLs = []config.KialiURL{{ClusterName: "inaccessible", URL: "http://inaccessible:20001", InstanceName: "kiali", Namespace: "istio-system"}}

t.Cleanup(func() {
Expand Down

0 comments on commit b1dd7b2

Please sign in to comment.