Skip to content

Commit 2fbf033

Browse files
authored
ROX-16108: Remove Targeted Cluster Placement Strategy (#903)
* Remove targeted cluster placement strategy. * Fix the FirstReadyPlacementStrategy to be a pointer
1 parent 275af43 commit 2fbf033

File tree

3 files changed

+3
-56
lines changed

3 files changed

+3
-56
lines changed

internal/dinosaur/pkg/config/dataplane_cluster_config.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ type DataplaneClusterConfig struct {
3030
// 'none' to disabled scaling all together, useful in testing
3131
DataPlaneClusterScalingType string `json:"dataplane_cluster_scaling_type"`
3232
DataPlaneClusterConfigFile string `json:"dataplane_cluster_config_file"`
33-
DataPlaneClusterTarget string `json:"dataplane_cluster_target"`
3433
ReadOnlyUserList userv1.OptionalNames
3534
ReadOnlyUserListFile string
3635
// TODO ROX-11294 adjust or drop sre user list
@@ -318,7 +317,6 @@ func (c *DataplaneClusterConfig) AddFlags(fs *pflag.FlagSet) {
318317
fs.StringVar(&c.FleetshardOperatorOLMConfig.Namespace, "fleetshard-operator-namespace", c.FleetshardOperatorOLMConfig.Namespace, "fleetshard operator namespace")
319318
fs.StringVar(&c.FleetshardOperatorOLMConfig.Package, "fleetshard-operator-package", c.FleetshardOperatorOLMConfig.Package, "fleetshard operator package")
320319
fs.StringVar(&c.FleetshardOperatorOLMConfig.SubscriptionChannel, "fleetshard-operator-sub-channel", c.FleetshardOperatorOLMConfig.SubscriptionChannel, "fleetshard operator subscription channel")
321-
fs.StringVar(&c.DataPlaneClusterTarget, "dataplane-cluster-target", "", "specify cluster by ID on which new centrals should be created")
322320
}
323321

324322
// ReadFiles ...

internal/dinosaur/pkg/services/cluster_placement_strategy.go

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package services
22

33
import (
44
"errors"
5-
"fmt"
65
"strings"
76

87
"github.com/stackrox/acs-fleet-manager/internal/dinosaur/pkg/api/dbapi"
@@ -22,18 +21,7 @@ type ClusterPlacementStrategy interface {
2221
// placement configuration. An appropriate ClusterPlacementStrategy implementation
2322
// is returned based on the received parameters content
2423
func NewClusterPlacementStrategy(clusterService ClusterService, dataplaneClusterConfig *config.DataplaneClusterConfig) ClusterPlacementStrategy {
25-
var clusterSelection ClusterPlacementStrategy
26-
if dataplaneClusterConfig.DataPlaneClusterTarget != "" {
27-
clusterSelection = TargetClusterPlacementStrategy{
28-
targetClusterID: dataplaneClusterConfig.DataPlaneClusterTarget,
29-
clusterService: clusterService}
30-
} else {
31-
clusterSelection = FirstReadyPlacementStrategy{
32-
clusterService: clusterService,
33-
}
34-
}
35-
36-
return clusterSelection
24+
return &FirstReadyPlacementStrategy{clusterService: clusterService}
3725
}
3826

3927
var _ ClusterPlacementStrategy = (*FirstReadyPlacementStrategy)(nil)
@@ -59,32 +47,6 @@ func (d FirstReadyPlacementStrategy) FindCluster(central *dbapi.CentralRequest)
5947
return nil, errors.New("no schedulable cluster found")
6048
}
6149

62-
var _ ClusterPlacementStrategy = TargetClusterPlacementStrategy{}
63-
64-
// TargetClusterPlacementStrategy implements the ClusterPlacementStrategy to always return the same cluster
65-
type TargetClusterPlacementStrategy struct {
66-
targetClusterID string
67-
clusterService ClusterService
68-
}
69-
70-
// FindCluster returns the target cluster of the placement strategy if found in the cluster list
71-
func (f TargetClusterPlacementStrategy) FindCluster(central *dbapi.CentralRequest) (*api.Cluster, error) {
72-
cluster, err := f.clusterService.FindClusterByID(f.targetClusterID)
73-
if err != nil {
74-
return nil, err
75-
}
76-
77-
if !supportsInstanceType(cluster, central.InstanceType) {
78-
return nil, fmt.Errorf("target cluster %s, does not support instance type %s", f.targetClusterID, central.InstanceType)
79-
}
80-
81-
if cluster != nil {
82-
return cluster, nil
83-
}
84-
85-
return nil, fmt.Errorf("target cluster %v not found in cluster list", f.targetClusterID)
86-
}
87-
8850
func supportsInstanceType(c *api.Cluster, instanceType string) bool {
8951
supportedTypes := strings.Split(c.SupportedInstanceType, ",")
9052
for _, t := range supportedTypes {

internal/dinosaur/pkg/services/cluster_placement_strategy_test.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
)
1616

1717
func TestPlacementStrategyType(t *testing.T) {
18-
1918
tt := []struct {
2019
description string
2120
createClusterService func() ClusterService
@@ -27,20 +26,8 @@ func TestPlacementStrategyType(t *testing.T) {
2726
createClusterService: func() ClusterService {
2827
return &ClusterServiceMock{}
2928
},
30-
dataPlaneConfig: &config.DataplaneClusterConfig{
31-
DataPlaneClusterTarget: "",
32-
},
33-
expectedType: FirstReadyPlacementStrategy{},
34-
},
35-
{
36-
description: "TargetClusterPlacementStrategy",
37-
createClusterService: func() ClusterService {
38-
return &ClusterServiceMock{}
39-
},
40-
dataPlaneConfig: &config.DataplaneClusterConfig{
41-
DataPlaneClusterTarget: "test-cluster-id",
42-
},
43-
expectedType: TargetClusterPlacementStrategy{},
29+
dataPlaneConfig: &config.DataplaneClusterConfig{},
30+
expectedType: &FirstReadyPlacementStrategy{},
4431
},
4532
}
4633

0 commit comments

Comments
 (0)