fix(ServiceBus): Remove container lifecycle overrides #1465
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Due to a bug or regression in Docker Desktop, I noticed that we're calling
StartAsync()for the database container in the Service Bus module twice. Normally, this wouldn't be a problem, but with the current Docker Desktop regression, it breaks the module.Since our modules don't handle cleaning up dependent resources (because they don't know who owns them), I've decided to remove this special handling from the Service Bus module as well. Testcontainers can resolve the dependency graph and automatically create all necessary resources. There's no need to explicitly override
UnsafeCreateAsync(CancellationToken)orUnsafeStartAsync(CancellationToken).Also, the current implementation is inconsistent. For example, it removes the dependent container but not the associated network.
To reliably remove dependent resources, we'd need to track which ones are created by our internal library and which are passed in to the builder configuration. Even then, reliably deleting orphaned resources within the test process isn't really feasible. Ryuk usually handles that. Resources only get leaked in environments that don't support Ryuk and aren't ephemeral.
The Docker Desktop regression is easy to reproduce: just call
docker start <container_id>a second time, and it messes up the port bindings.Why is it important?
Workaround Docker Desktop regression.
Related issues
-