@@ -2,7 +2,6 @@ package services
22
33import (
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
2423func 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
3927var _ 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-
8850func supportsInstanceType (c * api.Cluster , instanceType string ) bool {
8951 supportedTypes := strings .Split (c .SupportedInstanceType , "," )
9052 for _ , t := range supportedTypes {
0 commit comments