blob: 00e4329d87bd761cf91321a91a8fe722e8fc79d3 [file] [log] [blame]
Tim Windelschmidta153f522025-02-21 03:00:20 +01001From 922898cb67ccedc6f0b67af9b398895d7fb55e56 Mon Sep 17 00:00:00 2001
Lorenz Brun6211e4d2023-11-14 19:09:40 +01002From: Tim Windelschmidt <tim@monogon.tech>
3Date: Sat, 9 Sep 2023 14:22:59 +0200
Tim Windelschmidta153f522025-02-21 03:00:20 +01004Subject: [PATCH] reserve metropolis system ports
Lorenz Brun6211e4d2023-11-14 19:09:40 +01005
6---
Tim Windelschmidta153f522025-02-21 03:00:20 +01007 .../core/service/portallocator/controller/repair.go | 12 ++++++++++++
8 1 file changed, 12 insertions(+)
Lorenz Brun6211e4d2023-11-14 19:09:40 +01009
Tim Windelschmidte95007b2023-07-17 19:05:30 +020010diff --git a/pkg/registry/core/service/portallocator/controller/repair.go b/pkg/registry/core/service/portallocator/controller/repair.go
Tim Windelschmidta153f522025-02-21 03:00:20 +010011index 0ec22c55a54..f890b9c133e 100644
Lorenz Brun6211e4d2023-11-14 19:09:40 +010012--- a/pkg/registry/core/service/portallocator/controller/repair.go
13+++ b/pkg/registry/core/service/portallocator/controller/repair.go
14@@ -22,6 +22,8 @@ import (
15 "sync"
Tim Windelschmidte95007b2023-07-17 19:05:30 +020016 "time"
Tim Windelschmidta153f522025-02-21 03:00:20 +010017
Jan Schär0f8ce4c2025-09-04 13:27:50 +020018+ "source.monogon.dev/metropolis/node/allocs"
Tim Windelschmidte95007b2023-07-17 19:05:30 +020019+
20 corev1 "k8s.io/api/core/v1"
21 "k8s.io/apimachinery/pkg/api/errors"
22 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Tim Windelschmidta153f522025-02-21 03:00:20 +010023@@ -148,6 +150,16 @@ func (c *Repair) doRunOnce() error {
Tim Windelschmidte95007b2023-07-17 19:05:30 +020024 if err != nil {
Lorenz Brun6211e4d2023-11-14 19:09:40 +010025 return fmt.Errorf("unable to create port allocator: %v", err)
Tim Windelschmidta153f522025-02-21 03:00:20 +010026 }
27+
28+ // pretend that metropolis system ports are in use by an actual service
Jan Schär0f8ce4c2025-09-04 13:27:50 +020029+ for _, p := range allocs.SystemPorts {
Tim Windelschmidta153f522025-02-21 03:00:20 +010030+ if err := rebuilt.Allocate(int(p)); err != nil {
31+ return fmt.Errorf("unable to allocate metropolis port: %v", err)
32+ }
33+ // remove it from the old set, so it doesn't appear leaked
34+ stored.Release(int(p))
35+ }
36+
37 // Check every Service's ports, and rebuild the state as we think it should be.
38 for i := range list.Items {
39 svc := &list.Items[i]
Lorenz Brun6211e4d2023-11-14 19:09:40 +010040--
Tim Windelschmidta153f522025-02-21 03:00:20 +0100412.47.1
Lorenz Brun6211e4d2023-11-14 19:09:40 +010042