Skip to content

Add actuator endpoint for finding and deleting sessions #8342

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

Closed
wants to merge 1 commit into from

Conversation

vpavic
Copy link
Contributor

@vpavic vpavic commented Feb 20, 2017

This PR is an alternative approach to implementing sessions endpoint to one proposed in #5730.

Key differences:

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 20, 2017
@philwebb philwebb added this to the 2.0.0.M3 milestone Apr 27, 2017
@philwebb philwebb added priority: normal type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 27, 2017
@vpavic vpavic force-pushed the sessions-endpoint branch 4 times, most recently from b82bfd9 to 8e9ce60 Compare June 26, 2017 16:28
@vpavic vpavic force-pushed the sessions-endpoint branch from 8e9ce60 to 297e675 Compare June 27, 2017 09:50
@snicoll snicoll modified the milestones: 2.0.0.M3, 2.0.0.M4 Jul 13, 2017
@vpavic vpavic force-pushed the sessions-endpoint branch from 297e675 to c8599f7 Compare July 27, 2017 21:02
@wilkinsona wilkinsona modified the milestones: 2.0.0.M4, 2.0.0.M5 Jul 28, 2017
@vpavic vpavic force-pushed the sessions-endpoint branch 4 times, most recently from d0e19a7 to ff4d0f6 Compare September 17, 2017 17:51
@vpavic
Copy link
Contributor Author

vpavic commented Sep 18, 2017

I've adapted this PR to the new Actuator endpoint infrastructure. Hands-on developer experience with the new stuff is just great!

Copy link
Member

@snicoll snicoll left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @vpavic!

I've made a few suggestions (which might lead us to add another extension point in the Endpoint API).

Also, I wonder if a sample wouldn't be in order for this? This can happen in a separate PR for sure.

@ReadOperation
public WebEndpointResponse<SessionsReport> sessionsForUsername(String username) {
if (username == null) {
return new WebEndpointResponse<>(HttpStatus.BAD_REQUEST.value());
Copy link
Member

@snicoll snicoll Sep 19, 2017

Choose a reason for hiding this comment

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

You can't use HttpStatus here as this class may not be available when running with Jersey. That's why that object is taking the raw int code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Web framework neutrality completely slipped my mind when using HttpStatus, I'll address that shortly.

Note that I used the same pattern in AuditEventsWebEndpointExtension that was introduced in #10322. Quick search also revealed another usage in HeapDumpWebEndpoint.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the feedback. I've created #10348


@Test
public void deleteSession() {
this.endpoint.deleteSession(session.getId());
Copy link
Member

Choose a reason for hiding this comment

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

That test does nothing. Verify that the repository was called with the right argument would be in order:

verify(this.repository).deleteById(session.getId());

@@ -106,6 +106,10 @@ The following technology agnostic endpoints are available:
|`mappings`
|Displays a collated list of all `@RequestMapping` paths.

|`sessions`
|Allows retrieving user's sessions from Spring Session backed session store, and deleting
them.
Copy link
Member

Choose a reason for hiding this comment

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

I'd add that to the first part of the sentence (see above for an example).

@snicoll snicoll added the status: waiting-for-feedback We need additional information before we can continue label Sep 19, 2017
@vpavic
Copy link
Contributor Author

vpavic commented Sep 19, 2017

Thanks for the review @snicoll, I've addressed your concerns.

Regarding the sample remark, would it be OK to reuse the existing spring-boot-sample-session-redis to showcase this functionality?

@snicoll
Copy link
Member

snicoll commented Sep 19, 2017

Yes. Perhaps we could first rename it and use something else. jdbc comes to mind even I know you guys don't want to promote it too much?

That sample looks outdated as it requires a redis server.

@vpavic
Copy link
Contributor Author

vpavic commented Sep 19, 2017

Can we use the similar approach to one in spring-boot-sample-cache and have multiple build profiles?

@snicoll
Copy link
Member

snicoll commented Sep 19, 2017

Maybe. Not sure that's an immediate goal but I am happy to review a PR

@vpavic
Copy link
Contributor Author

vpavic commented Sep 19, 2017

@snicoll I've opened #10351 to improve the sample.

@vpavic
Copy link
Contributor Author

vpavic commented Sep 20, 2017

I've updated the PR to adopt to changes from #10350 and enable the new endpoint in spring-boot-sample-session.

@snicoll snicoll removed the status: waiting-for-feedback We need additional information before we can continue label Sep 20, 2017
@snicoll snicoll self-assigned this Sep 20, 2017
@vpavic
Copy link
Contributor Author

vpavic commented Sep 20, 2017

Transient errors involving WebFluxEndpointIntegrationTests like the one below are quite often on Travis CI lately. It's been basically 50-50 with my PR updates over the past few days.

[INFO] Results:
[INFO] 
[ERROR] Errors: 
[ERROR]   WebFluxEndpointIntegrationTests>AbstractWebEndpointIntegrationTests.writeOperation:165->AbstractWebEndpointIntegrationTests.load:312->AbstractWebEndpointIntegrationTests.load:300->AbstractWebEndpointIntegrationTests.lambda$load$24:313->AbstractWebEndpointIntegrationTests.lambda$writeOperation$11:170 » IllegalState
[INFO] 
[ERROR] Tests run: 440, Failures: 0, Errors: 1, Skipped: 1

@wilkinsona
Copy link
Member

We see those on Bamboo too. @bclozel has been investigating. My suspicion is that it's a Linux-specific problem in Netty or Reactor Netty.

@vpavic
Copy link
Contributor Author

vpavic commented Sep 20, 2017

Thanks for the feedback. FWIW I didn't hit those problems on Ubuntu 17.04.

@snicoll snicoll closed this in 27f2222 Sep 20, 2017
snicoll added a commit that referenced this pull request Sep 20, 2017
* pr/8342:
  Polish "Add actuator endpoint for finding and deleting sessions"
  Add actuator endpoint for finding and deleting sessions
@snicoll snicoll mentioned this pull request Sep 20, 2017
1 task
@vpavic vpavic deleted the sessions-endpoint branch September 20, 2017 17:36
@manderson23
Copy link

@vpavic was there a reason that the endpoint doesn't have the option of returning the IDs of all sessions within the repository?

@wilkinsona
Copy link
Member

There's no support in Spring Session for getting the IDs of all sessions known to the repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants