Skip to content

Commit 520c4a4

Browse files
authored
fix: enforce at most one IP per private network (#248)
1 parent 6ed04a1 commit 520c4a4

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

docs/loadbalancer-annotations.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ The possible formats are:
233233

234234
This is the annotation to statically set the private IPs of the loadbalancer.
235235
It is possible to provide a single IPAM IP ID, or a comma delimited list of IPAM IP IDs.
236+
Each IPAM IP ID will automatically be assigned to the appropriate Private Network attachment.
237+
Please note that there can be at most one IP address (IPv4 or IPv6) per Private Network.
236238
Changing the IPs will result in the re-creation of the Private Network attachments.
237239
The possible formats are:
238240
- `<ip-id>`: will attach a single IP to the LB.

scaleway/loadbalancers.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,10 @@ func (l *loadbalancers) attachPrivateNetworks(loadbalancer *scwlb.LB, service *v
921921

922922
// Reconcile: skip already-correct attachments, detach+reattach if IPs changed, attach if missing.
923923
for pnID, pnStatus := range privateNetworkAttachments {
924+
if len(pnStatus.desiredIPIDs) > 1 {
925+
return fmt.Errorf("at most one IP can be set per private network, please choose one between %s", pnStatus.desiredIPIDs)
926+
}
927+
924928
if pnStatus.attached {
925929
if len(pnStatus.desiredIPIDs) == 0 || slices.Equal(slices.Sorted(slices.Values(pnStatus.attachedIPIDs)), slices.Sorted(slices.Values(pnStatus.desiredIPIDs))) {
926930
continue

scaleway/loadbalancers_annotations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ const (
225225

226226
// serviceAnnotationLoadBalancerPrivateIPIDs is the annotation to statically set the private IPs of the loadbalancer.
227227
// It is possible to provide a single IPAM IP ID, or a comma delimited list of IPAM IP IDs.
228+
// Each IPAM IP ID will automatically be assigned to the appropriate Private Network attachment.
229+
// Please note that there can be at most one IP address (IPv4 or IPv6) per Private Network.
228230
// Changing the IPs will result in the re-creation of the Private Network attachments.
229231
// The possible formats are:
230232
// "<ip-id>": will attach a single IP to the LB.

0 commit comments

Comments
 (0)