Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

Provide error logs instead of exception spew on missing config #73

Merged
merged 2 commits into from
Jun 15, 2021
Merged

Provide error logs instead of exception spew on missing config #73

merged 2 commits into from
Jun 15, 2021

Conversation

itowlson
Copy link
Contributor

Fixes #63.

image

image

image

@itowlson itowlson marked this pull request as draft June 15, 2021 00:37
@itowlson
Copy link
Contributor Author

Ugh, missed a case. Please hold off a moment.

@itowlson itowlson marked this pull request as ready for review June 15, 2021 00:45
@itowlson
Copy link
Contributor Author

Ready for review now; sorry for the botch job.

@simongdavies
Copy link
Member

LGTM , Win32Exception on Linux 😆 .

@@ -39,19 +49,39 @@ public void Start(Channel c)
var port = c.PortID + Channel.EphemeralPortRange;

var wagiProgram = WagiBinaryPath();
var bindleUrl = Environment.GetEnvironmentVariable(ENV_BINDLE);

if (string.IsNullOrWhiteSpace(bindleUrl))
Copy link
Contributor

@bacongobbler bacongobbler Jun 15, 2021

Choose a reason for hiding this comment

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

Should this be checked in the constructor instead of Start? The user won't know BINDLE_SERVER_URL is set until the first time a job is scheduled. With the current DataSeeder fixtures, an error will be reported during startup. But for "production" cases where no apps are installed, it will not report until they've registered their first app and uploaded their first few revisions.

Copy link
Contributor

@bacongobbler bacongobbler Jun 15, 2021

Choose a reason for hiding this comment

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

Alternatively, we could look up this environment variable during Startup. We may want to support more options than an environment variable in the future (e.g. from appsettings.json, or from a feature flag).

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 can check in the constructor but are you thinking throw in that case? The trouble is that will give us spew again, albeit one-off and terminal spew. I'm not sure if there is a way to tell ASP.NET to simply exit without blowing chunks...?

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've added a check and critical log in the constructor, so you will now get an error log on startup even if there are no channels. I couldn't find a clean way to tell ASP.NET to terminate though.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yeah I was thinking about throwing, but if it means more spew... Eww.

_wagiProcessIds[c.Id] = process.Id;
}
}
catch (Win32Exception e) // yes, even on Linux
Copy link
Contributor

Choose a reason for hiding this comment

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

wat

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's for backward compatibility. This API dates from 2002 and the exception types were documented then; changing them just for six new versions and a different OS would break existing code. Microsoft does not fuck around when it comes to backcompat.

Copy link
Contributor

@bacongobbler bacongobbler left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -39,19 +49,39 @@ public void Start(Channel c)
var port = c.PortID + Channel.EphemeralPortRange;

var wagiProgram = WagiBinaryPath();
var bindleUrl = Environment.GetEnvironmentVariable(ENV_BINDLE);

if (string.IsNullOrWhiteSpace(bindleUrl))
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yeah I was thinking about throwing, but if it means more spew... Eww.

@itowlson itowlson merged commit cfb48af into deislabs:main Jun 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto start can give confusing error
3 participants