Skip to content

argocd: use native http client, apply fallback on sync timeout, local ITs instance script #193

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

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

Conversation

benbroadaway
Copy link
Collaborator

@benbroadaway benbroadaway commented Apr 4, 2025

Use Java's native HttpClient instead of Apache's.

Streamline dependencies. Less stuff to manage over time.

Apply syncTimeout to entire CallRetry operation.

Previously, the timeout was implicitly applied through the http call made within. This could result in a duration up-to retryCount * syncTimeout--say, if the operation was interrupted 59 minutes into a 60 minutes timeout, then a retry would be given at least another 60 minute window. ArgoCD's sync call is essentially a single long-running GET call. Since CallRetry is currently only used for that purpose, the reliance on a socket timeout worked "good enough"--assuming the call wasn't interrupted by something other than a SocketTimeout.

This PR's change to CallRetry forces a timeout against the operation as a whole, so if for some odd reason the http's socket timeout doesn't occur, it will still effectively timeout as expected. This further makes the class more reusable for in the future.

Apply "fallback" calls after timeout of "main" call in CallRetry

Previously, if the main call timed out, then that immediately was the end of things. Now, the fallback call(s) are made in the case of a main call timeout.

Local integration tests

Added script and Ansible playbook to bootstrap a local ArgoCD instance for integration testing. See details in README.md

@benbroadaway benbroadaway requested review from jchikatur, hemant0308 and a team April 4, 2025 16:24
@benbroadaway benbroadaway changed the title argocd: use native http client argocd: use native http client, apply fallback on sync timeout, local ITs instance script Apr 4, 2025
public static String auth(String baseUrl, TaskParams.BasicAuth auth) throws IOException {
private BasicAuthHandler() { }

public static String auth(HttpClient.Builder httpBuilder, String baseUrl, TaskParams.BasicAuth auth) throws IOException {
Map<String, Object> body = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

var here? Should var usage be at least method-wide or, better yet, for the entire file (unless it requires casting like in the lastError case below)?

.build();

try {
// this will redirect, hopefully client is configured to do so
Copy link
Collaborator

Choose a reason for hiding this comment

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

Set followRedirects explicitly?

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

Successfully merging this pull request may close these issues.

2 participants