Skip to content
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

fix: honour the set region config #1039

Merged
merged 6 commits into from Jul 11, 2022

Conversation

prakashsvmx
Copy link
Member

@prakashsvmx prakashsvmx commented Jun 14, 2022

honour the set region config
fixes #1038

  playConfig= {
    useSSL:false,
    endPoint:"localhost",
    port:9000,
    accessKey:"minio",
    secretKey:"minio123",
    region: "us-west-1  
  }

Test env setup for default region:

//ensure no region is set in minio server
mc admin config set local region name= && mc admin service restart local

export SERVER_ENDPOINT=localhost:9000 && export ACCESS_KEY=minio && export SECRET_KEY=minio123 && npm run functional

 mc admin config set local region name=us-west-1 && mc admin service restart local

export MINIO_REGION="us-west-1" && export SERVER_ENDPOINT=localhost:9000 && export ACCESS_KEY=minio && export SECRET_KEY=minio123 && npm run functional
Test script for APIs
var Minio = require('../../dist/main/minio')
const _ = require("lodash");

let s3Client = new Minio.Client({
  useSSL:false,
  endPoint:"localhost",
  port:9000,
  accessKey:"minio",
  secretKey:"minio123",
  region:"us-west-1"
})

s3Client.traceOn()
/*s3Client.makeBucket("test-new-bucket-e1","", (err, res)=>{
  if(err) {
    console.log(":Err:..", err)
  }
  if (res){
    console.log(".. Done..")
  }
})*/

/*
s3Client.listBuckets((e, buckets) => {
  if (e) {
    console.log("Error....")
  }

  console.log(`Listed:${buckets.length}`)
})*/


var objectsStream = s3Client.listObjects('test-bucket', '', true)
objectsStream.on('data', function(obj) {
  console.log(obj)
})
objectsStream.on('error', function(e) {
  console.log(e)
})

@prakashsvmx prakashsvmx self-assigned this Jun 14, 2022
src/main/helpers.js Fixed Show fixed Hide fixed
harshavardhana
harshavardhana previously approved these changes Jun 14, 2022
harshavardhana
harshavardhana previously approved these changes Jun 15, 2022
src/test/functional/functional-tests.js Outdated Show resolved Hide resolved
src/test/functional/functional-tests.js Show resolved Hide resolved
Copy link
Member

@harshavardhana harshavardhana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prakashsvmx I think there may be some bugs that you might have now because the changes look way too much.

Check how minio-py handles this specifically def _get_region - this is what you need in minio-js.

@prakashsvmx
Copy link
Member Author

@harshavardhana thank you. I checked the minio-py and added back the validation i removed in earlier commit.

i have extracted the hard coded default region into a const and replaced all the occurrences
And the functional-tests.js has been formatted

src/main/minio.js Outdated Show resolved Hide resolved
src/main/minio.js Outdated Show resolved Hide resolved
src/test/functional/functional-tests.js Show resolved Hide resolved
src/test/functional/functional-tests.js Show resolved Hide resolved
src/test/functional/functional-tests.js Outdated Show resolved Hide resolved
@prakashsvmx
Copy link
Member Author

I have checked the minio-go code. as per the implementation, the make bucket is retried with server returned region in case the region is not configured ("") or default region (us-east-1) on the client.

So i will explore further . marking it as WIP. @harshavardhana @ebozduman @kannappanr

thank you for the guidance.

@prakashsvmx prakashsvmx changed the title fix: honour the set region config [WIP] fix: honour the set region config Jun 16, 2022
src/main/helpers.js Fixed Show fixed Hide fixed
@@ -791,3 +791,5 @@
}

}

export const DEFAULT_REGION = 'us-east-1'

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "us-east-1" is used as [authorization header](1).
@prakashsvmx prakashsvmx changed the title [WIP] fix: honour the set region config fix: honour the set region config Jun 16, 2022
src/main/minio.js Outdated Show resolved Hide resolved
Copy link
Contributor

@ebozduman ebozduman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@harshavardhana harshavardhana merged commit 55d0161 into minio:master Jul 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Region hardcoded in listBuckets
3 participants