Repository navigation
Fixes ClearML server is down - and then hangfire crashes #65 --ECL - #66
Conversation
ddaspit
left a comment
There was a problem hiding this comment.
Reviewed 10 of 10 files at r1, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Enkidu93 and @johnml1135)
src/SIL.Machine.AspNetCore/Services/ClearMLAuthenticationService.cs line 28 at r1 (raw file):
public async Task<string> GetAuthToken(CancellationToken cancellationToken = default) { if (_authToken is "")
This could result in a race condition where the auth token that is returned is no longer valid. I think it would be better to move this back to the StartAsync method. The other option is to use an async lock.
src/SIL.Machine.AspNetCore/Services/ClearMLHealthCheck.cs line 29 at r1 (raw file):
catch (Exception e) { _logger.LogError(
One of the overloads of the LogError method allows you to directly pass the exception.
|
Previously, ddaspit (Damien Daspit) wrote…
The issue I was having here was that if it cannot fetch the token on startup (even with the retries), then it's left waiting an hour to try again, right? |
ddaspit
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Enkidu93 and @johnml1135)
src/SIL.Machine.AspNetCore/Services/ClearMLAuthenticationService.cs line 28 at r1 (raw file):
Previously, Enkidu93 (Eli C. Lowry) wrote…
The issue I was having here was that if it cannot fetch the token on startup (even with the retries), then it's left waiting an hour to try again, right?
Won't it fail after 3 attempts?
Enkidu93
left a comment
There was a problem hiding this comment.
Reviewable status: 9 of 10 files reviewed, 2 unresolved discussions (waiting on @ddaspit and @johnml1135)
src/SIL.Machine.AspNetCore/Services/ClearMLAuthenticationService.cs line 28 at r1 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
Won't it fail after 3 attempts?
It ought to. What happens if StartAsync throws an exception? In testing it out, I noticed that if I started everything up without internet connectivity and then turned then connected after a few minutes, it wouldn't fetch the token. I'll investigate.
src/SIL.Machine.AspNetCore/Services/ClearMLHealthCheck.cs line 29 at r1 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
One of the overloads of the
LogErrormethod allows you to directly pass the exception.
I'm not sure I'm seeing that overload. I found one that includes the exception. Let me know if this is what you wanted.
ddaspit
left a comment
There was a problem hiding this comment.
Reviewed 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @Enkidu93 and @johnml1135)
src/SIL.Machine.AspNetCore/Services/ClearMLAuthenticationService.cs line 28 at r1 (raw file):
Previously, Enkidu93 (Eli C. Lowry) wrote…
It ought to. What happens if StartAsync throws an exception? In testing it out, I noticed that if I started everything up without internet connectivity and then turned then connected after a few minutes, it wouldn't fetch the token. I'll investigate.
I'm guessing that the server will simply crash and not startup. That is probably not what we want. Let's add an async lock around the if statement. SmtTransferEngineState has an example of using a lock. You should also rename this method to GetAuthTokenAsync. This is the naming convention for async methods.
src/SIL.Machine.AspNetCore/Services/ClearMLHealthCheck.cs line 29 at r1 (raw file):
Previously, Enkidu93 (Eli C. Lowry) wrote…
I'm not sure I'm seeing that overload. I found one that includes the exception. Let me know if this is what you wanted.
This is the overload I am referring to.
|
Can you give a general explanation "this is what I am trying to do with refactoring this"? |
johnml1135
left a comment
There was a problem hiding this comment.
Reviewed 9 of 10 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Enkidu93)
ddaspit
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Enkidu93 and @johnml1135)
src/SIL.Machine.AspNetCore/Services/ClearMLAuthenticationService.cs line 66 at r2 (raw file):
Previously, johnml1135 (John Lambert) wrote…
Can you give a general explanation "this is what I am trying to do with refactoring this"?
Failed requests are now handled by Polly. See the new http error policy that was added in IMachineBuilderExtensions.cs.
|
Previously, ddaspit (Damien Daspit) wrote…
Yes, exactly. |
|
Previously, Enkidu93 (Eli C. Lowry) wrote…
Thanks. I'm fine with it. |
johnml1135
left a comment
There was a problem hiding this comment.
Dismissed @johnml1135 from a discussion.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @ddaspit and @Enkidu93)
Enkidu93
left a comment
There was a problem hiding this comment.
Reviewable status: 7 of 10 files reviewed, 3 unresolved discussions (waiting on @ddaspit and @johnml1135)
src/SIL.Machine.AspNetCore/Services/ClearMLAuthenticationService.cs line 28 at r1 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
I'm guessing that the server will simply crash and not startup. That is probably not what we want. Let's add an async lock around the
ifstatement.SmtTransferEngineStatehas an example of using a lock. You should also rename this method toGetAuthTokenAsync. This is the naming convention for async methods.
Done.
src/SIL.Machine.AspNetCore/Services/ClearMLHealthCheck.cs line 29 at r1 (raw file):
Previously, ddaspit (Damien Daspit) wrote…
This is the overload I am referring to.
I see. I got it now - it wasn't showing up in my IDE for some reason, but VScode has been sketchy lately I think because of some of the extensions. I do wonder if we really need to log this at all though since it's automatically logged given it's an unhealthy healthcheck response.
ddaspit
left a comment
There was a problem hiding this comment.
Reviewed 2 of 3 files at r3, 3 of 3 files at r4, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @Enkidu93)
src/SIL.Machine.AspNetCore/Services/ClearMLHealthCheck.cs line 29 at r1 (raw file):
Previously, Enkidu93 (Eli C. Lowry) wrote…
I see. I got it now - it wasn't showing up in my IDE for some reason, but VScode has been sketchy lately I think because of some of the extensions. I do wonder if we really need to log this at all though since it's automatically logged given it's an unhealthy healthcheck response.
I agree. We don't need this log.
tests/SIL.Machine.AspNetCore.Tests/Services/ClearMLServiceTests.cs line 31 at r4 (raw file):
); var authService = Substitute.For<IClearMLAuthenticationService>(); authService.GetAuthTokenAsync().Returns("accessToken");
This should return a task, i.e. Task.FromResult("accessToken").
ddaspit
left a comment
There was a problem hiding this comment.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @Enkidu93)
src/SIL.Machine.AspNetCore/Services/ClearMLAuthenticationService.cs line 40 at r4 (raw file):
} public override async Task StartAsync(CancellationToken cancellationToken)
You can remove this method.
src/SIL.Machine.AspNetCore/Services/ClearMLAuthenticationService.cs line 53 at r4 (raw file):
{ await Task.Delay(TimeSpan.FromSeconds(RefreshPeriod), stoppingToken); await AuthorizeAsync(stoppingToken);
You need to lock this line of code as well.
|
I think that's it, @ddaspit. |
ddaspit
left a comment
There was a problem hiding this comment.
Reviewed 3 of 3 files at r5, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @Enkidu93)
ddaspit
left a comment
There was a problem hiding this comment.
Dismissed @johnml1135 from a discussion.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @Enkidu93)
* Simplified logging --ECL * Added lock to token refresh; changed logging format --ECL * Changed name to ...Async --ECL * Fixed typo; removed unused var --ECL
166e46c to
8da55c4
Compare
johnml1135
left a comment
There was a problem hiding this comment.
Reviewed 2 of 2 files at r6, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @Enkidu93)
johnml1135
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! all files reviewed, all discussions resolved (waiting on @Enkidu93)
Rows 43 and 44 move from in progress to done. R1 on #546 is draft PR #577 (commit bbb81a0, shadow 0 violations); R3 ordered look-ahead is draft PR #576 (shadow 0 violations). Adds the round-doc section for both and the PanGloss port issues (sillsdev/PanGloss #65, #66). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Also relevant to #50.
ClearMLAuthenticationServicea bit to avoid issue where token wasn't properly populating immediatelyClearMLHealthCheckand to loggingThis change is