-
Notifications
You must be signed in to change notification settings - Fork 48
New endpoint to support migration of SI to SP #4918
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
Conversation
ramonsmits
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why this new endpoint it needed? Second, why is the filtering needed on "time sent"? This to be feels more sorting/seeking requirement but that could conflicting with SortInfo.
As each index uses a different type of ordering we need to "seek" using the ordered index attributes.
This is a new API and the sorting/seeking seems incorrect.
src/ServiceControl.Audit/Auditing/MessagesView/GetMessagesController.cs
Outdated
Show resolved
Hide resolved
src/ServiceControl.Audit/Auditing/MessagesView/GetMessages2Controller.cs
Show resolved
Hide resolved
src/ServiceControl.Audit.Persistence.RavenDB/Extensions/RavenQueryExtensions.cs
Outdated
Show resolved
Hide resolved
src/ServiceControl.Audit.Persistence.RavenDB/Extensions/RavenQueryExtensions.cs
Outdated
Show resolved
Hide resolved
src/ServiceControl.Audit.Persistence.RavenDB/Extensions/RavenQueryExtensions.cs
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| return combined; | ||
| return combined.Take(input.PagingInfo.PageSize).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fix right? Better to isolated that in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a fix to the existing behaviour - this is what's required by the new behaviour (getting first x results only)
That being said, for old versions of SP that still use the old API, this is going to result in even more broken behaviour where they can't even see large chunks of messages. It would make sense to have this behaviour conditional on the new API only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought of that @PhilBastian, but I don't understand why you think it would be worse in SI, we would only send the correct amount of records to it, how does that break it even further?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to toggle it only conditionally though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current behaviour on a 50 page size
- first page: SGa 1-50 + SGb 1-50
- second page: SGa 50-100 + SGb 50-100
this solution - first page: SGa 1-25 + SGb 1-25 (approx, depending on sort)
- second page: SGa 50-75 + SGb 50-75.
The user will never see 25-50 from either of the ScatterGather endpoints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is not the way it works.
We still return 50 results from all the instances, we then merge them all together and sort them and return the top 50.
859397d to
39657d1
Compare
Also fixed a bug where the results could return more than the page size
Changes time range from string to DateTimeRange object for message queries. This provides type safety and removes parsing logic and error handling from the data access layer. Also allows for optional To property on the DateTimeRange.
|
|
||
| public DateTimeRange(string from = null, string to = null) | ||
| { | ||
| if (from != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exception handling for invalid date string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exceptions in REST apis are hard, they don't really bubble to the UI,
So not sure what can we do better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that this is currently throwing an exception. At least ignore the value if it's not valid so that the client still receives data
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then they don't know they made a mistake, and they would get unexpected results.
This is a tricky topic that, unfortunately, our REST API does not handle well.
So, I am cautious about introducing a new pattern that is not well thought out.
|
|
||
| public DateTimeRange(string from = null, string to = null) | ||
| { | ||
| if (from != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exception handling for invalid date string?
| } | ||
|
|
||
| return combined; | ||
| return combined.Take(input.PagingInfo.PageSize).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is a fix to the existing behaviour - this is what's required by the new behaviour (getting first x results only)
That being said, for old versions of SP that still use the old API, this is going to result in even more broken behaviour where they can't even see large chunks of messages. It would make sense to have this behaviour conditional on the new API only
|
@ramonsmits can you unblock this PR, so we can merge it? |
| [ApiController] | ||
| [Route("api")] | ||
| public class GetMessages2Controller(IAuditDataStore dataStore) : ControllerBase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be possible to use ApiVersionAttribute by using the Microsoft.AspNetCore.Mvc.Versioning package?
This is just pseudo typing but it would then become something like:
| [ApiController] | |
| [Route("api")] | |
| public class GetMessages2Controller(IAuditDataStore dataStore) : ControllerBase | |
| [ApiController] | |
| [Route("api")] | |
| [ApiVersion("2.0")] | |
| public class GetMessages2Controller(IAuditDataStore dataStore) : ControllerBase |
This also allows for a more clean usage of the deprecated API later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ramonsmits I am not too concerned with api versioning given that we control the clients and this is not a publicly documented api so we can evolve it anyway we want as long our clients do not break.
So if you feel strongly about api versioning we can have that discussion separately from this work.
But otherwise can you unblock the PR so we can proceed with the port of SI to SP.
As part of the ongoing work to migrate SI to SP, we identified that paging in SI does not return the correct results once the user reaches page 2 or higher. The only correct page is page 1.
The TF working on this has evaluated whether paging is needed at all for the screens in SP and decided that, to provide accurate results, we are not migrating paging, given the issues.
This PR introduces a new endpoint that: