Skip to content

Commit

Permalink
Tidy up calls
Browse files Browse the repository at this point in the history
Signed-off-by: Rafael Raposo <[email protected]>
  • Loading branch information
RRap0so committed Mar 4, 2024
1 parent f53c866 commit e69cedb
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions flyteadmin/pkg/executioncluster/impl/random_cluster_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,27 @@ func (s RandomClusterSelector) GetTarget(ctx context.Context, spec *executionclu
}
return nil, fmt.Errorf("invalid cluster target %s", spec.TargetID)
}
resource, err := s.resourceManager.GetResource(ctx, managerInterfaces.ResourceRequest{
Project: spec.Project,
Domain: spec.Domain,
Workflow: spec.Workflow,
LaunchPlan: spec.LaunchPlan,
ResourceType: admin.MatchableResource_EXECUTION_CLUSTER_LABEL,
})
if err != nil && !errors.IsDoesNotExistError(err) {
return nil, err
}

var weightedRandomList random.WeightedRandomList

var label string

if spec.ClusterAssignment != nil && spec.ClusterAssignment.ExecutionClusterLabelName != "" {
label = spec.ClusterAssignment.ExecutionClusterLabelName
} else if resource != nil && resource.Attributes.GetExecutionClusterLabel() != nil {
label = resource.Attributes.GetExecutionClusterLabel().Value
} else {
resource, err := s.resourceManager.GetResource(ctx, managerInterfaces.ResourceRequest{
Project: spec.Project,
Domain: spec.Domain,
Workflow: spec.Workflow,
LaunchPlan: spec.LaunchPlan,
ResourceType: admin.MatchableResource_EXECUTION_CLUSTER_LABEL,
})
if err != nil && !errors.IsDoesNotExistError(err) {
return nil, err
}

Check warning on line 113 in flyteadmin/pkg/executioncluster/impl/random_cluster_selector.go

View check run for this annotation

Codecov / codecov/patch

flyteadmin/pkg/executioncluster/impl/random_cluster_selector.go#L112-L113

Added lines #L112 - L113 were not covered by tests
if resource != nil && resource.Attributes.GetExecutionClusterLabel() != nil {
label = resource.Attributes.GetExecutionClusterLabel().Value
}
}

if label != "" {
Expand Down

0 comments on commit e69cedb

Please sign in to comment.