Skip to content
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

Improve network configuration of catlets #280

Merged
merged 30 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
762c538
Start cleanup
ChristopherMann Nov 5, 2024
3a6ff4f
Improve tests
ChristopherMann Nov 5, 2024
b878b5f
Add todos
ChristopherMann Nov 11, 2024
dedf99e
* Fix incorrect cloud-init network config
ChristopherMann Nov 11, 2024
1d4bd47
Make MAC address mandatory in the database and fix tests
ChristopherMann Nov 11, 2024
d02508b
Cleanup ProviderIpManager
ChristopherMann Nov 12, 2024
2e8a9bc
Simplify network lookup
ChristopherMann Nov 12, 2024
8a3f3f3
Add tests
ChristopherMann Nov 13, 2024
6880b88
Cleanup MachineNetworkSettings and improve tests
ChristopherMann Nov 14, 2024
15cc265
Cleanup MAC addresses in tests
ChristopherMann Nov 14, 2024
4f0d530
Fix issues and cleanup
ChristopherMann Nov 14, 2024
3e4ef95
Cleanup tests
ChristopherMann Nov 14, 2024
7d17374
Cleanup
ChristopherMann Nov 14, 2024
2598154
Cleanup
ChristopherMann Nov 15, 2024
65729c6
Fix incorrect API spec
ChristopherMann Nov 20, 2024
7f26f9d
Improve externalnet switch configuration
ChristopherMann Nov 21, 2024
8d635b5
Fix incorrect network definitions in tests
ChristopherMann Nov 21, 2024
b1fc7a8
Move provider IP acquisition to NetworkConfigRealizer
ChristopherMann Nov 22, 2024
55b7d1a
Enable logging to XUnit test output
ChristopherMann Nov 22, 2024
5e1d87e
Add first tests
ChristopherMann Nov 22, 2024
df9dbe0
Fix management of NetNat
ChristopherMann Nov 25, 2024
a3c364d
Mark NetworkProvider as required
ChristopherMann Nov 25, 2024
683b199
Update unit tests
ChristopherMann Nov 25, 2024
fc13e26
Improve NetworkSyncService
ChristopherMann Nov 25, 2024
00027ba
Improve network service
ChristopherMann Nov 26, 2024
01f86b6
Cleanup
ChristopherMann Nov 26, 2024
9fbcbee
Tweak network sync logic
ChristopherMann Nov 26, 2024
ee2e091
Support in-place update of provider IP pools
ChristopherMann Nov 26, 2024
295bf7e
Cleanup
ChristopherMann Nov 26, 2024
90fb4c8
Configure missing floating IPs during network sync
ChristopherMann Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/apps/src/Eryph-zero/NetworkSyncServiceBridgeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,4 @@ public EitherAsync<Error, string[]> ValidateChanges(NetworkProvider[] networkPro
.GetInstance<INetworkSyncService>()
.ValidateChanges(networkProviders);
}

public EitherAsync<Error, Unit> RealizeProviderNetworks(CancellationToken cancellationToken)
{
return _controllerModule.Services.GetRequiredService<Container>()
.GetInstance<INetworkSyncService>()
.RealizeProviderNetworks(cancellationToken);
}
}
}
13 changes: 5 additions & 8 deletions src/core/src/Eryph.Core/INetworkSyncService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@
using LanguageExt;
using LanguageExt.Common;

namespace Eryph.Core
{
public interface INetworkSyncService
{
namespace Eryph.Core;

public EitherAsync<Error, Unit> SyncNetworks(CancellationToken cancellationToken);
public interface INetworkSyncService
{
public EitherAsync<Error, Unit> SyncNetworks(CancellationToken cancellationToken);

public EitherAsync<Error, string[]> ValidateChanges(NetworkProvider[] networkProviders);
EitherAsync<Error, Unit> RealizeProviderNetworks(CancellationToken cancellationToken);
}
public EitherAsync<Error, string[]> ValidateChanges(NetworkProvider[] networkProviders);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ namespace Eryph.Messages.Resources.Catlets.Commands;
public class UpdateCatletNetworksCommand: IHasResource, IHasProjectId
{
public Guid ProjectId { get; set; }

public CatletConfig Config { get; set; }

public Guid CatletId { get; set; }

public Resource Resource => new(ResourceType.Catlet, CatletId);
public Guid CatletMetadataId { get; set; }

}
public Resource Resource => new(ResourceType.Catlet, CatletId);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Eryph.Resources.Machines;
using System.Collections.Generic;

namespace Eryph.Resources.Machines;


public sealed class MachineNetworkSettings
Expand All @@ -8,11 +10,16 @@ public sealed class MachineNetworkSettings
public string NetworkName { get; set; }

public string NetworkProviderName { get; set; }

public string PortName { get; set; }

public string MacAddress { get; set; }
public string AddressesV4 { get; set; }
public string AddressesV6 { get; set; }

public IReadOnlyList<string> AddressesV4 { get; set; }

public IReadOnlyList<string> AddressesV6 { get; set; }

public string FloatingAddressV4 { get; set; }
public string FloatingAddressV6 { get; set; }

}
public string FloatingAddressV6 { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ private async Task<Either<Error, NetworkData>> GenerateNetworkData(TypedPsObject
var physicalNetworkSettings = new
{
type = "physical",
id = adapter.Value.Name,
name = adapter.Value.Name,
mac_address = macFormatted,
subnets = (Context.Config.Networks?.Filter(x=>x.AdapterName == adapter.Value.Name)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
.Annotation("MySql:CharSet", "utf8mb4"),
Environment = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
NetworkProvider = table.Column<string>(type: "longtext", nullable: true)
NetworkProvider = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
IpNetwork = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4")
Expand Down Expand Up @@ -461,7 +461,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ProviderName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
MacAddress = table.Column<string>(type: "varchar(255)", nullable: true)
MacAddress = table.Column<string>(type: "varchar(255)", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
AddressName = table.Column<string>(type: "longtext", nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.4")
.HasAnnotation("ProductVersion", "8.0.11")
.HasAnnotation("Relational:MaxIdentifierLength", 64);

MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
Expand Down Expand Up @@ -188,7 +188,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.ToTable("IpAssignment");

b.HasDiscriminator<string>("Discriminator").HasValue("IpAssignment");
b.HasDiscriminator().HasValue("IpAssignment");

b.UseTphMappingStrategy();
});
Expand Down Expand Up @@ -241,6 +241,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("varchar(21)");

b.Property<string>("MacAddress")
.IsRequired()
.HasColumnType("varchar(255)");

b.Property<string>("Name")
Expand All @@ -257,7 +258,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.ToTable("NetworkPorts");

b.HasDiscriminator<string>("Discriminator").HasValue("NetworkPort");
b.HasDiscriminator().HasValue("NetworkPort");

b.UseTphMappingStrategy();
});
Expand Down Expand Up @@ -544,7 +545,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.ToTable("Subnet");

b.HasDiscriminator<string>("Discriminator").HasValue("Subnet");
b.HasDiscriminator().HasValue("Subnet");

b.UseTphMappingStrategy();
});
Expand Down Expand Up @@ -778,6 +779,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("longtext");

b.Property<string>("NetworkProvider")
.IsRequired()
.HasColumnType("longtext");

b.ToTable("VirtualNetworks");
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
ResourceType = table.Column<int>(type: "INTEGER", nullable: false),
Name = table.Column<string>(type: "TEXT", nullable: false),
Environment = table.Column<string>(type: "TEXT", nullable: false),
NetworkProvider = table.Column<string>(type: "TEXT", nullable: true),
NetworkProvider = table.Column<string>(type: "TEXT", nullable: false),
IpNetwork = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
Expand Down Expand Up @@ -395,7 +395,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
Id = table.Column<Guid>(type: "TEXT", nullable: false),
ProviderName = table.Column<string>(type: "TEXT", nullable: true),
MacAddress = table.Column<string>(type: "TEXT", nullable: true),
MacAddress = table.Column<string>(type: "TEXT", nullable: false),
AddressName = table.Column<string>(type: "TEXT", nullable: true),
Name = table.Column<string>(type: "TEXT", nullable: false),
Discriminator = table.Column<string>(type: "TEXT", maxLength: 21, nullable: false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ partial class SqliteStateStoreContextModelSnapshot : ModelSnapshot
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "8.0.4");
modelBuilder.HasAnnotation("ProductVersion", "8.0.11");

modelBuilder.Entity("Eryph.StateDb.Model.CatletDrive", b =>
{
Expand Down Expand Up @@ -183,7 +183,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.ToTable("IpAssignment");

b.HasDiscriminator<string>("Discriminator").HasValue("IpAssignment");
b.HasDiscriminator().HasValue("IpAssignment");

b.UseTphMappingStrategy();
});
Expand Down Expand Up @@ -236,6 +236,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("TEXT");

b.Property<string>("MacAddress")
.IsRequired()
.HasColumnType("TEXT");

b.Property<string>("Name")
Expand All @@ -252,7 +253,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.ToTable("NetworkPorts");

b.HasDiscriminator<string>("Discriminator").HasValue("NetworkPort");
b.HasDiscriminator().HasValue("NetworkPort");

b.UseTphMappingStrategy();
});
Expand Down Expand Up @@ -539,7 +540,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.ToTable("Subnet");

b.HasDiscriminator<string>("Discriminator").HasValue("Subnet");
b.HasDiscriminator().HasValue("Subnet");

b.UseTphMappingStrategy();
});
Expand Down Expand Up @@ -773,6 +774,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("TEXT");

b.Property<string>("NetworkProvider")
.IsRequired()
.HasColumnType("TEXT");

b.ToTable("VirtualNetworks");
Expand Down
3 changes: 2 additions & 1 deletion src/data/src/Eryph.StateDb/Model/NetworkPort.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public abstract class NetworkPort
public string? ProviderName { get; set; }

public Guid Id { get; set; }
public string? MacAddress { get; set; }

public required string MacAddress { get; set; }

public string? AddressName { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion src/data/src/Eryph.StateDb/Model/VirtualNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public VirtualNetwork()
ResourceType = ResourceType.VirtualNetwork;
}

public string? NetworkProvider { get; set; }
public required string NetworkProvider { get; set; }

public string? IpNetwork { get; set; }

Expand Down
Loading