Skip to content

Commit 3390881

Browse files
authored
fix: nil pointer dereference when network is not found (#29)
Signed-off-by: Niclas Schad <niclas.schad@stackit.cloud>
1 parent 72aaeba commit 3390881

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

pkg/controller/infrastructure/stackit/infraflow/reconcile.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,20 @@ func (fctx *FlowContext) ensureOpenStackSubnetID(ctx context.Context) error {
152152
)
153153
}
154154

155+
if osNetwork == nil {
156+
return gardenv1beta1helper.NewErrorWithCodes(
157+
fmt.Errorf("network with ID '%s' was not found", networkID),
158+
gardencorev1beta1.ErrorInfraDependencies,
159+
)
160+
}
161+
162+
if len(osNetwork.Subnets) == 0 {
163+
return gardenv1beta1helper.NewErrorWithCodes(
164+
fmt.Errorf("network with ID '%s' does not have any subnets", networkID),
165+
gardencorev1beta1.ErrorInfraDependencies,
166+
)
167+
}
168+
155169
// TODO: A network can have multiple subnets. Check if we can just fetch the first one
156170
fctx.state.Set(IdentifierSubnet, osNetwork.Subnets[0])
157171
return nil

0 commit comments

Comments
 (0)