ayush00git opened a new pull request, #56:
URL: https://github.com/apache/openserverless-cli/pull/56

   Fixes apache/openserverless#175
   
   ### Problem
   
   Behind a corporate proxy (HTTP_PROXY/HTTPS_PROXY set), `ops setup 
devcluster` deploys the cluster fine but then loops for 600 s in the final 
login step:
   
   Unable to obtain the list of available namespaces: The connection failed, or 
timed out. (HTTP status code 502)
   
   Every command that talks to the apihost fails the same way, ops -wsk , bun 
scripts such as `ops env list`, curl calls in tasks.
   
   ### Cause
   
   ops does honor the proxy variables; the trouble is that it honors them for 
its own `apihost` too. `http://miniops.me` resolves to `127.0.0.1`, but Go, bun 
and curl only bypass the proxy for hosts listed in `NO_PROXY`, matching by name 
rather than by resolved address. So requests meant for the local machine are 
sent to the corporate proxy, which cannot reach it. Nothing in the CLI or the 
tasks ever sets `NO_PROXY`.
   
   Reproduced with a forward proxy that refuses loopback targets (as a real 
corporate proxy effectively does); its log showed `GET 
http://miniops.me/api/v1/namespaces` and `POST 
http://miniops.me/api/v1/web/whisk-system/nuv/secrets` arriving from wsk and 
bun. Adding `miniops.me` to `NO_PROXY` by hand made everything work.
   
   ### Fix
   
   When a proxy is configured, ops adds the `apihosts` it knows about, 
`OPS_APIHOST`, `OPERATOR_CONFIG_APIHOST`, `APIHOST` from ~/.wskprops, and the 
`apihost` passed to `ops -login`, to both `NO_PROXY` and `no_proxy`. Existing 
entries of both spellings are merged first, so neither one shadows the other.
   
   It runs twice: once before any network call (Go reads the proxy environment 
only once per process) and once after the config env vars are loaded, so wsk, 
bun and curl spawned by tasks inherit the result. It is idempotent and a no-op 
when no proxy variable is set.
   
   ### Testing
   
   - New unit tests in `noproxy_test.go` (host parsing, merging, env handling, 
-login argument parsing).
   - Live, behind the proxy with only `NO_PROXY=localhost,127.0.0.1`: `ops env 
list`, `ops -wsk namespace list`, `ops -wsk action invoke hello/hello`, `ops 
setup openserverless login` and `ops -login` http://miniops.me all succeed; the 
proxy log shows zero requests for the apihost, while https://github.com still 
goes through the proxy.
   - Without proxy variables, behaviour is unchanged.
   
   ### when `apihosts` were not added vs when added to `NO-PROXY`
   
   ```bash
   
   openserverless on  main via  v3.14.8 
   ❯ HTTP_PROXY=http://172.18.0.1:3128 HTTPS_PROXY=http://172.18.0.1:3128 \
   NO_PROXY=localhost,127.0.0.1 ops env list
   Error while making API request
   ops: Failed to run task "list": exit status 1
   task execution error: ops: Failed to run task "list": exit status 1
   
   openserverless on  main via  v3.14.8 
   ❯ HTTP_PROXY=http://172.18.0.1:3128 HTTPS_PROXY=http://172.18.0.1:3128 \
   NO_PROXY=localhost,127.0.0.1,miniops.me ops env list
   
   Current Env
   
----------------------------------------------------------------------------------------------------------------
   | Key  | Value                                                               
                                  |
   
----------------------------------------------------------------------------------------------------------------
   | AUTH | 
6aba2f0e-26b3-4354-8cc7-7c20b27a427b:eamviYu1A5Ffms07b******mKMWD2nHDYMakwzD0uffOVzYDAfIChnB
 |
   
----------------------------------------------------------------------------------------------------------------
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to