Skip to content

Comments

Disable failing patron authentication (DB Migration Required)#980

Merged
RishiDiwanTT merged 5 commits intomainfrom
feature/ils-deadman-switch
Apr 17, 2023
Merged

Disable failing patron authentication (DB Migration Required)#980
RishiDiwanTT merged 5 commits intomainfrom
feature/ils-deadman-switch

Conversation

@RishiDiwanTT
Copy link
Contributor

@RishiDiwanTT RishiDiwanTT commented Apr 4, 2023

NOTE: This PR includes a database migration

Description

The LibraryAuthenticator skips authentication mechanisms based on their status

There is also a random sampling built into the disable logic
so the disabled integrations get sampled during the timeout window
Now instead of raising an error the authenticated_patron method will return a problem detail
This is so the error is written to the DB and not rolled back at the end of the request

Motivation and Context

Over the last several weeks, we have seen a number of patron authentication mechanisms fail (the remote ILS goes offline). Because these connections take some time to fail, they cause a backup of requests on the webserver, causing other library on the same CM not to be able to authenticate.

Notion

How Has This Been Tested?

Manually Set and unset the status while hitting an authenticated endpoint
New unit tests were written

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@RishiDiwanTT RishiDiwanTT requested a review from a team April 4, 2023 11:35
@RishiDiwanTT RishiDiwanTT self-assigned this Apr 4, 2023
Now instead of raising an error the authenticated_patron method will return a problem detail
This is so the error is written to the DB and not rolled back at the end of the request
Moved the externalintegrationerrors to the configuration model file
Added the migration for the externalintegrations model
There is also a random sampling built into the disable logic
so the disabled integrations get sampled during the timeout window
@RishiDiwanTT RishiDiwanTT force-pushed the feature/ils-deadman-switch branch from f5a70bb to 60a8b45 Compare April 4, 2023 11:42
@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Patch coverage: 95.89% and project coverage change: +0.01 🎉

Comparison is base (ae80281) 89.30% compared to head (17385a6) 89.31%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #980      +/-   ##
==========================================
+ Coverage   89.30%   89.31%   +0.01%     
==========================================
  Files         181      182       +1     
  Lines       32188    32249      +61     
  Branches     7190     7196       +6     
==========================================
+ Hits        28744    28803      +59     
- Misses       2283     2284       +1     
- Partials     1161     1162       +1     
Impacted Files Coverage Δ
core/model/__init__.py 86.03% <ø> (ø)
api/authenticator.py 91.04% <90.62%> (-0.01%) ⬇️
api/sip/client.py 96.34% <100.00%> (+<0.01%) ⬆️
core/jobs/update_integration_status.py 100.00% <100.00%> (ø)
core/model/configuration.py 94.08% <100.00%> (+0.15%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dbernstein dbernstein changed the title Disable failing patron authentication Disable failing patron authentication (DB Migration Required) Apr 4, 2023
Copy link
Contributor

@dbernstein dbernstein 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 to me. Nice work, @RishiDiwanTT. I appreciated the comments and also the thorough test coverage.


# 10 errors in the last 30 minutes
ERROR_WINDOW_DELTA = datetime.timedelta(minutes=30)
ERROR_WINDOW_COUNT = 10
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot to draw attention to these numbers, they were chosen because they are numbers, and for no other reason.
Should they be changed to something with more rationale behind them?
@dbernstein @jonathangreen

Copy link
Contributor

Choose a reason for hiding this comment

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

@RishiDiwanTT : I like numbers. Numbers are good. ;) It seems like as good a guess as any. I think 10 errors in 1/2 hour is a good place to start.

Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

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

This is looking pretty good!

I have a couple concerns, which are discussed in the comments below, and one minor general general suggestion, which is to end sentences in comments and docstrings with a period/full stop.

)
return record

def _is_provider_available(self, _db, provider):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you provide type hints here?

Comment on lines 148 to 150
class STATUS:
RED = 0
GREEN = 1
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to just make this an enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Laziness. This has been fixed. Not in me, in the code.

Copy link
Member

Choose a reason for hiding this comment

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

I was reading through my GitHub notifications this morning while I was eating breakfast, and this comment gave me a good laugh 🤣

@RishiDiwanTT RishiDiwanTT requested a review from tdilauro April 12, 2023 07:37
@RishiDiwanTT
Copy link
Contributor Author

@tdilauro I'll wait for your approval before merging.

@RishiDiwanTT RishiDiwanTT added the DB migration This PR contains a DB migration label Apr 13, 2023
Copy link
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

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

I think this is ready to go! 🏁

@jonathangreen jonathangreen added the feature New feature label Apr 14, 2023
@RishiDiwanTT RishiDiwanTT merged commit d2eb840 into main Apr 17, 2023
@RishiDiwanTT RishiDiwanTT deleted the feature/ils-deadman-switch branch April 17, 2023 05:10
jonathangreen added a commit that referenced this pull request May 15, 2023
jonathangreen added a commit that referenced this pull request May 15, 2023
We are seeing elevated errors due to the auth filtering happening in
migration intact.

We will do further work and reenable in a future PR.
jonathangreen added a commit that referenced this pull request May 16, 2023
We are seeing elevated errors due to the auth filtering happening in
migration intact.

We will do further work and reenable in a future PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DB migration This PR contains a DB migration feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants