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

editoast: log stdcm requests #9873

Merged
merged 1 commit into from
Dec 5, 2024
Merged

editoast: log stdcm requests #9873

merged 1 commit into from
Dec 5, 2024

Conversation

hamz2a
Copy link
Contributor

@hamz2a hamz2a commented Nov 27, 2024

Part of #9724

  • Create a PostgreSQL table with columns: trace_id, request, response, created and user_id.
  • Store the data of LMR requests in this table.

@hamz2a hamz2a requested a review from a team as a code owner November 27, 2024 13:57
@hamz2a hamz2a marked this pull request as draft November 27, 2024 13:57
@github-actions github-actions bot added the area:editoast Work on Editoast Service label Nov 27, 2024
@codecov-commenter
Copy link

codecov-commenter commented Nov 27, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 84.00000% with 12 lines in your changes missing coverage. Please review.

Project coverage is 79.86%. Comparing base (255cf0a) to head (63990f2).
Report is 10 commits behind head on dev.

Files with missing lines Patch % Lines
editoast/src/core/stdcm.rs 16.66% 5 Missing ⚠️
editoast/src/views/timetable/stdcm.rs 87.09% 4 Missing ⚠️
editoast/editoast_models/src/tables.rs 93.33% 1 Missing ⚠️
editoast/src/core/conflict_detection.rs 0.00% 1 Missing ⚠️
editoast/src/models/stdcm_log.rs 95.23% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff            @@
##              dev    #9873    +/-   ##
========================================
  Coverage   79.85%   79.86%            
========================================
  Files        1048     1048            
  Lines      105086   105214   +128     
  Branches      756      756            
========================================
+ Hits        83921    84033   +112     
- Misses      21124    21140    +16     
  Partials       41       41            
Flag Coverage Δ
editoast 73.40% <84.00%> (+<0.01%) ⬆️
front 89.35% <ø> (+0.01%) ⬆️
gateway 2.18% <ø> (ø)
osrdyne 3.28% <ø> (ø)
railjson_generator 87.49% <ø> (ø)
tests 87.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch 3 times, most recently from cd61269 to aaf0574 Compare November 27, 2024 16:37
@hamz2a hamz2a marked this pull request as ready for review November 27, 2024 16:38
@hamz2a hamz2a marked this pull request as draft November 27, 2024 16:38
@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch from aaf0574 to a1541d9 Compare November 27, 2024 16:49
@hamz2a hamz2a marked this pull request as ready for review November 27, 2024 16:50
@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch from a1541d9 to e2d76fe Compare November 28, 2024 09:48
Copy link
Contributor

@leovalais leovalais left a comment

Choose a reason for hiding this comment

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

Cursory review, I'll test later if this isn't merged beforehand.

I know the list of fields has been discussed in the refinement, but I can think of at least two other columns that could prove useful IMO:

  • the date time of the request, allowing us to sort requests by recentness
  • the user that performed the request

With these we'd be easily able to provide a feature like "replay my most recent request". Wdyt? (ping @ everyone)

editoast/src/models/stdcm_log.rs Outdated Show resolved Hide resolved
editoast/src/views/timetable/stdcm.rs Outdated Show resolved Hide resolved
editoast/src/views/timetable/stdcm.rs Outdated Show resolved Hide resolved
editoast/src/views/timetable/stdcm.rs Outdated Show resolved Hide resolved
editoast/src/views/timetable/stdcm.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@woshilapin woshilapin left a comment

Choose a reason for hiding this comment

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

Were you able to test if the trace_id in the entrypoint of editoast is the same than the one you log? I'm wondering if it just generates a new one or not 🤷

editoast/src/views/timetable/stdcm.rs Outdated Show resolved Hide resolved
@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch 2 times, most recently from 9ba80cd to 7d91e9d Compare November 28, 2024 15:11
@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch 4 times, most recently from 3dd6355 to ea2b2c7 Compare November 29, 2024 13:28
Copy link
Contributor

@leovalais leovalais 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 changes! A few more comments below:

editoast/src/models/stdcm_log.rs Outdated Show resolved Hide resolved
editoast/src/views/timetable/stdcm.rs Outdated Show resolved Hide resolved
editoast/src/views/timetable/stdcm.rs Outdated Show resolved Hide resolved
editoast/src/views/timetable/stdcm.rs Outdated Show resolved Hide resolved
editoast/src/views/timetable/stdcm.rs Outdated Show resolved Hide resolved
@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch 2 times, most recently from b396089 to cf11718 Compare December 2, 2024 17:12
@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch from cf11718 to 5a83e23 Compare December 3, 2024 10:43
@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch 3 times, most recently from 159b927 to e37b50e Compare December 4, 2024 10:08
@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch 2 times, most recently from e9e81aa to 2e01cb6 Compare December 4, 2024 15:40
Copy link
Contributor

@leovalais leovalais left a comment

Choose a reason for hiding this comment

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

Just tested. Works great when authenticated, but the log entry isn't created when authorization is disabled. Probably a unique nulls missing somewhere.

To keep the repo history clean, I suggest merging @woshilapin PR into yours instead of cherry-picking, and he should probably be Co-Author as well.

@hamz2a
Copy link
Contributor Author

hamz2a commented Dec 4, 2024

Just tested. Works great when authenticated, but the log entry isn't created when authorization is disabled. Probably a unique nulls missing somewhere.

If authentication is disabled, the superuser profile is granted to everyone:

if disable_authorization {
    return Ok(Authentication::Authenticated(Authorizer::new_superuser(
        PgAuthDriver::<BuiltinRole>::new(db_pool),
    )));
}

In the code, we assign user_id = -1:

pub fn new_superuser(storage_driver: S) -> Self {
    Self {
        user: UserInfo {
            identity: "superuser".to_string(),
            name: "Super User".to_string(),
        },
        user_id: -1,
        user_roles: HashSet::from([S::BuiltinRole::superuser()]),
        storage: storage_driver,
    }
}

This leads to an issue when trying to store the log, because it results in a foreign key error.
@leovalais

Copy link
Contributor

@woshilapin woshilapin 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 integrating #9947 into your PR. I'll close #9947.

@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch from 2e01cb6 to be5fcf9 Compare December 5, 2024 09:29
@hamz2a hamz2a requested a review from leovalais December 5, 2024 09:30
@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch from be5fcf9 to 6a99e1f Compare December 5, 2024 15:50
Copy link
Contributor

@leovalais leovalais left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @hamz2a @woshilapin for the changes!

editoast/src/models/stdcm_log.rs Outdated Show resolved Hide resolved
Co-authored-by: Jean SIMARD <[email protected]>
Signed-off-by: hamz2a <[email protected]>
@hamz2a hamz2a force-pushed the hai/editoast-log-stdcm-requests branch from 6a99e1f to 63990f2 Compare December 5, 2024 16:39
@hamz2a hamz2a added this pull request to the merge queue Dec 5, 2024
Merged via the queue into dev with commit 50a599e Dec 5, 2024
27 checks passed
@hamz2a hamz2a deleted the hai/editoast-log-stdcm-requests branch December 5, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:editoast Work on Editoast Service
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants