-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added AzLinux-dnf support for RedisPackageInstallation #417
base: main
Are you sure you want to change the base?
Changes from all commits
0f3d501
b984341
8d36530
6629bc9
56fe32c
e97f648
869694b
75b1e5c
c38abb0
8d8831c
099b4d5
47ee79d
dee457f
e037e54
67bc6d4
321076f
331dd5f
8b3cc0c
001526d
2c035b6
67fe5e2
3be25f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ namespace VirtualClient.Dependencies | |
/// <summary> | ||
/// Provides functionality for installing latest version of Redis from Apt package manager on specific OS distribution version. | ||
/// </summary> | ||
[SupportedPlatforms("linux-arm64,linux-x64")] | ||
[SupportedPlatforms("linux-arm64,linux-x64", throwError: true)] | ||
public class RedisPackageInstallation : VirtualClientComponent | ||
{ | ||
private IFileSystem fileSystem; | ||
|
@@ -81,25 +81,20 @@ public string Version | |
/// <returns></returns> | ||
protected override async Task InitializeAsync(EventContext telemetryContext, CancellationToken cancellationToken) | ||
{ | ||
if (this.Platform != PlatformID.Unix) | ||
{ | ||
throw new WorkloadException($"Unsupported platform. The platform '{this.Platform}' is not supported.", ErrorReason.NotSupported); | ||
} | ||
LinuxDistributionInfo distroInfo = await this.systemManager.GetLinuxDistributionAsync(cancellationToken); | ||
this.Logger.LogMessage($"Print Distro Info:{distroInfo}", telemetryContext); | ||
this.Logger.LogMessage($"Print LinuxDistribution:{distroInfo.LinuxDistribution}", telemetryContext); | ||
|
||
if (this.Platform == PlatformID.Unix) | ||
switch (distroInfo.LinuxDistribution) | ||
{ | ||
LinuxDistributionInfo distroInfo = await this.systemManager.GetLinuxDistributionAsync(cancellationToken); | ||
|
||
switch (distroInfo.LinuxDistribution) | ||
{ | ||
case LinuxDistribution.Ubuntu: | ||
break; | ||
|
||
default: | ||
throw new WorkloadException( | ||
$"Redis installation is not supported by Virtual Client on the current Unix/Linux distro '{distroInfo.LinuxDistribution}'.", | ||
ErrorReason.LinuxDistributionNotSupported); | ||
} | ||
case LinuxDistribution.Ubuntu: | ||
break; | ||
case LinuxDistribution.AzLinux: | ||
break; | ||
default: | ||
throw new WorkloadException( | ||
$"Redis installation is not supported by Virtual Client on the current Unix/Linux distro '{distroInfo.LinuxDistribution}'.", | ||
ErrorReason.LinuxDistributionNotSupported); | ||
} | ||
|
||
this.PackagePath = this.PlatformSpecifics.GetPackagePath(this.PackageName); | ||
|
@@ -122,20 +117,22 @@ protected override async Task ExecuteAsync(EventContext telemetryContext, Cancel | |
case LinuxDistribution.Debian: | ||
await this.InstallOnUbuntuAsync(telemetryContext, cancellationToken); | ||
break; | ||
case LinuxDistribution.AzLinux: | ||
await this.InstallOnAzLinuxAsync(telemetryContext, cancellationToken); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
private async Task InstallOnUbuntuAsync(EventContext telemetryContext, CancellationToken cancellationToken) | ||
{ | ||
if (this.Version != string.Empty) | ||
if (!string.IsNullOrEmpty(this.Version)) | ||
{ | ||
this.installRedisCommand = $"install redis={this.Version} -y"; | ||
} | ||
else | ||
{ | ||
this.installRedisCommand = $"install redis -y"; | ||
|
||
} | ||
|
||
await this.ExecuteCommandAsync("apt", "update", Environment.CurrentDirectory, telemetryContext, cancellationToken) | ||
|
@@ -154,5 +151,35 @@ await this.systemManager.PackageManager.RegisterPackageAsync(redisPackage, cance | |
.ConfigureAwait(false); | ||
|
||
} | ||
|
||
private async Task InstallOnAzLinuxAsync(EventContext telemetryContext, CancellationToken cancellationToken) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this would also work on RHEL/Fedora distros? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but I haven't tested these cases. Should I also include RHEL/Fedora distros? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so, Redis is important enough that we need more than ubuntu and AzLinux |
||
{ | ||
if (!string.IsNullOrEmpty(this.Version)) | ||
{ | ||
this.installRedisCommand = $"install redis-{this.Version} -y"; | ||
} | ||
else | ||
{ | ||
this.installRedisCommand = $"install redis -y"; | ||
|
||
RakeshwarK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
await this.ExecuteCommandAsync("dnf", "update -y", Environment.CurrentDirectory, telemetryContext, cancellationToken) | ||
.ConfigureAwait(false); | ||
await this.ExecuteCommandAsync("dnf", this.installRedisCommand, Environment.CurrentDirectory, telemetryContext, cancellationToken) | ||
.ConfigureAwait(false); | ||
|
||
this.fileSystem.Directory.CreateDirectory(this.PackagePath); | ||
this.fileSystem.Directory.CreateDirectory(this.PlatformSpecifics.Combine(this.PackagePath, "src")); | ||
|
||
await this.ExecuteCommandAsync("cp", $"/usr/bin/redis-server {this.PlatformSpecifics.Combine(this.PackagePath, "src")}", Environment.CurrentDirectory, telemetryContext, cancellationToken) | ||
.ConfigureAwait(false); | ||
|
||
DependencyPath redisPackage = new DependencyPath(this.PackageName, this.PackagePath); | ||
await this.systemManager.PackageManager.RegisterPackageAsync(redisPackage, cancellationToken) | ||
.ConfigureAwait(false); | ||
|
||
} | ||
|
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,29 +55,18 @@ | |
} | ||
}, | ||
{ | ||
"Type": "WgetPackageInstallation", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you tested the changes in ubuntu? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There seems to be some issue with Redis, entering protected mode in ubuntu even without these changes, but the changes were running fine on AZ Linux. |
||
"Type": "RedisPackageInstallation", | ||
"Parameters": { | ||
"Scenario": "InstallRedisPackage", | ||
"PackageName": "redis", | ||
"PackageUri": "https://github.com/redis/redis/archive/refs/tags/6.2.1.tar.gz", | ||
"SubPath": "redis-6.2.1", | ||
"Notes": "Example path to package -> /packages/redis/redis-6.2.1" | ||
} | ||
}, | ||
{ | ||
"Type": "ExecuteCommand", | ||
"Parameters": { | ||
"Scenario": "CompileRedis", | ||
"SupportedPlatforms": "linux-x64,linux-arm64", | ||
"Command": "make", | ||
"WorkingDirectory": "{PackagePath:redis}" | ||
"Scenario": "InstallRedisPackageFromAptRepository", | ||
"PackageName": "redis" | ||
} | ||
}, | ||
{ | ||
"Type": "GitRepoClone", | ||
"Parameters": { | ||
"Scenario": "CloneMemtierRepo", | ||
"RepoUri": "https://github.com/RedisLabs/memtier_benchmark", | ||
"Commit": "1.4.0", | ||
"PackageName": "memtier" | ||
} | ||
}, | ||
|
@@ -86,7 +75,7 @@ | |
"Parameters": { | ||
"Scenario": "CompileMemtier", | ||
"SupportedPlatforms": "linux-x64,linux-arm64", | ||
"Command": "git checkout 1.4.0&&autoreconf -ivf&&bash -c './configure'&&make", | ||
"Command": "autoreconf -ivf&&bash -c './configure'&&make", | ||
"WorkingDirectory": "{PackagePath:memtier}" | ||
} | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tried tdnf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tdnf also works, is it preferred!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on AzLinux yes, on RHEL still use dnf. You don;t have to change it right now, you could add a comment that tdnf also works. I heard AzLinux eventually wants to move to tdnf entirely