Skip to content

Commit

Permalink
[flyteagent] Add Logging for Agent Supported Task Types (flyteorg#5718)
Browse files Browse the repository at this point in the history
* Add Logging for Agent-Supported Task Types

Signed-off-by: Future-Outlier <[email protected]>

* use make(map[string]struct{})

Signed-off-by: Future-Outlier <[email protected]>

---------

Signed-off-by: Future-Outlier <[email protected]>
Signed-off-by: Bugra Gedik <[email protected]>
  • Loading branch information
Future-Outlier authored and bgedik committed Sep 12, 2024
1 parent 2dc91ca commit 573516f
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion flyteplugins/go/tasks/plugins/webapi/agent/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package agent
import (
"context"
"crypto/x509"
"strings"

"golang.org/x/exp/maps"
"google.golang.org/grpc"
Expand Down Expand Up @@ -127,19 +128,26 @@ func getAgentRegistry(ctx context.Context, cs *ClientSet) Registry {
continue
}

agentSupportedTaskCategories := make(map[string]struct{})
for _, agent := range res.GetAgents() {
deprecatedSupportedTaskTypes := agent.SupportedTaskTypes
for _, supportedTaskType := range deprecatedSupportedTaskTypes {
agent := &Agent{AgentDeployment: agentDeployment, IsSync: agent.IsSync}
newAgentRegistry[supportedTaskType] = map[int32]*Agent{defaultTaskTypeVersion: agent}
agentSupportedTaskCategories[supportedTaskType] = struct{}{}
}

supportedTaskCategories := agent.SupportedTaskCategories
for _, supportedCategory := range supportedTaskCategories {
agent := &Agent{AgentDeployment: agentDeployment, IsSync: agent.IsSync}
newAgentRegistry[supportedCategory.GetName()] = map[int32]*Agent{supportedCategory.GetVersion(): agent}
supportedCategoryName := supportedCategory.GetName()
newAgentRegistry[supportedCategoryName] = map[int32]*Agent{supportedCategory.GetVersion(): agent}
agentSupportedTaskCategories[supportedCategoryName] = struct{}{}
}

}
logger.Infof(ctx, "AgentDeployment [%v] supports the following task types: [%v]", agentDeployment.Endpoint,
strings.Join(maps.Keys(agentSupportedTaskCategories), ", "))
}

// If the agent doesn't implement the metadata service, we construct the registry based on the configuration
Expand All @@ -160,6 +168,7 @@ func getAgentRegistry(ctx context.Context, cs *ClientSet) Registry {
}
}

logger.Infof(ctx, "AgentDeployments support the following task types: [%v]", strings.Join(maps.Keys(newAgentRegistry), ", "))
return newAgentRegistry
}

Expand Down

0 comments on commit 573516f

Please sign in to comment.