From bd51582da2b320b88d88227716676dafffd3c999 Mon Sep 17 00:00:00 2001 From: Andreas Burger Date: Thu, 17 Oct 2024 09:42:43 +0200 Subject: [PATCH] check whether a network was found --- pkg/controller/infrastructure/infraflow/reconcile.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/controller/infrastructure/infraflow/reconcile.go b/pkg/controller/infrastructure/infraflow/reconcile.go index fc1859e19..b672ee46c 100644 --- a/pkg/controller/infrastructure/infraflow/reconcile.go +++ b/pkg/controller/infrastructure/infraflow/reconcile.go @@ -199,13 +199,17 @@ func (fctx *FlowContext) ensureNetwork(ctx context.Context) error { } func (fctx *FlowContext) ensureConfiguredNetwork(_ context.Context) error { - network, err := fctx.access.GetNetworkByID(*fctx.config.Networks.ID) + networkId := *fctx.config.Networks.ID + network, err := fctx.access.GetNetworkByID(networkId) if err != nil { fctx.state.Set(IdentifierNetwork, "") fctx.state.Set(NameNetwork, "") return err } - fctx.state.Set(IdentifierNetwork, *fctx.config.Networks.ID) + if network == nil { + return fmt.Errorf("network with ID '%s' was not found", networkId) + } + fctx.state.Set(IdentifierNetwork, networkId) fctx.state.Set(NameNetwork, network.Name) return nil }