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

Commit 0fb5663

Browse files
committed
Check that device exists in the facility or metro you're adding it to
Signed-off-by: Chris Privitere <[email protected]>
1 parent dfac059 commit 0fb5663

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

controllers/packetmachine_controller.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,16 @@ func (r *PacketMachineReconciler) reconcile(ctx context.Context, machineScope *s
412412
result = ctrl.Result{}
413413
}
414414

415+
// If Metro or Facility has changed in the spec, verify that the facility's metro is compatible with the requested spec change.
416+
417+
if machineScope.PacketMachine.Spec.Facility != "" && machineScope.PacketMachine.Spec.Facility != dev.Facility.Code {
418+
return ctrl.Result{}, fmt.Errorf("instance facility does not match machine facility %s: %q != %q", machineScope.Name(), machineScope.PacketMachine.Spec.Facility, dev.Facility.Code)
419+
}
420+
421+
if machineScope.PacketMachine.Spec.Metro != "" && machineScope.PacketMachine.Spec.Metro != dev.Metro.Code {
422+
return ctrl.Result{}, fmt.Errorf("instance metro does not match machine metro %s: %w", machineScope.Name(), err)
423+
}
424+
415425
return result, nil
416426
}
417427

0 commit comments

Comments
 (0)