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 9a80c3e commit b37b76a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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
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 b37b76a

Please sign in to comment.