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

Rename websocket notification channel URL path #537

Merged
merged 18 commits into from
Jul 2, 2021
Merged

Rename websocket notification channel URL path #537

merged 18 commits into from
Jul 2, 2021

Conversation

hareetd
Copy link
Contributor

@hareetd hareetd commented Jun 23, 2021

Change the path from api/v1/command to api/v1/notifications since the websocket channel is now used for one-way notifications instead of commands.

Fixes #478

@hareetd hareetd requested a review from andrewazores June 23, 2021 20:09
@andrewazores
Copy link
Member

How does this handle the Since it's part of the published 1.0 API, the existing path should still be exposed and result in a successful connection if clients attempt to use it. requirement from the original issue?

@hareetd
Copy link
Contributor Author

hareetd commented Jun 23, 2021

Looks like I misunderstood the issue. Breaking that requirement down:

  1. the existing path should still be exposed: does this mean the ClientUrlGetHandler should still return the path api/v1/command, or perhaps return both possible paths?

  2. result in a successful connection if clients attempt to use it: I guess this means I should include functionality in the code such that both paths "work"

I'm just a bit confused because I thought with the deprecation of Commands we would want to remove any mention of them. Are we waiting to do that until the 2.0 API is published and completely replaces the 1.0 API?

@andrewazores
Copy link
Member

andrewazores commented Jun 23, 2021

the existing path should still be exposed: does this mean the ClientUrlGetHandler should still return the path api/v1/command, or perhaps return both possible paths?

It can just return the new path, as you've done. This is what clients are supposed to use to check what the notification channel URL is, so it should tell them what the newest/preferred place to go is. But, clients aren't required to do a GET on this endpoint before connecting - it's just there as a reference and the "correct" way to check where to connect to before opening a connection.

The handler may as well be renamed while we're here, too. ClientUrl reflects the original interactive mode from early ContainerJFR days. NotificationsGetHandler would match the handler naming convention better now.

result in a successful connection if clients attempt to use it: I guess this means I should include functionality in the code such that both paths "work"

Right. Even though we want to stop referring to the notification channel as a command channel, since that is now a misleading name, it should also be cheap and easy for us to still support clients that try to connect on the old path. If a redirect (ex. HTTP 301) can be used here then that's probably ideal.

I'm just a bit confused because I thought with the deprecation of Commands we would want to remove any mention of them. Are we waiting to do that until the 2.0 API is published and completely replaces the 1.0 API?

The Commands removal definitely won't be going into v1, since we already have a published 1.0.0 release, and so any further 1.x.y releases should avoid changing or removing anything that would break any potential end users' clients and scripts that exist and were built against the 1.0.0 API. Breaking changes like that should only arrive in 2.0.0 (or any other major version release). That said, where it's possible, it would also be nice of us to make migration from 1.0->2.0 as easy as possible, so that could mean doing things like HTTP 301 redirects on renamed paths, so that any third-party clients/scripts will continue to work but users will (hopefully) see the 301 status and realize that they're using something that is changed/deprecated and they should prepare for it to be removed or otherwise more significantly altered (in a breaking way) in a future release.

@andrewazores
Copy link
Member

On the other hand, since /api/v1/commands in 1.0.0 implements an interactive command channel, and /api/v1/notifications in 2.0.0 implements a push notification channel, perhaps /api/v1/commands should not redirect the client but instead respond with a 410 GONE response, so that the clients fail to connect and hopefully do so in an informative way for the end user.

@hareetd
Copy link
Contributor Author

hareetd commented Jun 24, 2021

Thanks for the explanation, it cleared up any misconceptions I had.

I think a 410 GONE response would make more sense as it would (hopefully) funnel clients towards getting the new path from the updated handler. I'll go ahead and implement your other suggestions as well; will let you know if I have any other questions.

@hareetd hareetd marked this pull request as draft June 24, 2021 14:33
@hareetd
Copy link
Contributor Author

hareetd commented Jun 25, 2021

@andrewazores (not sure if you get notified for comments on draft PRs)

I'm almost done but had a few questions first:

  1. I decided to rename ClientUrlGetHandler to NotificationsUrlGetHandler, instead of NotificationsGetHandler as you previously suggested, because it matches the GrafanaDashboardUrlGetHandler convention and I think it's a more accurate name. Is this fine or should I change it to NotificationsGetHandler?

  2. For the HTTP_API.md, should I also change the synopsis for the updated handler, and if so, what to?

  3. Should I add a new test in MessagingServerTest to check if api/v1/command rejects the websocket connection with a 410 GONE status code? I'm leaning towards no since all the test would check is an if statement.

@andrewazores
Copy link
Member

Yes, I still get notified on drafts.

  1. No, what you've done makes sense and sounds good.
  2. I think just removing/changing mentions of "command channel" to "notification channel" or similar should be fine?
  3. A test probably does make sense even though it seems so simple. Doing it as an integration-test might be even better here.

@hareetd
Copy link
Contributor Author

hareetd commented Jun 29, 2021

I've finished writing up the integration test; had a few difficulties extracting the HTTP status code from the thrown exception(s) so I settled with comparing the error message instead.

@hareetd hareetd marked this pull request as ready for review June 29, 2021 20:43
Copy link
Member

@andrewazores andrewazores left a comment

Choose a reason for hiding this comment

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

Looks good! Again, I will hold off on approving/merging this until there is a corresponding change in -web. Are you interested in taking a look at that yourself? It should be a pretty small patch.

@hareetd
Copy link
Contributor Author

hareetd commented Jun 30, 2021

Sure, I can do that.

It looks like NotificationChannel.service.tsx in -web still references clienturl; I can open an issue and take care of that.

Were there any other corresponding changes you had in mind?

@andrewazores
Copy link
Member

No, that's all that comes to mind.

@andrewazores
Copy link
Member

web-client change is merged. Please update this PR with a commit bumping the submodule version again, and then I'll approve and merge this too.

@hareetd
Copy link
Contributor Author

hareetd commented Jul 2, 2021

Just double-checking, but the merge conflict is because the web-client is pointing to a different commit than the one on the main branch, right?

@andrewazores
Copy link
Member

andrewazores commented Jul 2, 2021 via email

@hareetd
Copy link
Contributor Author

hareetd commented Jul 2, 2021

Looks like it worked. I guess in the future it's best to rebase at the end to prevent merge conflicts? I've only been rebasing my branches right before opening the PR.

@andrewazores
Copy link
Member

andrewazores commented Jul 2, 2021 via email

@andrewazores andrewazores merged commit ec30b79 into cryostatio:main Jul 2, 2021
@hareetd hareetd deleted the update-web-socket-notification-channel-path branch July 2, 2021 17:28
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.

/api/v1/command should be renamed /api/v1/notifications
2 participants