Skip to content

Commit

Permalink
Re-execute full validation for AppNetworkConfig once pending NIs are …
Browse files Browse the repository at this point in the history
…ready

When an application network configuration depends on a network instance (NI)
that is either missing or in an error state, zedrouter flags the AppNetworkStatus
with AwaitNetworkInstance. It then waits until the network instance becomes
available and is activated without errors before proceeding with the activation
of the application network.

However, conditions may change while the application is waiting for the network
instance to be available. For instance, another application with conflicting
port forwarding rules could have been deployed during this time, which would
necessitate preventing the activation of this app's network.

To address this, we adopt the approach used in zedrouter.retryFailedAppNetworks(),
where the entire pubsub handler is re-executed to repeat the full validation process.
The handler is idempotent, ensuring operations like AppNum allocation reuse
previously set values.

Signed-off-by: Milan Lenco <[email protected]>
  • Loading branch information
milan-zededa authored and OhmSpectator committed Dec 5, 2024
1 parent a85bf88 commit e32819e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/pillar/cmd/zedrouter/appnetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,12 @@ func (z *zedrouter) checkAndRecreateAppNetworks(niID uuid.UUID) {
}
if !appNetStatus.HasError() && !appNetStatus.AwaitNetworkInstance &&
appNetConfig.Activate && !appNetStatus.Activated {
z.doActivateAppNetwork(*appNetConfig, &appNetStatus)
// Re-execute the entire pubsub handler to repeat the full validation process.
// The conditions might have changed while the application was waiting for the
// network instance to appear or get fixed. For instance, another application
// with conflicting port forwarding rules could have been deployed during this
// time, which would necessitate preventing the activation of this app's network.
z.handleAppNetworkCreate(nil, appNetConfig.Key(), *appNetConfig)
}
z.log.Functionf("checkAndRecreateAppNetworks(%v) done for %s",
niID, appNetConfig.DisplayName)
Expand Down

0 comments on commit e32819e

Please sign in to comment.