-
Notifications
You must be signed in to change notification settings - Fork 304
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][CLI] Make agent prometheus port configurable #3064
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Future-Outlier <[email protected]>
Code Review Agent Run #9cfb00Actionable Suggestions - 2
Review Details
|
Signed-off-by: Future-Outlier <[email protected]>
Changelist by BitoThis pull request implements the following key changes.
|
@@ -45,20 +52,20 @@ def serve(ctx: click.Context): | |||
"for testing.", | |||
) | |||
@click.pass_context | |||
def agent(_: click.Context, port, worker, timeout): | |||
def agent(_: click.Context, port, prometheus_port, worker, timeout): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider validating the prometheus_port
parameter to ensure it doesn't conflict with the main port
parameter and is within valid port range (0-65535). A similar issue was also found in flytekit/clis/sdk_in_container/serve.py (line 83).
Code suggestion
Check the AI-generated fix before applying
@@ -55,2 +55,6 @@
def agent(_: click.Context, port, prometheus_port, worker, timeout):
+ if not 0 <= prometheus_port <= 65535:
+ raise ValueError(f'prometheus_port {prometheus_port} is not in valid range (0-65535)')
+ if prometheus_port == port:
+ raise ValueError(f'prometheus_port {prometheus_port} conflicts with main service port {port}')
"""
Code Review Run #9cfb00
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
from flytekit.extend.backend.agent_service import AgentMetadataService, AsyncAgentService, SyncAgentService | ||
|
||
click.secho("🚀 Starting the agent service...") | ||
_start_http_server() | ||
_start_http_server(prometheus_port) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling around _start_http_server(prometheus_port)
call to gracefully handle port binding failures.
Code suggestion
Check the AI-generated fix before applying
_start_http_server(prometheus_port) | |
try: | |
_start_http_server(prometheus_port) | |
except OSError as e: | |
click.secho(f"Failed to start prometheus server on port {prometheus_port}: {e}", fg="red") | |
raise |
Code Review Run #9cfb00
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3064 +/- ##
===========================================
+ Coverage 51.36% 82.79% +31.43%
===========================================
Files 202 3 -199
Lines 21367 186 -21181
Branches 2746 0 -2746
===========================================
- Hits 10975 154 -10821
+ Misses 9792 32 -9760
+ Partials 600 0 -600 ☔ View full report in Codecov by Sentry. |
Code Review Agent Run Status
|
default="9090", | ||
is_flag=False, | ||
type=int, | ||
help="Grpc port for the agent service", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!!
Signed-off-by: Future-Outlier <[email protected]> Co-authored-by: Eduardo Apolinario <[email protected]>
Code Review Agent Run Status
|
Signed-off-by: Future-Outlier <[email protected]>
Code Review Agent Run #6c3b01Actionable Suggestions - 0Review Details
|
Tracking issue
flyteorg/flyte#3936
Why are the changes needed?
we want to make Prometheus port configurable so that we can have more flexibility.
What changes were proposed in this pull request?
add a
How was this patch tested?
--prometheus_port
option to theserve agent
command, enabling users to define a custom port for the Prometheus metrics server._start_grpc_server
function to utilize the configurable Prometheus port instead of the default value.Setup process
Screenshots
Check all the applicable boxes
Related PRs
Docs link
Summary by Bito
This PR implements configurable Prometheus metrics port functionality in the Flyte agent service, introducing a '--prometheus_port' CLI option (default: 9090) with validation checks. The changes include updated CLI help text to clearly distinguish between Prometheus metrics and GRPC ports, improving service configurability and user experience.Unit tests added: False
Estimated effort to review (1-5, lower is better): 1