Skip to content

Commit

Permalink
Allow random cluster selection when no override (flyteorg#117)
Browse files Browse the repository at this point in the history
In case there is no override in resource table, we should allow the code
to go through and apply non-label based weighted random selection.

Close flyteorg#481
  • Loading branch information
honnix authored Aug 25, 2020
1 parent d094408 commit 6985f7a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion pkg/executioncluster/impl/random_cluster_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions pkg/executioncluster/impl/random_cluster_selector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6985f7a

Please sign in to comment.