From 0b86edab80cf4dd01f330d7721b130f5017d84a5 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Wed, 18 Aug 2021 20:34:47 +0300 Subject: [PATCH] fix: don't panic if the machine config doesn't have network (EM) This handles the case if the machine config doesn't contain `.machine.network` (I got hit by that today). Signed-off-by: Andrey Smirnov --- .../pkg/runtime/v1alpha1/platform/packet/packet.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/app/machined/pkg/runtime/v1alpha1/platform/packet/packet.go b/internal/app/machined/pkg/runtime/v1alpha1/platform/packet/packet.go index d81534bb8..4f74821ad 100644 --- a/internal/app/machined/pkg/runtime/v1alpha1/platform/packet/packet.go +++ b/internal/app/machined/pkg/runtime/v1alpha1/platform/packet/packet.go @@ -76,7 +76,7 @@ func (p *Packet) Name() string { } // Configuration implements the platform.Platform interface. -//nolint:gocyclo +//nolint:gocyclo,cyclop func (p *Packet) Configuration(ctx context.Context) ([]byte, error) { // Fetch and unmarshal both the talos machine config and the // metadata about the instance from packet's metadata server @@ -199,6 +199,14 @@ func (p *Packet) Configuration(ctx context.Context) ([]byte, error) { } } + if machineConfig.MachineConfig == nil { + machineConfig.MachineConfig = &v1alpha1.MachineConfig{} + } + + if machineConfig.MachineConfig.MachineNetwork == nil { + machineConfig.MachineConfig.MachineNetwork = &v1alpha1.NetworkConfig{} + } + machineConfig.MachineConfig.MachineNetwork.NetworkInterfaces = append( machineConfig.MachineConfig.MachineNetwork.NetworkInterfaces, &bondDev,