ArgumentNullException: Value cannot be null, for anonymous volume mounts#426
Merged
Conversation
| // try to resolve path inside container if the request path is part of the mount volume | ||
| #if OS_WINDOWS | ||
| if (Container.MountVolumes.Exists(x => path.StartsWith(x.SourceVolumePath, StringComparison.OrdinalIgnoreCase))) | ||
| if (Container.MountVolumes.Exists(x => x.SourceVolumePath != null && path.StartsWith(x.SourceVolumePath, StringComparison.OrdinalIgnoreCase))) |
Member
There was a problem hiding this comment.
will string.isnullorempty better?
Contributor
Author
There was a problem hiding this comment.
Probably yes. All strings would technically start with "" so if it were empty we would unnecessarily call Container.TranslateToContainerPath. SourcePath shouldnt be empty but its probably safer
TingluoHuang
approved these changes
Apr 14, 2020
TingluoHuang
pushed a commit
that referenced
this pull request
Apr 15, 2020
…nts (#426) * Dont check if path starts with null * Check SourceVolumePath not MountVolume obj * Prefer string.IsNullOrEmpty
AdamOlech
pushed a commit
to antmicro/runner
that referenced
this pull request
Jan 28, 2021
…nts (actions#426) * Dont check if path starts with null * Check SourceVolumePath not MountVolume obj * Prefer string.IsNullOrEmpty
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This was introduced due to #384
Given a workflow like:
we now properly mount the anonymous volume per https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontainervolumes
But anonymous volumes do not have a source path, so the SourceVolume is null and we cant resolve those paths from host to container. We get the following exception:
If the volume mount is coming from an anonymous volume the target script to run in the container can not possibly exist in that volume on the host, since these volumes are created on the fly, so theres no need to try to resolve the container path for that mount
I believe this was not an issue in the past due to changing when we expand and add the full MountVolumes objects to the ContainerInfo