-
Notifications
You must be signed in to change notification settings - Fork 252
ft/ZENKO-229 get using location #1204
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
Conversation
926487e to
577c8fc
Compare
|
PR has been updated. Reviewers, please be cautious. |
1 similar comment
|
PR has been updated. Reviewers, please be cautious. |
fade444 to
5c9801a
Compare
|
PR has been updated. Reviewers, please be cautious. |
|
|
||
| module.exports = { | ||
| locationConstraintCheck, | ||
| locationHeaderCheck, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend separating it to it's own module to keep things modular.
| const location = headers['x-amz-location-constraint']; | ||
| if (location) { | ||
| const locationConstraints = Object.keys(config.locationConstraints); | ||
| const validLocation = locationConstraints.includes(location); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can just be
const validLocation = config.locationConstraints[location];| const locationConstraints = Object.keys(config.locationConstraints); | ||
| const validLocation = locationConstraints.includes(location); | ||
| if (!validLocation) { | ||
| return errors.InvalidArgument.customizeDescription( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use errors.InvalidLocationConstraint since we already have it.
| } | ||
| const locConfigObj = config.locationConstraints[location]; | ||
| const bucketMatch = locConfigObj.details.bucketMatch; | ||
| let backendKey = objectKey; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ternary operators make the logic look easy here
const backendKey = bucketMatch ? objectKey : `${bucketName}/${objectKey}`;| const locMatch = replicationInfo.backends.find( | ||
| backend => backend.site === locationObj.location); | ||
| if (!locMatch) { | ||
| repBackendResult.error = errors.InvalidArgument.customizeDescription( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use InvalidLocationConstraint for this as well.
| return repBackendResult; | ||
| } | ||
| if (locMatch.status === 'PENDING') { | ||
| repBackendResult.error = errors.InternalError.customizeDescription( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use errors.NoSuchKey here
| * @param {string} locationObj.location - name of location constraint | ||
| * @param {string} locationObj.key - keyname of object in location constraint | ||
| * @param {string} locationObj.type - type of location constraint | ||
| * @param {object} replicationInfo - information about object replication |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please expand on the properties of this object.
| * @param {object} headers - request headers | ||
| * @param {string} objectKey - key name of object | ||
| * @param {string} bucketName - name of bucket | ||
| * @return {object} - error if header location is not valid or object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please expand on the properties of the return object and also include undefined as a return value. This seems to be the format generally used
@return {undefined|Object}
@return {any} return.value The value of the attribute
@return {boolean} return.modified If the value has been changed
etc
| log.trace('invalid location constraint to get from', { | ||
| location: request.headers['x-amz-location-constraint'], | ||
| error: locCheckResult, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can return the callback early avoid any further processing.
|
PR has been updated. Reviewers, please be cautious. |
1 similar comment
|
PR has been updated. Reviewers, please be cautious. |
ba79b9b to
d252705
Compare
|
PR has been updated. Reviewers, please be cautious. |
d252705 to
1f8fc75
Compare
|
PR has been updated. Reviewers, please be cautious. |
1 similar comment
|
PR has been updated. Reviewers, please be cautious. |
|
| 'passed in location header'); | ||
| return repBackendResult; | ||
| } | ||
| if (locMatch.status === 'PENDING') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may also want to handle FAILED status the same way, or alternatively, return the locator if status is COMPLETED, and fail otherwise and provide the replication status as an extra info in the returned message.
| * @return {object} contains error if no replication backend matches or | ||
| * dataLocator object | ||
| */ | ||
| function replicationBackendCompare(locationObj, replicationInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about renaming to getReplicationBackendDataLocator, since this is the main purpose of the function (and especially since the function is exported as a utility function potentially useful for others - thinking of transient source 😄).
|
PR has been updated. Reviewers, please be cautious. |
e5beef7 to
a52ce02
Compare
|
PR has been updated. Reviewers, please be cautious. |
a52ce02 to
b102bfa
Compare
|
PR has been updated. Reviewers, please be cautious. |
b102bfa to
6141c35
Compare
|
PR has been updated. Reviewers, please be cautious. |
6141c35 to
5cf6e08
Compare
|
PR has been updated. Reviewers, please be cautious. |
5cf6e08 to
4ad2032
Compare
|
PR has been updated. Reviewers, please be cautious. |
|
@ironman-machine try |
|
Hello @dora-korpar "try": Success: Try build successfully launched on 'http://ci.ironmann.io/gh/scality/Integration/21340' with the following env. args: {
"DEFAULT_BRANCH": "master",
"SCALITY_INTEGRATION_BRANCH": "ultron/master",
"REPO_NAME": "S3",
"SCALITY_S3_BRANCH": "ft/ZENKO-229-get-using-location"
} |
bennettbuchanan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
| } | ||
| if (['PENDING', 'FAILED'].includes(locMatch.status)) { | ||
| repBackendResult.error = errors.NoSuchKey.customizeDescription( | ||
| 'Object replication to specified backend is not complete'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could imagine it being nice to include the status in the description, particularly if the status is failed. That way the user would know to retry the operation.
|
@ironman-machine try |
|
Hello @dora-korpar "try": Success: Try build successfully launched on 'http://ci.ironmann.io/gh/scality/Integration/21351' with the following env. args: {
"DEFAULT_BRANCH": "master",
"SCALITY_INTEGRATION_BRANCH": "ultron/master",
"REPO_NAME": "S3",
"SCALITY_S3_BRANCH": "ft/ZENKO-229-get-using-location"
} |
|
@ironman-machine try |
|
Hello @dora-korpar "try": Success: Try build successfully launched on 'http://ci.ironmann.io/gh/scality/Integration/21376' with the following env. args: {
"DEFAULT_BRANCH": "master",
"SCALITY_INTEGRATION_BRANCH": "ultron/master",
"REPO_NAME": "S3",
"SCALITY_S3_BRANCH": "ft/ZENKO-229-get-using-location"
} |
a727ebc to
6c6a51e
Compare
|
PR has been updated. Reviewers, please be cautious. |
|
@ironman-machine try |
|
Hello @dora-korpar "try": Success: Try build successfully launched on 'http://ci.ironmann.io/gh/scality/Integration/21412' with the following env. args: {
"DEFAULT_BRANCH": "master",
"SCALITY_INTEGRATION_BRANCH": "ultron/master",
"REPO_NAME": "S3",
"SCALITY_S3_BRANCH": "ft/ZENKO-229-get-using-location"
} |
|
@ironman-machine try |
|
Hello @dora-korpar "try": Success: Try build successfully launched on 'http://ci.ironmann.io/gh/scality/Integration/21436' with the following env. args: {
"DEFAULT_BRANCH": "master",
"SCALITY_INTEGRATION_BRANCH": "ultron/master",
"REPO_NAME": "S3",
"SCALITY_S3_BRANCH": "ft/ZENKO-229-get-using-location"
} |
|
☀️ 👍 circleCI test succeeded! |
6c6a51e to
719795e
Compare
|
PR has been updated. Reviewers, please be cautious. |
719795e to
d6e8201
Compare
Do it again human slave!:point_right: :runner: (Oh and the pull request has been updated, by the way.)
|
PR has been updated. Reviewers, please be cautious. |
Adds functionality to get object from specific location by passing header 'x-amz-location-constraint'