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

Use sumologic extension base URL to determine the appropriate OpAMP endpoint #1399

Merged
merged 9 commits into from
Jan 11, 2024

Conversation

portertech
Copy link
Contributor

The sumologic extension may update/alter the API base URL used, following the collector registration process. This base URL redirection is tied to the installation token which the OpAMP extension isn't aware of. Update the OpAMP extension to leverage the sumologic extension's base URL to determine the appropriate OpAMP endpoint (i.e. region).

@echlebek echlebek marked this pull request as ready for review January 2, 2024 18:33
@echlebek echlebek requested a review from a team as a code owner January 2, 2024 18:33
@echlebek
Copy link
Collaborator

echlebek commented Jan 2, 2024

I feel this approach is a bit hacky and could fail if the URL structure of the base URL changes. However, given the transitional nature of the landscape here, perhaps it's fine. What do reviewers think?

@sumo-drosiek
Copy link
Contributor

This is very hacky and I wouldn't say reliable as long-term solution. Can we ensure that this will be done properly in the future? The address should be returned by the API backend

@echlebek echlebek changed the title Use sumologic extention base URL to determine the appropriate OpAMP endpoint Use sumologic extension base URL to determine the appropriate OpAMP endpoint Jan 9, 2024
@echlebek echlebek enabled auto-merge (squash) January 9, 2024 03:01
Comment on lines 228 to 231
{
name: "empty url defaults to config endpoint",
wantEndpoint: "https://example.com",
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure that this test case indicates valid behaviour. It's a reproduction of the business logic that was encoded in the draft PR, and may need to be changed.

@echlebek
Copy link
Collaborator

echlebek commented Jan 9, 2024

@swiatekm-sumo if you could take a look, I would appreciate it, thank you! 🙏

u.Host = strings.Replace(u.Host, "open-events", "opamp-events", 1)
u.Host = strings.Replace(u.Host, "open-collectors", "opamp-collectors", 1)
Copy link

Choose a reason for hiding this comment

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

I thought we'd agreed to parse the Sumo deployment name out of the domain and explicitly construct a new one. Any reason to do a string replace here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it's my naivete regarding Sumo deployments, but it seems even more error prone to me. How do I know which deployments correspond to open-events, and which correspond to open-collectors (and correspondingly, opamp-events and opamp-collectors). This knowledge is not encoded anywhere in the codebase, unless I'm mistaken, and I don't know how it would be determined either.

Choose a reason for hiding this comment

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

I was hoping to do https://long-open-events.sumologic.net -> deployment = long -> construct wss://{{ deployment }}-opamp-events.sumologic.net/v1/opamp. But looking at it now, these domains are actually different in production environments, so this might be even more complicated.

I'm fine with it if we add test cases for all the possible forms of this url. For example, on prod it's just open-collectors.sumologic.com.

Copy link
Contributor

@Gourav2906 Gourav2906 Jan 10, 2024

Choose a reason for hiding this comment

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

wss://stag-opamp-events.sumologic.net/v1/opamp
wss://long-opamp-events.sumologic.net/v1/opamp
wss://opamp-collectors.au.sumologic.comt/v1/opamp
wss://opamp-collectors.ca.sumologic.comt/v1/opamp
wss://opamp-collectors.de.sumologic.comt/v1/opamp
wss://opamp-collectors.eu.sumologic.comt/v1/opamp
wss://opamp-collectors.fed.sumologic.comt/v1/opamp
wss://opamp-collectors.in.sumologic.comt/v1/opamp
wss://opamp-collectors.jp.sumologic.comt/v1/opamp
wss://opamp-collectors.sumologic.comt/v1/opamp
wss://opamp-collectors.us2.sumologic.comt/v1/opamp

Open receiver can be found at
https://help.sumologic.com/docs/api/getting-started/#sumo-logic-endpoints-by-deployment-and-firewall-security

@swiatekm swiatekm force-pushed the feature/opamp-base-url branch from 3465f7f to e52be4c Compare January 11, 2024 13:50
@swiatekm swiatekm force-pushed the feature/opamp-base-url branch from e52be4c to 18555a9 Compare January 11, 2024 14:34
@swiatekm swiatekm force-pushed the feature/opamp-base-url branch from 9b5af12 to e632091 Compare January 11, 2024 14:43
@echlebek echlebek merged commit 6d4048c into main Jan 11, 2024
28 checks passed
@echlebek echlebek deleted the feature/opamp-base-url branch January 11, 2024 14:56
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.

6 participants