Skip to content

Commit 0d981b4

Browse files
committed
Add TFTP provisioning support
1 parent bdedecd commit 0d981b4

13 files changed

Lines changed: 514 additions & 17 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
app.kubernetes.io/managed-by: {{ .Release.Service }}
6+
app.kubernetes.io/name: {{ include "network-operator.name" . }}
7+
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
8+
app.kubernetes.io/instance: {{ .Release.Name }}
9+
control-plane: controller-manager
10+
name: {{ include "network-operator.resourceName" (dict "suffix" "controller-manager-tftp-service" "context" $) }}
11+
namespace: {{ .Release.Namespace }}
12+
spec:
13+
ports:
14+
- name: tftp
15+
port: 1069
16+
protocol: UDP
17+
targetPort: 1069
18+
selector:
19+
app.kubernetes.io/name: {{ include "network-operator.name" . }}
20+
control-plane: controller-manager
21+
type: ClusterIP

‎charts/network-operator/templates/manager/manager.yaml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ spec:
3535
{{- with .Values.manager.nodeSelector }}
3636
nodeSelector: {{ toYaml . | nindent 10 }}
3737
{{- end }}
38+
{{- with .Values.manager.imagePullSecrets }}
39+
imagePullSecrets: {{ toYaml . | nindent 8 }}
40+
{{- end }}
3841
containers:
3942
- args:
4043
{{- if .Values.metrics.enable }}
@@ -54,6 +57,9 @@ spec:
5457
- /manager
5558
image: "{{ .Values.manager.image.repository }}:{{ .Values.manager.image.tag }}"
5659
imagePullPolicy: {{ .Values.manager.image.pullPolicy }}
60+
{{- with .Values.manager.env }}
61+
env: {{ toYaml . | nindent 10 }}
62+
{{- end }}
5763
livenessProbe:
5864
httpGet:
5965
path: /healthz

‎charts/network-operator/values.yaml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ manager:
3434
podSecurityContext:
3535
runAsNonRoot: true
3636
seccompProfile:
37-
type: RuntimeDefault
37+
type: RuntimeDefault
3838

3939
## Container-level security settings
4040
##
4141
securityContext:
4242
allowPrivilegeEscalation: false
4343
capabilities:
44-
drop:
45-
- ALL
44+
drop:
45+
- ALL
4646

4747
## Resource limits and requests
4848
##
4949
resources:
5050
limits:
51-
memory: 512Mi
51+
memory: 512Mi
5252
requests:
53-
cpu: 150m
54-
memory: 256Mi
53+
cpu: 150m
54+
memory: 256Mi
5555

5656
## Manager pod's affinity
5757
##

‎cmd/main.go‎

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ import (
1717
_ "k8s.io/client-go/plugin/pkg/client/auth"
1818

1919
// Set runtime concurrency to match CPU limit imposed by Kubernetes
20-
_ "go.uber.org/automaxprocs"
21-
2220
"github.com/sapcc/go-api-declarations/bininfo"
21+
_ "go.uber.org/automaxprocs"
2322
"go.uber.org/zap/zapcore"
2423
coordinationv1 "k8s.io/api/coordination/v1"
2524
"k8s.io/apimachinery/pkg/runtime"
@@ -36,20 +35,21 @@ import (
3635
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3736
"sigs.k8s.io/controller-runtime/pkg/webhook"
3837

39-
// Import all supported provider implementations.
40-
_ "github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr"
41-
_ "github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos"
42-
_ "github.com/ironcore-dev/network-operator/internal/provider/openconfig"
43-
4438
nxv1alpha1 "github.com/ironcore-dev/network-operator/api/cisco/nx/v1alpha1"
4539
"github.com/ironcore-dev/network-operator/api/core/v1alpha1"
4640
nxcontroller "github.com/ironcore-dev/network-operator/internal/controller/cisco/nx"
4741
corecontroller "github.com/ironcore-dev/network-operator/internal/controller/core"
4842
"github.com/ironcore-dev/network-operator/internal/provider"
4943
"github.com/ironcore-dev/network-operator/internal/provisioning"
5044
"github.com/ironcore-dev/network-operator/internal/resourcelock"
45+
tftpserver "github.com/ironcore-dev/network-operator/internal/tftp"
5146
webhooknxv1alpha1 "github.com/ironcore-dev/network-operator/internal/webhook/cisco/nx/v1alpha1"
5247
webhookv1alpha1 "github.com/ironcore-dev/network-operator/internal/webhook/core/v1alpha1"
48+
49+
// Import all supported provider implementations.
50+
_ "github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr"
51+
_ "github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos"
52+
_ "github.com/ironcore-dev/network-operator/internal/provider/openconfig"
5353
// +kubebuilder:scaffold:imports
5454
)
5555

@@ -81,6 +81,8 @@ func main() {
8181
var watchFilterValue string
8282
var providerName string
8383
var requeueInterval time.Duration
84+
var tftpPort int
85+
var tftpValidateSourceIP bool
8486
var maxConcurrentReconciles int
8587
var lockerNamespace string
8688
var lockerDuration time.Duration
@@ -102,12 +104,14 @@ func main() {
102104
flag.StringVar(&watchFilterValue, "watch-filter", "", fmt.Sprintf("Label value that the controller watches to reconcile api objects. Label key is always %q. If unspecified, the controller watches for all api objects.", v1alpha1.WatchLabel))
103105
flag.StringVar(&providerName, "provider", "openconfig", "The provider to use for the controller. If not specified, the default provider is used. Available providers: "+strings.Join(provider.Providers(), ", "))
104106
flag.DurationVar(&requeueInterval, "requeue-interval", time.Hour, "The interval after which Kubernetes resources should be reconciled again regardless of whether they have changed.")
107+
flag.IntVar(&tftpPort, "tftp-port", 1069, "The port on which the inline TFTP server listens. Set to 0 to disable the TFTP server.")
108+
flag.BoolVar(&tftpValidateSourceIP, "tftp-validate-source-ip", false, "If set, the TFTP server validates the source IP and requested serial-based filename against the same Device.")
105109
flag.IntVar(&maxConcurrentReconciles, "max-concurrent-reconciles", 1, "The maximum number of concurrent reconciles per controller. Defaults to 1.")
106110
flag.StringVar(&lockerNamespace, "locker-namespace", "", "The namespace to use for resource locker coordination. If not specified, uses the namespace the manager is deployed in, or 'default' if undetectable.")
107111
flag.DurationVar(&lockerDuration, "locker-duration", 5*time.Second, "The duration of the resource locker lease.")
108112
flag.DurationVar(&lockerRenewInterval, "locker-renew-interval", time.Second, "The interval at which the resource locker lease is renewed.")
109113
flag.IntVar(&provisioningHTTPPort, "provisioning-http-port", 8080, "The port on which the provisioning HTTP server listens.")
110-
flag.BoolVar(&provisioningHTTPValidateSourceIP, "provisioning-http-validate-source-ip", false, "If set, the provisioning HTTP server will validate the source IP of incoming requests against the DeviceIPLabel of Device resources.")
114+
flag.BoolVar(&provisioningHTTPValidateSourceIP, "provisioning-http-validate-source-ip", false, "If set, the provisioning HTTP server will validate the source IP of incoming requests against Device.spec.endpoint.address.")
111115
opts := zap.Options{
112116
Development: true,
113117
TimeEncoder: zapcore.ISO8601TimeEncoder,
@@ -672,6 +676,22 @@ func main() {
672676
}
673677
}
674678

679+
// Start inline TFTP server when the configured port is non-zero.
680+
if tftpPort != 0 {
681+
tftpAddr := fmt.Sprintf(":%d", tftpPort)
682+
srv, err := tftpserver.New(ctx, tftpAddr, tftpValidateSourceIP, mgr, klog.NewKlogr().WithName("tftp"))
683+
if err != nil {
684+
setupLog.Error(err, "unable to initialize TFTP server")
685+
os.Exit(1)
686+
}
687+
688+
setupLog.Info("Adding inline TFTP server to manager", "address", tftpAddr, "validateSourceIP", tftpValidateSourceIP)
689+
if err := mgr.Add(srv); err != nil {
690+
setupLog.Error(err, "unable to add TFTP server to manager")
691+
os.Exit(1)
692+
}
693+
}
694+
675695
// +kubebuilder:scaffold:builder
676696

677697
if metricsCertWatcher != nil {

‎config/default/kustomization.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ resources:
2929
- metrics_service.yaml
3030
# [PROVISIONING] Expose the controller manager provisioning service.
3131
- provisioning_service.yaml
32+
# [TFTP] Expose the controller manager TFTP service.
33+
- tftp_service.yaml
3234
# [NETWORK POLICY] Protect the /metrics endpoint and Webhook Server with NetworkPolicy.
3335
# Only Pod(s) running a namespace labeled with 'metrics: enabled' will be able to gather the metrics.
3436
# Only CR(s) which requires webhooks and are applied on namespaces labeled with 'webhooks: enabled' will
@@ -61,6 +63,11 @@ patches:
6163
target:
6264
kind: Deployment
6365

66+
# [TFTP] The following patch will add the TFTP port to the manager container.
67+
- path: manager_tftp_patch.yaml
68+
target:
69+
kind: Deployment
70+
6471
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER' prefix.
6572
# Uncomment the following replacements to add the cert-manager CA injection annotations
6673
replacements:
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This patch adds the container port for the TFTP service.
2+
- op: add
3+
path: /spec/template/spec/containers/0/ports/-
4+
value:
5+
containerPort: 1069
6+
name: tftp
7+
protocol: UDP

‎config/default/tftp_service.yaml‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
labels:
5+
control-plane: controller-manager
6+
app.kubernetes.io/name: network-operator
7+
app.kubernetes.io/managed-by: kustomize
8+
name: controller-manager-tftp-service
9+
namespace: system
10+
spec:
11+
ports:
12+
- name: tftp
13+
port: 1069
14+
protocol: UDP
15+
targetPort: 1069
16+
selector:
17+
control-plane: controller-manager
18+
app.kubernetes.io/name: network-operator
19+
type: ClusterIP

‎go.mod‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
github.com/openconfig/goyang v1.6.3
1515
github.com/openconfig/ygnmi v0.14.0
1616
github.com/openconfig/ygot v0.34.0
17+
github.com/pin/tftp/v3 v3.1.0
1718
github.com/sapcc/go-api-declarations v1.21.0
1819
github.com/stretchr/testify v1.11.1
1920
github.com/tidwall/gjson v1.18.0
@@ -70,7 +71,7 @@ require (
7071
github.com/google/gnostic-models v0.7.1 // indirect
7172
github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect
7273
github.com/google/uuid v1.6.0 // indirect
73-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 // indirect
74+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7 // indirect
7475
github.com/inconshreveable/mousetrap v1.1.0 // indirect
7576
github.com/json-iterator/go v1.1.12 // indirect
7677
github.com/kylelemons/godebug v1.1.0 // indirect
@@ -113,8 +114,8 @@ require (
113114
golang.org/x/text v0.35.0 // indirect
114115
golang.org/x/time v0.14.0 // indirect
115116
gomodules.xyz/jsonpatch/v2 v2.5.0 // indirect
116-
google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b // indirect
117-
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b // indirect
117+
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 // indirect
118+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 // indirect
118119
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
119120
gopkg.in/inf.v0 v0.9.1 // indirect
120121
gopkg.in/yaml.v3 v3.0.1 // indirect

‎go.sum‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
109109
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
110110
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 h1:kEISI/Gx67NzH3nJxAmY/dGac80kKZgZt134u7Y/k1s=
111111
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4/go.mod h1:6Nz966r3vQYCqIzWsuEl9d7cf7mRhtDmm++sOxlnfxI=
112+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7 h1:X+2YciYSxvMQK0UZ7sg45ZVabVZBeBuvMkmuI2V3Fak=
113+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.7/go.mod h1:lW34nIZuQ8UDPdkon5fmfp2l3+ZkQ2me/+oecHYLOII=
112114
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
113115
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
114116
github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE=
@@ -153,6 +155,8 @@ github.com/openconfig/ygnmi v0.14.0 h1:WXkZU8NcMVJzZBn1mDm7GMdJ+WyU2ab/4ls1kMKPN
153155
github.com/openconfig/ygnmi v0.14.0/go.mod h1:c5ThNBAhrg5o3ZP5V9xagjlJZaKLPFMcJ2Mc3mcNJ8g=
154156
github.com/openconfig/ygot v0.34.0 h1:9OkVjy3SGi4mbvAZc4HTQBU9u4MT6k4j5DdX+hgRiC4=
155157
github.com/openconfig/ygot v0.34.0/go.mod h1:eMNQHrJpanet+pQoBw/P3ua4sLY/tRTXyJ7ALkWCvl4=
158+
github.com/pin/tftp/v3 v3.1.0 h1:rQaxd4pGwcAJnpId8zC+O2NX3B2/NscjDZQaqEjuE7c=
159+
github.com/pin/tftp/v3 v3.1.0/go.mod h1:xwQaN4viYL019tM4i8iecm++5cGxSqen6AJEOEyEI0w=
156160
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
157161
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
158162
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -210,6 +214,8 @@ go.opentelemetry.io/otel v1.40.0 h1:oA5YeOcpRTXq6NN7frwmwFR0Cn3RhTVZvXsP4duvCms=
210214
go.opentelemetry.io/otel v1.40.0/go.mod h1:IMb+uXZUKkMXdPddhwAHm6UfOwJyh4ct1ybIlV14J0g=
211215
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 h1:f0cb2XPmrqn4XMy9PNliTgRKJgS5WcL/u0/WRYGz4t0=
212216
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0/go.mod h1:vnakAaFckOMiMtOIhFI2MNH4FYrZzXCYxmb1LlhoGz8=
217+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0 h1:QKdN8ly8zEMrByybbQgv8cWBcdAarwmIPZ6FThrWXJs=
218+
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.40.0/go.mod h1:bTdK1nhqF76qiPoCCdyFIV+N/sRHYXYCTQc+3VCi3MI=
213219
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 h1:in9O8ESIOlwJAEGTkkf34DesGRAc/Pn8qJ7k3r/42LM=
214220
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0/go.mod h1:Rp0EXBm5tfnv0WL+ARyO/PHBEaEAT8UUHQ6AGJcSq6c=
215221
go.opentelemetry.io/otel/metric v1.40.0 h1:rcZe317KPftE2rstWIBitCdVp89A2HqjkxR3c11+p9g=
@@ -234,22 +240,26 @@ go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0=
234240
go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8=
235241
go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc=
236242
go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
243+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
237244
golang.org/x/crypto v0.49.0 h1:+Ng2ULVvLHnJ/ZFEq4KdcDd/cfjrrjjNSXNzxg0Y4U4=
238245
golang.org/x/crypto v0.49.0/go.mod h1:ErX4dUh2UM+CFYiXZRTcMpEcN8b/1gxEuv3nODoYtCA=
239246
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93 h1:fQsdNF2N+/YewlRZiricy4P1iimyPKZ/xwniHj8Q2a0=
240247
golang.org/x/exp v0.0.0-20251219203646-944ab1f22d93/go.mod h1:EPRbTFwzwjXj9NpYyyrvenVh9Y+GFeEvMNh7Xuz7xgU=
241248
golang.org/x/mod v0.34.0 h1:xIHgNUUnW6sYkcM5Jleh05DvLOtwc6RitGHbDk4akRI=
242249
golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY=
250+
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
243251
golang.org/x/net v0.52.0 h1:He/TN1l0e4mmR3QqHMT2Xab3Aj3L9qjbhRm78/6jrW0=
244252
golang.org/x/net v0.52.0/go.mod h1:R1MAz7uMZxVMualyPXb+VaqGSa3LIaUqk0eEt3w36Sw=
245253
golang.org/x/oauth2 v0.34.0 h1:hqK/t4AKgbqWkdkcAeI8XLmbK+4m4G5YeQRrmiotGlw=
246254
golang.org/x/oauth2 v0.34.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA=
247255
golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4=
248256
golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
257+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
249258
golang.org/x/sys v0.42.0 h1:omrd2nAlyT5ESRdCLYdm3+fMfNFE/+Rf4bDIQImRJeo=
250259
golang.org/x/sys v0.42.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
251260
golang.org/x/term v0.41.0 h1:QCgPso/Q3RTJx2Th4bDLqML4W6iJiaXFq2/ftQF13YU=
252261
golang.org/x/term v0.41.0/go.mod h1:3pfBgksrReYfZ5lvYM0kSO0LIkAl4Yl2bXOkKP7Ec2A=
262+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
253263
golang.org/x/text v0.35.0 h1:JOVx6vVDFokkpaq1AEptVzLTpDe9KGpj5tR4/X+ybL8=
254264
golang.org/x/text v0.35.0/go.mod h1:khi/HExzZJ2pGnjenulevKNX1W67CUy0AsXcNubPGCA=
255265
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
@@ -262,8 +272,12 @@ gonum.org/v1/gonum v0.16.0 h1:5+ul4Swaf3ESvrOnidPp4GZbzf0mxVQpDCYUQE7OJfk=
262272
gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E=
263273
google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b h1:uA40e2M6fYRBf0+8uN5mLlqUtV192iiksiICIBkYJ1E=
264274
google.golang.org/genproto/googleapis/api v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:Xa7le7qx2vmqB/SzWUBa7KdMjpdpAHlh5QCSnjessQk=
275+
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409 h1:merA0rdPeUV3YIIfHHcH4qBkiQAc1nfCKSI7lB4cV2M=
276+
google.golang.org/genproto/googleapis/api v0.0.0-20260128011058-8636f8732409/go.mod h1:fl8J1IvUjCilwZzQowmw2b7HQB2eAuYBabMXzWurF+I=
265277
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b h1:Mv8VFug0MP9e5vUxfBcE3vUkV6CImK3cMNMIDFjmzxU=
266278
google.golang.org/genproto/googleapis/rpc v0.0.0-20251222181119-0a764e51fe1b/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=
279+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409 h1:H86B94AW+VfJWDqFeEbBPhEtHzJwJfTbgE2lZa54ZAQ=
280+
google.golang.org/genproto/googleapis/rpc v0.0.0-20260128011058-8636f8732409/go.mod h1:j9x/tPzZkyxcgEFkiKEEGxfvyumM01BEtsW8xzOahRQ=
267281
google.golang.org/grpc v1.79.3 h1:sybAEdRIEtvcD68Gx7dmnwjZKlyfuc61Dyo9pGXXkKE=
268282
google.golang.org/grpc v1.79.3/go.mod h1:KmT0Kjez+0dde/v2j9vzwoAScgEPx/Bw1CYChhHLrHQ=
269283
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=

‎internal/controller/core/device_controller.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,18 @@ func (r *DeviceReconciler) reconcile(ctx context.Context, device *v1alpha1.Devic
319319
Message: "Device is healthy",
320320
})
321321

322+
log := ctrl.LoggerFrom(ctx)
323+
if device.Labels == nil {
324+
device.Labels = map[string]string{}
325+
}
326+
if serial := strings.ToLower(device.Status.SerialNumber); serial != "" {
327+
if device.Labels[v1alpha1.DeviceSerialLabel] == "" {
328+
device.Labels[v1alpha1.DeviceSerialLabel] = serial
329+
} else if device.Labels[v1alpha1.DeviceSerialLabel] != serial {
330+
log.Info("Device serial label does not match observed device serial number", "labelSerial", device.Labels[v1alpha1.DeviceSerialLabel], "observedSerial", serial)
331+
}
332+
}
333+
322334
return nil
323335
}
324336

0 commit comments

Comments
 (0)