Skip to content

Commit

Permalink
fix: deleted network is re used in recreate
Browse files Browse the repository at this point in the history
  • Loading branch information
KunalSin9h committed Feb 11, 2024
1 parent 5fe407a commit c9aaea8
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions internal/core/application/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,23 +329,23 @@ func createNetwork(cli *client.Client, appName string) (string, error) {
slog.Info("Creating network")
networkName := appName + "_default"

// nets, err := cli.NetworkList(context.Background(), types.NetworkListOptions{})
// if err != nil {
// return "", err
// }
// // waiting for 5 seconds, if old network is in deletion process
// // this problem only occur only recreating application
// // in that case, old network was not deleted and we try to create a new network already
// // slog.Info("waiting for 5 seconds, if old network is in deletion process")
// // time.Sleep(5 * time.Second)

// for _, network := range nets {
// slog.Info(network.Name)
// if network.Name == networkName {
// slog.Info("Network already exists")
// return network.ID, nil
// }
// }
// waiting for 5 seconds, if old network is in deletion process
// this problem only occur only recreating application
// in that case, old network was not deleted and we try to create a new network already
slog.Info("waiting for 5 seconds, if old network is in deletion process")
time.Sleep(5 * time.Second)

nets, err := cli.NetworkList(context.Background(), types.NetworkListOptions{})
if err != nil {
return "", err
}

for _, network := range nets {
if network.Name == networkName {
slog.Info("Network already exists")
return network.ID, nil
}
}

net, err := cli.NetworkCreate(context.Background(), networkName, types.NetworkCreate{
Scope: "swarm",
Expand Down

0 comments on commit c9aaea8

Please sign in to comment.