Skip to content

Commit

Permalink
Validate inputs only for repo action, no warning for small delay. (#476)
Browse files Browse the repository at this point in the history
* validate inputs only for repo action, no warning for small delay.

* l0
  • Loading branch information
TingluoHuang authored May 12, 2020
1 parent abf59bd commit cd8e4dd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/Runner.Worker/ActionRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,15 @@ Action.Reference is Pipelines.RepositoryPathReference repoAction &&
}
}

foreach (var input in userInputs)
// Validate inputs only for actions with action.yml
if (Action.Reference.Type == Pipelines.ActionSourceType.Repository)
{
if (!validInputs.Contains(input))
foreach (var input in userInputs)
{
ExecutionContext.Warning($"Unexpected input '{input}', valid inputs are ['{string.Join("', '", validInputs)}']");
if (!validInputs.Contains(input))
{
ExecutionContext.Warning($"Unexpected input '{input}', valid inputs are ['{string.Join("', '", validInputs)}']");
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/Runner.Worker/ExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public interface IExecutionContext : IRunnerService
public sealed class ExecutionContext : RunnerService, IExecutionContext
{
private const int _maxIssueCount = 10;
private const int _throttlingDelayReportThreshold = 10 * 1000; // Don't report throttling with less than 10 seconds delay

private readonly TimelineRecord _record = new TimelineRecord();
private readonly Dictionary<Guid, TimelineRecord> _detailRecords = new Dictionary<Guid, TimelineRecord>();
Expand Down Expand Up @@ -335,7 +336,7 @@ public TaskResult Complete(TaskResult? result = null, string currentOperation =
}

// report total delay caused by server throttling.
if (_totalThrottlingDelayInMilliseconds > 0)
if (_totalThrottlingDelayInMilliseconds > _throttlingDelayReportThreshold)
{
this.Warning($"The job has experienced {TimeSpan.FromMilliseconds(_totalThrottlingDelayInMilliseconds).TotalSeconds} seconds total delay caused by server throttling.");
}
Expand Down Expand Up @@ -851,7 +852,8 @@ private void JobServerQueueThrottling_EventReceived(object sender, ThrottlingEve
{
Interlocked.Add(ref _totalThrottlingDelayInMilliseconds, Convert.ToInt64(data.Delay.TotalMilliseconds));

if (!_throttlingReported)
if (!_throttlingReported &&
_totalThrottlingDelayInMilliseconds > _throttlingDelayReportThreshold)
{
this.Warning(string.Format("The job is currently being throttled by the server. You may experience delays in console line output, job status reporting, and action log uploads."));

Expand Down
5 changes: 3 additions & 2 deletions src/Test/L0/Worker/ActionRunnerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,10 @@ public async void WarnInvalidInputs()
{
Name = "action",
Id = actionId,
Reference = new Pipelines.ContainerRegistryReference()
Reference = new Pipelines.RepositoryPathReference()
{
Image = "ubuntu:16.04"
Name = "actions/runner",
Ref = "v1"
},
Inputs = actionInputs
};
Expand Down

0 comments on commit cd8e4dd

Please sign in to comment.