S3: fix issue with EC2 IDMSv2 request failing inside Docker container… #6752
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.
… with default networking
and causing later unrelated issues when opening a dataset. Cf https://lists.osgeo.org/pipermail/gdal-dev/2022-November/056488.html thread
https://community.grafana.com/t/imdsv2-is-not-working-from-docker/65944 points that the
curl -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 10
request doesn't work inside Docker with default networking settings.docker run --network=host
avoids that issueThe issue was that the failure of the EC2 IDMSv2 request set a CPLError() that was hidden, but not cleared. Hence when GDALOpen() run, after probing a first driver (VRT e.g.) that doesn't detect the dataset, the fact that the error state was in error made GDALOpen() abort without trying subsequent drivers.
So make sure to clear the error reset after EC2 HTTP requests, and when EC2 IDMSv2 fails but http://169.254.169.254/latest/meta-data succeeds, emit a debug message with a hint when we detect we are inside Docker.