Skip to content

Commit d90273a

Browse files
authored
Raise warning when volume mount root. (#413)
1 parent 2cdde6c commit d90273a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Runner.Worker/ContainerOperationProvider.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public async Task StartContainersAsync(IExecutionContext executionContext, objec
4747
condition: $"{PipelineTemplateConstants.Always}()",
4848
displayName: "Stop containers",
4949
data: data);
50-
50+
5151
executionContext.Debug($"Register post job cleanup for stopping/deleting containers.");
5252
executionContext.RegisterPostJobStep(nameof(StopContainersAsync), postJobStep);
5353

@@ -180,6 +180,11 @@ private async Task StartContainerAsync(IExecutionContext executionContext, Conta
180180
foreach (var volume in container.UserMountVolumes)
181181
{
182182
Trace.Info($"User provided volume: {volume.Value}");
183+
var mount = new MountVolume(volume.Value);
184+
if (string.Equals(mount.SourceVolumePath, "/", StringComparison.OrdinalIgnoreCase))
185+
{
186+
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.");
187+
}
183188
}
184189

185190
// Pull down docker image with retry up to 3 times

0 commit comments

Comments
 (0)