Skip to content

Commit

Permalink
check whether a network was found (#879)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBurger authored Oct 17, 2024
1 parent ae74b9f commit b991f4a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/controller/infrastructure/infraflow/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"fmt"
"time"

gardencorev1beta1 "github.com/gardener/gardener/pkg/apis/core/v1beta1"
gardenv1beta1helper "github.com/gardener/gardener/pkg/apis/core/v1beta1/helper"
"github.com/gardener/gardener/pkg/utils/flow"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules"
Expand Down Expand Up @@ -199,13 +201,20 @@ 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 gardenv1beta1helper.NewErrorWithCodes(
fmt.Errorf("network with ID '%s' was not found", networkId),
gardencorev1beta1.ErrorInfraDependencies,
)
}
fctx.state.Set(IdentifierNetwork, networkId)
fctx.state.Set(NameNetwork, network.Name)
return nil
}
Expand Down

0 comments on commit b991f4a

Please sign in to comment.