Skip to content

Commit

Permalink
Raise warning when volume mount root. (#413)
Browse files Browse the repository at this point in the history
  • Loading branch information
TingluoHuang authored Apr 8, 2020
1 parent 2cdde6c commit d90273a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Runner.Worker/ContainerOperationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public async Task StartContainersAsync(IExecutionContext executionContext, objec
condition: $"{PipelineTemplateConstants.Always}()",
displayName: "Stop containers",
data: data);

executionContext.Debug($"Register post job cleanup for stopping/deleting containers.");
executionContext.RegisterPostJobStep(nameof(StopContainersAsync), postJobStep);

Expand Down Expand Up @@ -180,6 +180,11 @@ private async Task StartContainerAsync(IExecutionContext executionContext, Conta
foreach (var volume in container.UserMountVolumes)
{
Trace.Info($"User provided volume: {volume.Value}");
var mount = new MountVolume(volume.Value);
if (string.Equals(mount.SourceVolumePath, "/", StringComparison.OrdinalIgnoreCase))
{
executionContext.Warning($"Volume mount {volume.Value} is going to mount '/' into the container which may cause file ownership change in the entire file system and cause Actions Runner to lose permission to access the disk.");
}
}

// Pull down docker image with retry up to 3 times
Expand Down

0 comments on commit d90273a

Please sign in to comment.