Adding New Customizable Resources

As a quick refresher, custom resources allow you to manage configurations for specific combinations of user projects, domains and workflows that override default values. Examples of such resources include execution clusters, task resource defaults, and more.

Note

For background on customizable resources, refer to Configuring Your Flyte Deployment.

In a multi-cluster setup, an example one could think of is setting routing rules to send certain workflows to specific clusters, which demands setting up custom resources.

Here’s how you could go about building a customizable priority designation.

Example

Let’s say you want to inject a default priority annotation for your workflows. Perhaps you start off with a model where everything has a default priority but soon you realize it makes sense that workflows in your production domain should take higher priority than those in your development domain.

Now, one of your user teams requires critical workflows to have a higher priority than other production workflows.

Here’s how you could do that.

Flyte IDL

Introduce a new matchable resource that includes a unique enum value and proto message definition.

For example:

enum MatchableResource {
  ...
  WORKFLOW_PRIORITY = 10;
}

message WorkflowPriorityAttribute {
  int priority = 1;
}

message MatchingAttributes {
  oneof target {
    ...
    WorkflowPriorityAttribute WorkflowPriority = 11;
  }
}

See the changes in this file for an example of what is required.

FlyteAdmin

Once your IDL changes are released, update the logic of FlyteAdmin to fetch your new matchable priority resource and use it while creating executions or in relevant use cases.

For example:

resource, err := s.resourceManager.GetResource(ctx, managerInterfaces.ResourceRequest{
    Domain:       domain,
    Project:      project, // optional
    Workflow:     workflow, // optional, must include project when specifying workflow
    LaunchPlan:   launchPlan, // optional, must include project + workflow when specifying launch plan
    ResourceType: admin.MatchableResource_WORKFLOW_PRIORITY,
})

if err != nil {
    return err
}

if resource != nil && resource.Attributes != nil && resource.Attributes.GetWorkflowPriority() != nil {
     priorityValue := resource.Attributes.GetWorkflowPriority().GetPriority()
     // do something with the priority here
}

Flytekit

For convenience, add a FlyteCTL wrapper to update the new attributes. Refer to this PR for the entire set of changes required.

That’s it! You now have a new matchable attribute to configure as the needs of your users evolve.