Skip to content
This repository was archived by the owner on Aug 12, 2025. It is now read-only.

Commit cf963ad

Browse files
committed
Add code to handle both metro and facility during IP creation
Signed-off-by: Chris Privitere <[email protected]>
1 parent ea7accd commit cf963ad

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

controllers/packetcluster_controller.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,19 @@ func (r *PacketClusterReconciler) reconcileNormal(ctx context.Context, clusterSc
116116
ipReserv, err := r.PacketClient.GetIPByClusterIdentifier(clusterScope.Namespace(), clusterScope.Name(), packetCluster.Spec.ProjectID)
117117
switch {
118118
case errors.Is(err, packet.ErrControlPlanEndpointNotFound):
119+
// Parse metro and facility from the cluster spec
120+
var metro, facility string
121+
122+
facility = packetCluster.Spec.Facility
123+
metro = packetCluster.Spec.Metro
124+
125+
// If both specified, metro takes precedence over facility
126+
if metro != "" {
127+
facility = ""
128+
}
129+
119130
// There is not an ElasticIP with the right tags, at this point we can create one
120-
ip, err := r.PacketClient.CreateIP(clusterScope.Namespace(), clusterScope.Name(), packetCluster.Spec.ProjectID, packetCluster.Spec.Facility, packetCluster.Spec.Metro)
131+
ip, err := r.PacketClient.CreateIP(clusterScope.Namespace(), clusterScope.Name(), packetCluster.Spec.ProjectID, facility, metro)
121132
if err != nil {
122133
log.Error(err, "error reserving an ip")
123134
return ctrl.Result{}, err

0 commit comments

Comments
 (0)