Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,25 @@ public async Task GetGslbsAsync_ReturnsArray()
// Arrange
var gslb1 = new V1Gslb { Metadata = new k8s.Models.V1ObjectMeta { Name = "gslb1" } };
var gslb2 = new V1Gslb { Metadata = new k8s.Models.V1ObjectMeta { Name = "gslb2" } };
var veccGslb1 = new V1VeccGslb { Metadata = new k8s.Models.V1ObjectMeta { Name = "veccgslb1" } };
var veccGslb2 = new V1VeccGslb { Metadata = new k8s.Models.V1ObjectMeta { Name = "veccgslb2" } };

_clientMock.Setup(x => x.ListAsync<V1Gslb>(null))
.ReturnsAsync(new List<V1Gslb> { gslb1, gslb2 });
_clientMock.Setup(x => x.ListAsync<V1VeccGslb>(null))
.ReturnsAsync(new List<V1VeccGslb> { veccGslb1, veccGslb2 });

var manager = new DefaultGslbManager(_loggerMock.Object, _clientMock.Object);

// Act
var result = await manager.GetGslbsAsync();

// Assert
Assert.Equal(2, result.Length);
Assert.Equal(4, result.Length);
Assert.Equal("gslb1", result[0].Metadata.Name);
Assert.Equal("gslb2", result[1].Metadata.Name);
Assert.Equal("veccgslb1", result[2].Metadata.Name);
Assert.Equal("veccgslb2", result[3].Metadata.Name);
}

[Fact]
Expand All @@ -43,6 +50,8 @@ public async Task GetGslbsAsync_EmptyList_ReturnsEmptyArray()
// Arrange
_clientMock.Setup(x => x.ListAsync<V1Gslb>(null))
.ReturnsAsync(new List<V1Gslb>());
_clientMock.Setup(x => x.ListAsync<V1VeccGslb>(null))
.ReturnsAsync(new List<V1VeccGslb>());

var manager = new DefaultGslbManager(_loggerMock.Object, _clientMock.Object);

Expand Down
30 changes: 29 additions & 1 deletion src/Cyclops.MultiCluster/Services/Default/DefaultGslbManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using KubeOps.KubernetesClient;
using Cyclops.MultiCluster.Models.K8sEntities;
using k8s.Models;
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using k8s.Models; appears unused in this file. Unused usings can produce build warnings (and can fail builds if warnings are treated as errors). Remove it unless something in this file explicitly needs types from k8s.Models.

Suggested change
using k8s.Models;

Copilot uses AI. Check for mistakes.

namespace Cyclops.MultiCluster.Services.Default
{
Expand All @@ -18,7 +19,34 @@ public async Task<V1Gslb[]> GetGslbsAsync()
{
_logger.LogInformation("Getting all gslb resources in the cluster");
var resources = await _client.ListAsync<V1Gslb>();
return resources.ToArray();
var veccGslbs = await _client.ListAsync<V1VeccGslb>();
var allResources = resources.ToList();
allResources.AddRange(veccGslbs.Select(v => ToV1Gslb(v)));
return allResources.ToArray();
}

public static V1Gslb ToV1Gslb(V1VeccGslb veccGslb)
{
return new V1Gslb
{
ApiVersion = veccGslb.ApiVersion,
Kind = "Gslb",
Comment on lines +32 to +33
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToV1Gslb is overriding ApiVersion and Kind with values that don’t match V1Gslb (it uses the legacy vecc API version and "Gslb" casing). This can cause the returned objects to be serialized/handled as the wrong CRD. Prefer leaving these unset so V1Gslb’s constructor defaults apply (or set them explicitly to the V1Gslb values).

Suggested change
ApiVersion = veccGslb.ApiVersion,
Kind = "Gslb",

Copilot uses AI. Check for mistakes.
Metadata = veccGslb.Metadata,
Spec = new V1Gslb.GslbSpec
{
Hostnames=veccGslb.Hostnames,
IPOverrides = veccGslb.IPOverrides,
ObjectReference = new V1Gslb.V1ObjectReference
{
Kind = veccGslb.ObjectReference.Kind == V1VeccGslb.V1ObjectReference.ReferenceType.Ingress
? V1Gslb.V1ObjectReference.ReferenceType.Ingress
: V1Gslb.V1ObjectReference.ReferenceType.Service,
Name = veccGslb.Name(),
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ObjectReference.Name is being set to veccGslb.Name() (the CRD object’s metadata.name) rather than the referenced ingress/service name. This will make downstream logic look up the wrong Service/Ingress. It should use veccGslb.ObjectReference.Name (matching the conversion logic already used in K8sChangedController).

Suggested change
Name = veccGslb.Name(),
Name = veccGslb.ObjectReference.Name,

Copilot uses AI. Check for mistakes.
},
Priority = veccGslb.Priority,
Weight = veccGslb.Weight
}
};
}
}
}
Loading