-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add API liveness probes #35752
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
base: master
Are you sure you want to change the base?
Add API liveness probes #35752
Changes from all commits
5562ed3
3d3caeb
33398b9
28efcf7
351960e
b91fbca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
| // See the LICENCE file in the repository root for full licence text. | ||
|
|
||
| using System.Runtime.Serialization; | ||
| using Newtonsoft.Json; | ||
|
|
||
| namespace osu.Game.Online.API.Requests.Responses | ||
| { | ||
| public class LivenessProbeResponse | ||
| { | ||
| [JsonProperty("status")] | ||
| public LivenessStatus Status { get; set; } | ||
|
|
||
| [JsonProperty("reason")] | ||
| public string? Reason { get; set; } | ||
|
|
||
| public enum LivenessStatus | ||
| { | ||
| [EnumMember(Value = "up")] | ||
| Up, | ||
|
|
||
| [EnumMember(Value = "down")] | ||
| Down, | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
| // See the LICENCE file in the repository root for full licence text. | ||
|
|
||
| using osu.Framework.Allocation; | ||
| using osu.Framework.Graphics; | ||
| using osu.Framework.Graphics.Colour; | ||
| using osu.Framework.Graphics.Sprites; | ||
| using osu.Game.Graphics; | ||
|
|
||
| namespace osu.Game.Overlays.Notifications | ||
| { | ||
| public partial class OutageNotification : SimpleNotification | ||
| { | ||
| private readonly string message; | ||
|
|
||
| public OutageNotification(string message) | ||
| { | ||
| Text = this.message = message; | ||
|
|
||
| IsCritical = true; | ||
| } | ||
|
|
||
| [BackgroundDependencyLoader] | ||
| private void load() | ||
| { | ||
| Icon = FontAwesome.Solid.FireExtinguisher; | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was very difficult to resist using
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤣 i'd agree with using that, except the fire is in the wrong place. |
||
| IconContent.Colour = ColourInfo.GradientVertical(Colour4.Orange, Colour4.OrangeRed); | ||
|
|
||
| TextFlow.Clear(); | ||
| TextFlow.AddText("Online server outage in progress".ToUpperInvariant(), s => | ||
| { | ||
| s.Font = OsuFont.Style.Caption2.With(weight: FontWeight.Bold); | ||
| s.Colour = Colour4.Orange; | ||
| }); | ||
| TextFlow.AddParagraph(message, s => s.Font = OsuFont.Style.Caption1); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
| // See the LICENCE file in the repository root for full licence text. | ||
|
|
||
| using osu.Framework.Allocation; | ||
| using osu.Framework.Graphics.Sprites; | ||
| using osu.Game.Graphics; | ||
|
|
||
| namespace osu.Game.Overlays.Notifications | ||
| { | ||
| public partial class ScoreSubmissionFailureNotification : SimpleNotification | ||
| { | ||
| private readonly string heading; | ||
| private readonly string reason; | ||
|
|
||
| public ScoreSubmissionFailureNotification(string heading, string reason) | ||
| { | ||
| this.heading = heading; | ||
| this.reason = reason; | ||
|
|
||
| IsCritical = true; | ||
|
|
||
| Text = $"{heading}: {reason}"; | ||
| } | ||
|
|
||
| [BackgroundDependencyLoader] | ||
| private void load(OsuColour colours) | ||
| { | ||
| Icon = FontAwesome.Solid.Unlink; | ||
| IconContent.Colour = colours.RedDark; | ||
|
|
||
| TextFlow.Clear(); | ||
| TextFlow.AddText(heading.ToUpperInvariant(), s => | ||
| { | ||
| s.Font = OsuFont.Style.Caption2.With(weight: FontWeight.Bold); | ||
| s.Colour = colours.Red0; | ||
| }); | ||
| TextFlow.AddParagraph(reason, s => s.Font = OsuFont.Style.Caption1); | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,8 @@ | |
| using osu.Game.Online.Multiplayer; | ||
| using osu.Game.Online.Rooms; | ||
| using osu.Game.Online.Spectator; | ||
| using osu.Game.Overlays; | ||
| using osu.Game.Overlays.Notifications; | ||
| using osu.Game.Rulesets.Scoring; | ||
| using osu.Game.Scoring; | ||
| using osu.Game.Screens.Ranking; | ||
|
|
@@ -48,6 +50,10 @@ public abstract partial class SubmittingPlayer : Player | |
| [CanBeNull] | ||
| private UserStatisticsWatcher userStatisticsWatcher { get; set; } | ||
|
|
||
| [Resolved(canBeNull: true)] | ||
| [CanBeNull] | ||
| private INotificationOverlay notifications { get; set; } | ||
|
|
||
| private readonly object scoreSubmissionLock = new object(); | ||
| private TaskCompletionSource<bool> scoreSubmissionSource; | ||
|
|
||
|
|
@@ -99,9 +105,9 @@ private bool handleTokenRetrieval() | |
| return false; | ||
| } | ||
|
|
||
| if (!api.IsLoggedIn) | ||
| if (!api.IsLoggedIn || api.State.Value == APIState.Failing) | ||
| { | ||
| handleTokenFailure(new InvalidOperationException("API is not online.")); | ||
| handleTokenFailure(new InvalidOperationException("Online functionality is not available."), displayNotification: api.State.Value == APIState.Failing); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd probably also do diff --git a/osu.Game/Screens/Play/SubmittingPlayer.cs b/osu.Game/Screens/Play/SubmittingPlayer.cs
index 78e16c0f4b..62a2fc6f56 100644
--- a/osu.Game/Screens/Play/SubmittingPlayer.cs
+++ b/osu.Game/Screens/Play/SubmittingPlayer.cs
@@ -162,7 +162,7 @@ void handleTokenFailure(Exception exception, bool displayNotification = false)
break;
default:
- Logger.Log($"{whatWillHappen} {exception.Message}", level: LogLevel.Important);
+ Logger.Log($"{exception.Message}\n\n{whatWillHappen}", level: LogLevel.Important);
break;
}
}
to make the notification read more correctly. Bonus points if we have a custom styled notification for this. I was also thinking, rather than a notification for this state, it might be nice to put informational text in the place where the epilepsy warning etc. is.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
See what you think of 28efcf7.
Not trivially doable because those are in |
||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -138,31 +144,31 @@ void handleTokenFailure(Exception exception, bool displayNotification = false) | |
| if (displayNotification || shouldExit) | ||
| { | ||
| string whatWillHappen = shouldExit | ||
| ? "Play in this state is not permitted." | ||
| : "Your score will not be submitted."; | ||
| ? "Cannot start play" | ||
| : "Score will not be submitted"; | ||
|
|
||
| if (string.IsNullOrEmpty(exception.Message)) | ||
| Logger.Error(exception, $"Failed to retrieve a score submission token.\n\n{whatWillHappen}"); | ||
| notifications?.Post(new ScoreSubmissionFailureNotification(whatWillHappen, "Failed to retrieve a score submission token.")); | ||
| else | ||
| { | ||
| switch (exception.Message) | ||
| { | ||
| case @"missing token header": | ||
| case @"invalid client hash": | ||
| case @"invalid verification hash": | ||
| Logger.Log($"Please ensure that you are using the latest version of the official game releases.\n\n{whatWillHappen}", level: LogLevel.Important); | ||
| notifications?.Post(new ScoreSubmissionFailureNotification(whatWillHappen, "Please ensure that you are using the latest version of the official game releases.")); | ||
| break; | ||
|
|
||
| case @"invalid or missing beatmap_hash": | ||
| Logger.Log($"This beatmap does not match the online version. Please update or redownload it.\n\n{whatWillHappen}", level: LogLevel.Important); | ||
| notifications?.Post(new ScoreSubmissionFailureNotification(whatWillHappen, "This beatmap does not match the online version. Please update or redownload it.")); | ||
| break; | ||
|
|
||
| case @"expired token": | ||
| Logger.Log($"Your system clock is set incorrectly. Please check your system time, date and timezone.\n\n{whatWillHappen}", level: LogLevel.Important); | ||
| notifications?.Post(new ScoreSubmissionFailureNotification(whatWillHappen, "Your system clock is set incorrectly. Please check your system time, date and timezone.")); | ||
| break; | ||
|
|
||
| default: | ||
| Logger.Log($"{whatWillHappen} {exception.Message}", level: LogLevel.Important); | ||
| notifications?.Post(new ScoreSubmissionFailureNotification(whatWillHappen, exception.Message)); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
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.
Disputable, but seemed like a good idea.