Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flyteagent] Default Service Config Using Round Robin Mechanism #6179

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions flyteplugins/go/tasks/plugins/webapi/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ var (
},
},
DefaultAgent: Deployment{
Endpoint: "",
Insecure: true,
DefaultTimeout: config.Duration{Duration: 10 * time.Second},
Endpoint: "",
Insecure: true,
DefaultTimeout: config.Duration{Duration: 10 * time.Second},
DefaultServiceConfig: `{"loadBalancingConfig": [{"round_robin":{}}]}`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider making service config configurable

Consider making the default service config more configurable by moving it to a separate constant or configuration option rather than hardcoding the round robin load balancing config directly in the default config struct.

Code suggestion
Check the AI-generated fix before applying
  const (
 +    DefaultServiceConfig = `{"loadBalancingConfig": [{"round_robin":{}}]}`
 )
 			Endpoint:             "",
 			Insecure:             true,
 			DefaultTimeout:       config.Duration{Duration: 10 * time.Second},
 -			DefaultServiceConfig: `{"loadBalancingConfig": [{"round_robin":{}}]}`,
 +			DefaultServiceConfig: DefaultServiceConfig,

Code Review Run #141009


Is this a valid issue, or was it incorrectly flagged by the Agent?

  • it was incorrectly flagged

},
// AsyncPlugin should be registered to at least one task type.
// Reference: https://github.com/flyteorg/flyte/blob/master/flyteplugins/go/tasks/pluginmachinery/registry.go#L27
Expand Down
20 changes: 20 additions & 0 deletions flyteplugins/go/tasks/plugins/webapi/agent/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,23 @@ func TestGetAndSetConfig(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, &cfg, GetConfig())
}

func TestDefaultAgentConfig(t *testing.T) {
cfg := defaultConfig

assert.Equal(t, "", cfg.DefaultAgent.Endpoint)
assert.True(t, cfg.DefaultAgent.Insecure)
assert.Equal(t, 10*time.Second, cfg.DefaultAgent.DefaultTimeout.Duration)
assert.Equal(t, `{"loadBalancingConfig": [{"round_robin":{}}]}`, cfg.DefaultAgent.DefaultServiceConfig)

assert.Empty(t, cfg.DefaultAgent.Timeouts)

expectedTaskTypes := []string{"task_type_1", "task_type_2"}
assert.Equal(t, expectedTaskTypes, cfg.SupportedTaskTypes)

assert.Empty(t, cfg.AgentDeployments)

assert.Empty(t, cfg.AgentForTaskTypes)

assert.Equal(t, 10*time.Second, cfg.PollInterval.Duration)
}
Loading