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

WIP: Support for API-ops proxy #507

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

Conversation

chrismarget-j
Copy link
Collaborator

@chrismarget-j chrismarget-j commented Feb 26, 2025

This PR introduces support for talking to Apstra via the API-ops cloud proxy.

When talking via the proxy, we need to know:

  • the proxy URL (this is taken from the regular url configuration element - it is now either the URL of Apstra, or the URL of the proxy, depending on other configuration)
  • the datacenter ID which identifies the target apstra

We don't need to know the username/password and we'll never authenticate or handle an authentication token.

Payloads to and from the API-ops proxy are encapsulated in extra messaging layers.

Changes in this PR:

  • The ClientCfg struct has sprouted a new element: apiOpsDcId *string. When not-nil, the element signals that we should be talking via proxy.
  • ClientCfg.NewClient() sets apiOpsDcId based on environment variable API_OPS_DATACENTER_EDGE_ID.
  • ClientCfg.validate() does not complain about missing credentails when API_OPS_DATACENTER_EDGE_ID is set.
  • The Client.login() and Client.logout functions no longer start/stop the task monitor goroutine. That behavior has been moved to Client.Login() and Client.Logout(). The public methods do not invoke their respective private methods when the proxy is enabled. Clients running in proxy mode have the task monitor pre-started.
  • Client.talkToApstra() calls Client.talkToApiOps() (same function signature) when in proxy mode.
  • talkToApiOps() defaults to requesting gzip compression from Apstra. This is an attempt to keep payloads below the 1MB limit imposed by the API-ops proxy. Payloads exceeding the limit will be relayed through S3. TODO
  • Most of the talkToApstra() functionality is reimplemented in talToApiOps() with proxy-specific behaviors.
  • A bunch of old tests got touched while debugging the proxy behavior. Most importantly, tests which invoke Login() or Logout() must now be skipped.
  • Added support for API-ops proxy clients to getTestClients()

@chrismarget-j chrismarget-j marked this pull request as draft February 26, 2025 19:44
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.

1 participant