diff --git a/pkg/executioncluster/impl/random_cluster_selector.go b/pkg/executioncluster/impl/random_cluster_selector.go index 49321818e..e4ec1aecd 100644 --- a/pkg/executioncluster/impl/random_cluster_selector.go +++ b/pkg/executioncluster/impl/random_cluster_selector.go @@ -130,7 +130,6 @@ func (s RandomClusterSelector) GetTarget(ctx context.Context, spec *executionclu if flyteAdminError, ok := err.(errors.FlyteAdminError); !ok || flyteAdminError.Code() != codes.NotFound { return nil, err } - return nil, err } var weightedRandomList random.WeightedRandomList if resource != nil && resource.Attributes.GetExecutionClusterLabel() != nil { diff --git a/pkg/executioncluster/impl/random_cluster_selector_test.go b/pkg/executioncluster/impl/random_cluster_selector_test.go index ef48fbfe1..bf6f08b83 100644 --- a/pkg/executioncluster/impl/random_cluster_selector_test.go +++ b/pkg/executioncluster/impl/random_cluster_selector_test.go @@ -143,6 +143,16 @@ func TestRandomClusterSelectorGetTargetForDomainAndExecution2(t *testing.T) { } func TestRandomClusterSelectorGetRandomTarget(t *testing.T) { + cluster := getRandomClusterSelectorForTest(t) + target, err := cluster.GetTarget(context.Background(), &executioncluster.ExecutionTargetSpec{ + Project: "", + }) + assert.Nil(t, err) + assert.True(t, target.ID == "testcluster1" || target.ID == "testcluster2" || target.ID == "testcluster3") + assert.True(t, target.Enabled) +} + +func TestRandomClusterSelectorGetRandomTargetUsingEmptySpec(t *testing.T) { cluster := getRandomClusterSelectorForTest(t) _, err := cluster.GetTarget(context.Background(), nil) assert.NotNil(t, err)