-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support 'rzfs:host:port/template-id/subpath' engine spec (#106)
- Loading branch information
Showing
11 changed files
with
219 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
41 changes: 41 additions & 0 deletions
41
UET/Redpoint.Uet.Workspace/Descriptors/RemoteZfsWorkspaceDescriptor.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
namespace Redpoint.Uet.Workspace.Descriptors | ||
{ | ||
using System.Globalization; | ||
|
||
public record class RemoteZfsWorkspaceDescriptor : IWorkspaceDescriptor | ||
{ | ||
public required string Hostname { get; set; } | ||
|
||
public required int Port { get; set; } | ||
|
||
public required string TemplateId { get; set; } | ||
|
||
public required string Subpath { get; set; } | ||
|
||
public static RemoteZfsWorkspaceDescriptor Parse(string spec) | ||
{ | ||
ArgumentNullException.ThrowIfNull(spec); | ||
|
||
var components = spec.Replace('\\', '/').Split('/', 3); | ||
if (components.Length < 2) | ||
{ | ||
throw new ArgumentException("Invalid remote ZFS spec; expected 'host:port/template-id/optional-subpath'.", nameof(spec)); | ||
} | ||
|
||
var hostPort = components[0].Split(':'); | ||
var templateId = components[1]; | ||
var subpath = components.Length > 2 ? components[2] : string.Empty; | ||
|
||
var host = hostPort[0]; | ||
var port = hostPort.Length > 1 ? int.Parse(hostPort[1], CultureInfo.InvariantCulture) : 9000; | ||
|
||
return new RemoteZfsWorkspaceDescriptor | ||
{ | ||
Hostname = host, | ||
Port = port, | ||
TemplateId = templateId, | ||
Subpath = subpath, | ||
}; | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace Redpoint.Uet.Workspace.Instance | ||
{ | ||
using Grpc.Core; | ||
using Redpoint.Reservation; | ||
using Redpoint.Uet.Workspace.RemoteZfs; | ||
using System.Threading.Tasks; | ||
|
||
internal class RemoteZfsWorkspace : IWorkspace | ||
{ | ||
private readonly AsyncServerStreamingCall<AcquireWorkspaceResponse> _connection; | ||
private readonly IReservation _physicalReservation; | ||
|
||
public RemoteZfsWorkspace( | ||
AsyncServerStreamingCall<AcquireWorkspaceResponse> connection, | ||
IReservation physicalReservation) | ||
{ | ||
_connection = connection; | ||
_physicalReservation = physicalReservation; | ||
} | ||
|
||
public string Path => System.IO.Path.Combine(_physicalReservation.ReservedPath, "S"); | ||
|
||
public async ValueTask DisposeAsync() | ||
{ | ||
if (Directory.Exists(System.IO.Path.Combine(_physicalReservation.ReservedPath, "S"))) | ||
{ | ||
Directory.Delete(System.IO.Path.Combine(_physicalReservation.ReservedPath, "S")); | ||
} | ||
|
||
await _physicalReservation.DisposeAsync().ConfigureAwait(false); | ||
|
||
_connection.Dispose(); | ||
} | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,5 +19,7 @@ internal enum EngineSpecType | |
SelfEngineByBuildConfig, | ||
|
||
SESNetworkShare, | ||
|
||
RemoteZfs, | ||
} | ||
} |
This file contains 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