Skip to content

Commit

Permalink
fix: recreating is failing, does not recreate applicaiton
Browse files Browse the repository at this point in the history
  • Loading branch information
KunalSin9h committed Feb 11, 2024
1 parent d3bfa04 commit 8c4934f
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions internal/core/application/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,22 +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 {
if network.Name == networkName {
slog.Info("Network already exists")
return network.ID, nil
}
}
// 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
// }
// }

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

0 comments on commit 8c4934f

Please sign in to comment.