-
Notifications
You must be signed in to change notification settings - Fork 456
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
Update GetModuleLogs
method when tail + since + until
options are provided.
#4922
Update GetModuleLogs
method when tail + since + until
options are provided.
#4922
Conversation
tail
feature when since
and until
is applied.GetModuleLogs
method when tail + since + until
options are provided.
@@ -255,7 +255,7 @@ public static async Task<int> MainAsync(IConfiguration configuration) | |||
{ | |||
case "twin": | |||
bool enableStreams = configuration.GetValue(Constants.EnableStreams, false); | |||
int requestTimeoutSecs = configuration.GetValue(Constants.RequestTimeoutSecs, 600); | |||
int requestTimeoutSecs = configuration.GetValue(Constants.RequestTimeoutSecs, 30); |
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.
This is the part that I'm not super sure about if I should change the default request timeout from 600s to 30s for all the default. I don't really have a clean way to set a particular GetModuleLogs
DM's default request timeout to be 30s. Any suggestions?
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.
dm call has a timeout that can be set to ResponseTimeout in MethodRequest class. The default change is a big difference, it might cause issues with slower connections I assume.
return filter.Tail.Match<IReadOnlyList<ModuleLogMessage>>( | ||
t => | ||
{ | ||
return result.Skip(Math.Max(0, result.Count - t)).ToList().AsReadOnly(); |
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.
nit: this looks like Math.Abs can be used instead
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.
Unfortunately, I don't think Math.Abs()
will work here. More particularly in case t > result.Count
, Abs() would return the difference.. that's not what I want.
since.ForEach(s => logsUrl.AppendFormat($"&{LogsUrlSinceParameter}={Uri.EscapeUriString(s)}")); | ||
until.ForEach(u => logsUrl.AppendFormat($"&{LogsUrlUntilParameter}={Uri.EscapeUriString(u)}")); | ||
|
||
if (!(tail.HasValue && since.HasValue && until.HasValue)) |
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.
does tail.HasValue need to be checked here? it looks like only since and until have to be checked that are not set
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.
Yup, absolutely. This is where we about to send the docker API request via mgmt.sock.
Starting from this PR, the behavior is separated into 2 scenarios:
- When all 3 options (tail + since + until) are specified, only the
since + until
is passed down to mgmt.sock - When other combination of options (tail+since, tail+until, until+since) are specified, the options are then passthrough edgeAgent into mgmt.sock directly.
Once the log from (1) is returned, the result is tail
-ed after Akka parsing to enforce the tail.
@@ -255,7 +255,7 @@ public static async Task<int> MainAsync(IConfiguration configuration) | |||
{ | |||
case "twin": | |||
bool enableStreams = configuration.GetValue(Constants.EnableStreams, false); | |||
int requestTimeoutSecs = configuration.GetValue(Constants.RequestTimeoutSecs, 600); | |||
int requestTimeoutSecs = configuration.GetValue(Constants.RequestTimeoutSecs, 30); |
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.
dm call has a timeout that can be set to ResponseTimeout in MethodRequest class. The default change is a big difference, it might cause issues with slower connections I assume.
… provided. (Azure#4922) TL;DR - This PR chances the behavior of `GetModuleLogs` method to better facilitate the portal experience. Previous, when the `GetModuleLogs` is triggered from the azure portal with `tail + since + until`, all the 3 options are passed to Docker API management to fetch the log. The Docker API does the following: 1. Fetch the log of the module 2. Apply `tail` to the log 3. Apply the `since` and `until` to the log This results in an empty log most of the time which is not a desirable behavior. This PR changes the `GetModuleLogs` when the `tail + since + until` are specified together by doing the following: 1. Fetch Docker API with `since + until` log option 2. `tail` the returning log using LogProcessor (post-Akka). This allows a customer to get a tail of log within a given time frame. Note: This PR doesn't change the behavior of any other option combinations (i.e. `tail + since`, `tail`, `since`, etc). These combination are still managed by Docker API. Note2: I set RequestHandle timeout to be 30s instead of 600s by default
… provided. (Azure#4922) TL;DR - This PR chances the behavior of `GetModuleLogs` method to better facilitate the portal experience. Previous, when the `GetModuleLogs` is triggered from the azure portal with `tail + since + until`, all the 3 options are passed to Docker API management to fetch the log. The Docker API does the following: 1. Fetch the log of the module 2. Apply `tail` to the log 3. Apply the `since` and `until` to the log This results in an empty log most of the time which is not a desirable behavior. This PR changes the `GetModuleLogs` when the `tail + since + until` are specified together by doing the following: 1. Fetch Docker API with `since + until` log option 2. `tail` the returning log using LogProcessor (post-Akka). This allows a customer to get a tail of log within a given time frame. Note: This PR doesn't change the behavior of any other option combinations (i.e. `tail + since`, `tail`, `since`, etc). These combination are still managed by Docker API. Note2: I set RequestHandle timeout to be 30s instead of 600s by default
… provided (#4922) (#5171) TL;DR - This PR chances the behavior of `GetModuleLogs` method to better facilitate the portal experience. Previous, when the `GetModuleLogs` is triggered from the azure portal with `tail + since + until`, all the 3 options are passed to Docker API management to fetch the log. The Docker API does the following: 1. Fetch the log of the module 2. Apply `tail` to the log 3. Apply the `since` and `until` to the log This results in an empty log most of the time which is not a desirable behavior. This PR changes the `GetModuleLogs` when the `tail + since + until` are specified together by doing the following: 1. Fetch Docker API with `since + until` log option 2. `tail` the returning log using LogProcessor (post-Akka). This allows a customer to get a tail of log within a given time frame. Note: This PR doesn't change the behavior of any other option combinations (i.e. `tail + since`, `tail`, `since`, etc). These combination are still managed by Docker API. Note2: I set RequestHandle timeout to be 30s instead of 600s by default
TL;DR - This PR chances the behavior of
GetModuleLogs
method to better facilitate the portal experience.Previous, when the
GetModuleLogs
is triggered from the azure portal withtail + since + until
, all the 3 options are passed to Docker API management to fetch the log. The Docker API does the following:tail
to the logsince
anduntil
to the logThis results in an empty log most of the time which is not a desirable behavior.
This PR changes the
GetModuleLogs
when thetail + since + until
are specified together by doing the following:since + until
log optiontail
the returning log using LogProcessor (post-Akka).This allows a customer to get a tail of log within a given time frame.
Note: This PR doesn't change the behavior of any other option combinations (i.e.
tail + since
,tail
,since
, etc). These combination are still managed by Docker API.Note2: I set RequestHandle timeout to be 30s instead of 600s by default