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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Future-Outlier
Copy link
Member

@Future-Outlier Future-Outlier commented Jan 17, 2025

Tracking issue

#3936

Why are the changes needed?

This PR adds a default gRPC service configuration to the agent plugin that enables round-robin load balancing.
This ensures consistent and fair distribution of requests across multiple agent instances.

What changes were proposed in this pull request?

  • Added DefaultServiceConfig in the default agent configuration with round-robin load balancing policy
  • Default value set to: {"loadBalancingConfig": [{"round_robin":{}}]}
  • change agent endpoint from dns:///flyteagent.flyte.svc.cluster.local:8000 to k8s://flyteagent:8000

https://github.com/flyteorg/flyte/pull/6179/files#diff-98835a3d321cfb860916a188ca66ea98efe6c9f3a8314ea89ec2cfdf8ad50066R42-R47

How was this patch tested?

unit test and sandbox.

from flytekit import task, workflow
from flytekit.sensor.file_sensor import FileSensor

sensor = FileSensor(name="test_file_sensor")


@workflow()
def wf():
    sensor(path="s3://my-s3-bucket/a")

if __name__ == "__main__":
    import os
    from flytekit.clis.sdk_in_container import pyflyte
    from click.testing import CliRunner

    runner = CliRunner()
    path = os.path.realpath(__file__)
    
    for _ in range(100):  # Loop to trigger the workflow 100 times
        result = runner.invoke(pyflyte.main, ["run", "--remote", path, "wf"])
        print(result.output)

Labels

Please add one or more of the following labels to categorize your PR:

  • added: For new features.
  • changed: For changes in existing functionality.
  • deprecated: For soon-to-be-removed features.
  • removed: For features being removed.
  • fixed: For any bug fixed.
  • security: In case of vulnerabilities

This is important to improve the readability of release notes.

Setup process

agent-service:
defaultAgent:
  defaultTimeout: 10s
  endpoint: k8s://flyteagent:8000
  insecure: true
  timeouts:
    GetTask: 10s

Screenshots

image

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Summary by Bito

Implementation of round-robin load balancing for Flyte agent service, including default configuration through DefaultServiceConfig field and transition from DNS-based to Kubernetes native service discovery. Updates include endpoint configuration modifications, security-related changes to shared secrets and checksums in sandbox and development manifests, with comprehensive test coverage to validate configuration values.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 2

@flyte-bot
Copy link
Collaborator

flyte-bot commented Jan 17, 2025

Code Review Agent Run #141009

Actionable Suggestions - 1
  • flyteplugins/go/tasks/plugins/webapi/agent/config.go - 1
    • Consider making service config configurable · Line 46-46
Review Details
  • Files reviewed - 2 · Commit Range: a433b33..a433b33
    • flyteplugins/go/tasks/plugins/webapi/agent/config.go
    • flyteplugins/go/tasks/plugins/webapi/agent/config_test.go
  • Files skipped - 0
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

@flyte-bot
Copy link
Collaborator

flyte-bot commented Jan 17, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Feature Improvement - Agent Service Load Balancing Enhancement

values.yaml - Updated agent endpoint format to use k8s:// scheme

values.yaml - Updated agent endpoint format to use k8s:// scheme

complete-agent.yaml - Updated agent endpoint and security configurations

complete.yaml - Updated security configurations and checksums

dev.yaml - Updated security configurations and checksums

config.go - Added DefaultServiceConfig for round-robin load balancing

config_test.go - Added unit tests for default agent configuration

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

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.06%. Comparing base (ab463c3) to head (0d2539f).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6179      +/-   ##
==========================================
- Coverage   37.06%   37.06%   -0.01%     
==========================================
  Files        1318     1318              
  Lines      132644   132644              
==========================================
- Hits        49164    49161       -3     
- Misses      79230    79234       +4     
+ Partials     4250     4249       -1     
Flag Coverage Δ
unittests-datacatalog 51.58% <ø> (ø)
unittests-flyteadmin 54.31% <ø> (-0.03%) ⬇️
unittests-flytecopilot 30.99% <ø> (ø)
unittests-flytectl 62.29% <ø> (ø)
unittests-flyteidl 7.23% <ø> (ø)
unittests-flyteplugins 53.87% <ø> (+0.01%) ⬆️
unittests-flytepropeller 42.70% <ø> (ø)
unittests-flytestdlib 55.29% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@flyte-bot
Copy link
Collaborator

flyte-bot commented Jan 18, 2025

Code Review Agent Run #f18921

Actionable Suggestions - 0
Review Details
  • Files reviewed - 5 · Commit Range: a433b33..0d2539f
    • charts/flyte-binary/values.yaml
    • charts/flyte-core/values.yaml
    • docker/sandbox-bundled/manifests/complete-agent.yaml
    • docker/sandbox-bundled/manifests/complete.yaml
    • docker/sandbox-bundled/manifests/dev.yaml
  • Files skipped - 3
    • charts/flyte-binary/README.md - Reason: Filter setting
    • charts/flyte-core/README.md - Reason: Filter setting
    • docs/user_guide/flyte_agents/developing_agents.md - Reason: Filter setting
  • Tools
    • Golangci-lint (Linter) - ✖︎ Failed
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants