-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional S3_REGION config #846
Comments
With ____TODO____, closes getodk#846
While I think this is a good idea, you can also upgrade minio-js to the current version to get the new AWS regions. I sent in a PR to them (minio/minio-js#1363) to add the extra AWS regions. That has been incorporated into their 8.0.3 release. |
Amazing, thanks @derekmorr! Does this mean I misunderstood the issue? I thought that the problem was that the initial request against the generic S3 URL did not result in usable region information. From your comment and PR, it sounds like that initial exchange does provide region information, |
Not quite. Minio's That cache was out-of-date, so I sent them a PR to update it. So there are a few ways to fix the problem:
Since the ODK docs mention using S3-compatible providers other than AWS, I think you'll need to at least make S3_REGION optional. The only other option is to patch minio to support every possible S3-compatible endpoint which would be a lot of work. |
Really appreciate the follow-up!
That makes sense and you're right that we probably do want 3 regardless at some point no matter what.
Looks like it gets the region code from the response to an initial request to the generic URL at https://github.com/minio/minio-js/blob/a8e1abb5e2322b9d9bf938fb560e6e330d305ccc/src/internal/client.ts#L772 and presumably this works even for the newer regions (so not affected by https://repost.aws/questions/QUIZTCFPrzQXa2WJ2VaPC2lw/buckets-created-in-af-south-1-cannot-be-accessed-through-global-endpoint) Thanks again! |
I don't think that's what's happening in the current PR. The following code should allow creating a minio client both with and without the |
I agree that updating odk-central's minio dependency will increase the number of s3 regions that can be auto-mapped from the E.g.
|
I've added an issue for this at getodk/central-backend#1376 However, there are API changes between In future, it would be convenient if new s3 regions could be configured for the minio client without requiring a library update. I've created an issue about this at minio/minio-js#1375 |
This is a great summary, thanks. I think 3 is addressed by the PRs at #846 (comment), 1 is addressed by getodk/central-backend#1376, and minio/minio-js#1375 would speed up dealing with similar issues in future. |
This comment has been minimized.
This comment has been minimized.
You are saying that with the
This is extremely surprising -- I could not get region-specific URLs to work. Is that because of Central's usage? |
Ah no, this was because of a mistake in the test code shared above. Thanks for catching that. I've hidden the misleading results, and will re-share below. |
test codeconst minio = require('minio');
const { Client } = minio;
const minioVersion = require('minio/package.json').version
printRow(code(minioVersion), code('endPoint'), code('region'));
console.log('---|---|---');
(async () => {
await testConfig({ endPoint:'s3.amazonaws.com' });
await testConfig({ endPoint:'s3.amazonaws.com', region:'us-east-1' });
await testConfig({ endPoint:'s3.amazonaws.com', region:'af-south-1' });
await testConfig({ endPoint:'s3.af-south-1.amazonaws.com' });
await testConfig({ endPoint:'s3.af-south-1.amazonaws.com', region:'us-east-1' });
await testConfig({ endPoint:'s3.af-south-1.amazonaws.com', region:'af-south-1' });
await testConfig({ endPoint:'s3.us-east-1.amazonaws.com' });
await testConfig({ endPoint:'s3.us-east-1.amazonaws.com', region:'us-east-1' });
await testConfig({ endPoint:'s3.us-east-1.amazonaws.com', region:'af-south-1' });
function testConfig(cfg) {
return new Promise(resolve => {
try {
const client = new Client({ ...cfg });
stream = client.listObjects('deafrica-input-datasets');
stream.on('error', err => {
logResult(cfg, false);
resolve();
});
stream.on('end', () => { console.log('stream.end'); });
stream.on('data', o => {
logResult(cfg, true);
stream.destroy();
resolve();
});
} catch(err) {
console.log('\nouter error:', '\n config:', JSON.stringify(cfg), '\n error:', err.code, err.message);
};
});
}
})();
function code(s) {
return `\`${s}\``;
}
function logResult(cfg, ok) {
printRow(ok ? '✅' : '❌', code(cfg.endPoint), cfg.region ? code(cfg.region) : '(undefined)');
}
function printRow(...cols) {
console.log(cols.join(' | '));
} |
Upgrading the |
Amazing! Thanks so much for the tip, @derekmorr Let's close this issue and related PRs once getodk/central-backend#1378 is merged. We can re-open if someone needs another region-aware provider. I'd rather do that than add it right away because it would be helpful to know about the use case and see whether a REGION configuration is really the best way to address it. |
Short-term need addressed by getodk/central-backend#1378 for now |
We originally decided not to make region configurable because minio detects, caches and uses the region when making a request against a generic storage URL.
We've now discovered that for Amazon S3, regions introduced after 2019 like
af-south-1
can't use the generic URL: https://forum.getodk.org/t/using-external-aws-s3-bucket-in-region-other-than-us-east-1/51392The text was updated successfully, but these errors were encountered: