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

feat: Add proxy support to CLI API client #12527

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

Conversation

shimako55
Copy link

Fixes #10794

Motivation

Issue:
In the current version of Argo Workflows, the API client does not function properly in environments that use a proxy server.

Purpose:
This PR aims to modify the Argo Workflows API client to ensure it functions correctly when routing through a proxy server.

Modifications

Summary of Changes:
Made modifications in cmd/argo/commands/client/conn.go, pkg/apiclient/apiclient.go, pkg/apiclient/http1-client.go, and pkg/apiclient/http1/facade.go.

Specific Changes:
Added proxy functionality using http.ProxyURL.
Integrated new proxy settings into the API client construction process.
Added proxy settings to the configuration of http.Client and http.Transport.

Reason for Changes:
To support the operation of the API client in proxy environments.

Verification

Testing Method:
Conducted manual tests in an environment with a configured proxy server.

Test Results:
Confirmed that the API client operates correctly when routing through a proxy.

Reproduction Steps:
Replace http://example.com:8080 with your actual proxy server URL in the following commands:

$ ./argo template list --proxy-url=http://example.com:8080

NAME
awesome-tiger

or

$ export HTTPS_PROXY=http://example.com:8080
$ ./argo template list

NAME
awesome-tiger

@shimako55 shimako55 force-pushed the feat-proxy-support-cli-tool branch from 17ce132 to d78c157 Compare January 16, 2024 08:15
Copy link
Member

@isubasinghe isubasinghe left a comment

Choose a reason for hiding this comment

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

Can you add some tests in apiclient_test.go and facade_test.go? Thanks

@shimako55
Copy link
Author

Okay, thanks. I'll give it a try. However, it might take me some time.

@shimako55 shimako55 force-pushed the feat-proxy-support-cli-tool branch 4 times, most recently from 5103e5a to b69677d Compare February 20, 2024 16:32
@shimako55
Copy link
Author

@isubasinghe
I have added facade_test.go.
I didn't know what tests were expected for apiclient_test.go. Could you please tell me specifically what kind of tests are expected?

@Joibel
Copy link
Member

Joibel commented Sep 9, 2024

As suggested by @monaka in #12827 (comment), closing as implemented by #12867.

@Joibel Joibel closed this Sep 9, 2024
@Joibel
Copy link
Member

Joibel commented Sep 9, 2024

Oops, this isn't implemented there.

@Joibel Joibel reopened this Sep 9, 2024
@agilgur5 agilgur5 changed the title feat: Add proxy support to Argo CLI API client feat: Add proxy support to CLI API client Oct 19, 2024
@shimako55 shimako55 force-pushed the feat-proxy-support-cli-tool branch from b69677d to b1226a7 Compare October 28, 2024 07:48
@isubasinghe isubasinghe self-requested a review October 28, 2024 11:27
Signed-off-by: shimako55 <[email protected]>
@shimako55 shimako55 force-pushed the feat-proxy-support-cli-tool branch from 065e8a8 to cac0ae3 Compare October 29, 2024 09:45
@shimako55
Copy link
Author

Requesting a review for this PR.
I’d appreciate any feedback, particularly on the http.Client integration. Thanks in advance!

@shimako55
Copy link
Author

Hello @isubasinghe
Could you please review this PR again when you have a moment?

Copy link
Member

@isubasinghe isubasinghe left a comment

Choose a reason for hiding this comment

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

I wasn't able to get this to work, I ran a proxy server (https://github.com/neevek/omnip) on 8899.

I got: "./argo template list --proxy-url=http://localhost:8899"

I then tried to manually set the argo-server URL to localhost:2746.

When I did this, I did get this in my cli:
FATA[2024-11-29T14:07:09.786Z] could not find a token

Can you take another look at this please?

@shimako55
Copy link
Author

Thanks @isubasinghe
I was able to successfully execute the following steps in my environment.

1. Test Environment

Installed Argo Workflows in local environment using kind

2. Server Connection Setup

Set up port forwarding to connect to the Argo server in the Kubernetes cluster:

kubectl -n argo port-forward service/argo-server 8080:2746

3. Environment Variables Configuration

Set required environment variables for Argo CLI connection:

export ARGO_SERVER='localhost:8080'
export ARGO_HTTP1=true
export ARGO_SECURE=true
export ARGO_BASE_HREF=
export ARGO_TOKEN=''
export ARGO_NAMESPACE=argo

4. Proxy Server Launch

Started proxy server using omnip:

omnip -a http://0.0.0.0:8081 -lD

5. Operation Check Results

Argo CLI Verification

argo list -k --proxy-url=http://localhost:8081

Execution Result

NAME                STATUS      AGE   DURATION   PRIORITY   MESSAGE
hello-world-256m7   Succeeded   1h    25s        0

Proxy Server Logs

2024-12-04 14:55:26.723 [omnip] [omnip::server:717] [D] serve request directly: localhost:8080 from 127.0.0.1:49532
2024-12-04 14:55:26.723 [omnip] [rs_utilities::dns:163] [D] resolved [localhost] to [127.0.0.1]
2024-12-04 14:55:26.723 [omnip] [omnip::server:876] [D] sess start: 127.0.0.1:49532      ↔ 127.0.0.1:8080
2024-12-04 14:55:26.737 [omnip] [omnip::server:942] [D] sess end  : 127.0.0.1:49532      ↔ 127.0.0.1:8080       | ⟳ 8       | ↑ 1931       ↓ 3782

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.

CLI: HTTP client ignores proxy
4 participants