Skip to content

Commit

Permalink
wait and list networks before connecting
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Jul 31, 2024
1 parent aaca583 commit caf9b42
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package reverse_proxy_functions

import (
"context"
"github.com/sirupsen/logrus"
"net"
"time"

"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/docker_manager"
"github.com/kurtosis-tech/kurtosis/container-engine-lib/lib/backend_impls/docker/object_attributes_provider/docker_label_key"
Expand Down Expand Up @@ -34,6 +36,10 @@ func ConnectReverseProxyToNetwork(ctx context.Context, dockerManager *docker_man
return nil
}

logrus.Infof("Waiting a few second before connecting reverse proxy to network...")
time.Sleep(10 * time.Second)

err := dockerManager.dockerClient
if err = dockerManager.ConnectContainerToNetwork(ctx, networkId, maybeReverseProxyContainerId, autoAssignIpAddressToReverseProxy, emptyAliasForReverseProxy); err != nil {
return stacktrace.Propagate(err, "An error occurred while connecting the reverse proxy with container id '%v' to the enclave network '%v'", maybeReverseProxyContainerId, networkId)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,15 @@ func (manager *DockerManager) ConnectContainerToNetwork(ctx context.Context, net

config := getEndpointSettingsForIpAddress(staticIpAddressStr, alias)

logrus.Infof("Listing all networks right before attempting to connect to network...")
networkResources, err := manager.dockerClient.NetworkList(ctx, types.NetworkListOptions{})
for _, networkResource := range networkResources {
logrus.Infof("Information about network '%v' that exists: %v", networkResource.Name, networkResource)
if networkResource.ID == networkId {
logrus.Infof("The network we are trying to connect to exists right before connection.")
}
}

err = manager.dockerClient.NetworkConnect(
ctx,
networkId,
Expand Down

0 comments on commit caf9b42

Please sign in to comment.