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

rf: azure location config, use account / key #968

Merged
merged 1 commit into from
Oct 31, 2017

Conversation

electrachong
Copy link
Contributor

@electrachong electrachong commented Oct 27, 2017

No description provided.

lib/Config.js Outdated
}
});
assert(azureContainerName, 'bad location constraint: ' +
`"${location}" azureContainerName must be defined`);

Choose a reason for hiding this comment

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

This would assert false if locationObj.details.azureContainerName was defined as something falsy. I don't know why someone would set their config that way, but I guess it's possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made it more explicit to check if it is actually undefined and added some checks to make sure it is a string. The isValidBucketName function will check for length (make sure it's not an empty string)

},
'/should not throw for a valid azure location constraint/');
});
it('should throw error for if type is azure and azureContainerName is ' +

Choose a reason for hiding this comment

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

for if if

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, updated those

@ironman-machine ironman-machine dismissed bennettbuchanan’s stale review October 27, 2017 20:01

Do it again human slave!:point_right: :runner: (Oh and the pull request has been updated, by the way.)

@ironman-machine
Copy link
Contributor

PR has been updated. Reviewers, please be cautious.

@ironman-machine
Copy link
Contributor

CONFLICT (add/add): Merge conflict in tests/unit/testConfigs/locConstraintAssert.js
CONFLICT (add/add): Merge conflict in tests/locationConfigTests.json
CONFLICT (add/add): Merge conflict in tests/functional/aws-node-sdk/test/multipleBackend/utils.js
CONFLICT (add/add): Merge conflict in lib/data/locationConstraintParser.js
CONFLICT (add/add): Merge conflict in lib/data/external/AzureClient.js
CONFLICT (add/add): Merge conflict in lib/Config.js
CONFLICT (add/add): Merge conflict in constants.js

constants.js Outdated
@@ -111,6 +111,10 @@ const constants = {
mpuMDStoredExternallyBackend: { aws_s3: true },
/* eslint-enable camelcase */
mpuMDStoredOnS3Backend: { azure: true },
azureAccountNameRegex: /^[a-z0-9]{3,24}$/,
azureAccessKeyRegex:
new RegExp('^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==' +
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a regular base64 validation regexp, could it be shared in a more generic base64Regex constant? (ideally in Arsenal but not worth a PR just for this), then azureAccessKeyRegex can point to it.

Also you may shorten it by removing the last |[A-Za-z0-9+/]{4} and make the trailer match block optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we can just use the general base64Regex for the azureAccessKey check then.
Thanks for the tip

lib/Config.js Outdated
if (!locationConstraintDest) {
return true;
}
const accountNames = [locationConstraintSrc, locationConstraintDest]
Copy link
Contributor

Choose a reason for hiding this comment

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

style: for a simple comparison, I think calling twice getAzureStorageAccountName and comparing the results would be more straigthtforward than relying on a map.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true, I updated it

azureBlobSAS = process.env[`${azureLocation}_AZURE_BLOB_SAS`];
isTestingAzure = true;
} else if (config.locationConstraints[azureLocation] &&
const isTestingAzure = Object.keys(envMap).every(key => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can just rely on azureStorageAccountName presence, since an azure test would not make sense without the access key set as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We also create the blobservice client below, and we need to get the azureStorageAccessKey (stored in params in the every step) for that.

this._client = azure.createBlobService(
this._azureStorageCredentials.storageAccountName,
this._azureStorageCredentials.storageAccessKey);
this._azureStorageEndpoint = this._client.host.primaryHost;
Copy link
Contributor

Choose a reason for hiding this comment

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

are we relying on a documented property of the azure node sdk here? do they have a method for the endpoint? is this the best way to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't seem documented, they also don't have a method (they just access the StorageServiceClient.host.primaryHost property to get the value when sending a request). Maybe it's safest to require the blob endpoint explicitly again?

Copy link
Contributor

Choose a reason for hiding this comment

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

do you have to tell the client the endpoint? since it has this primary concept loaded, why do you need to tell it what it knows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we don't need it for the blob storage client, there is so far one case where we use it:
for the copy source uri https://github.com/scality/S3/pull/968/files#diff-96a8cd65c80ea7fb9b908a81388494d4R366
We always use a put object if copying from one account to another (instead of copy object) so the storage endpoint for the copy source uri should be the same as the destination endpoint

@@ -74,11 +75,12 @@ function parseLC() {
clients[location].clientType = 'aws_s3';
}
if (locationObj.type === 'azure') {
const azureBlobEndpoint = config.getAzureEndpoint(location);
const azureBlobSAS = config.getAzureBlobSas(location);
assert(locationObj.details, 'bad location constraint: details ' +
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this assertion here rather than in config.js?

@electrachong electrachong force-pushed the rf/azureCredentials branch 3 times, most recently from f3b8d03 to f774bae Compare October 30, 2017 19:33
@electrachong
Copy link
Contributor Author

@ironman-machine try

@ironman-machine
Copy link
Contributor

Hello @electrachong

"try": Success: Try build successfully launched on 'http://ci.ironmann.io/gh/scality/Integration/16555' with the following env. args:

{
    "SCALITY_INTEGRATION_BRANCH": "ultron/master",
    "REPO_NAME": "S3",
    "DEFAULT_BRANCH": "master",
    "SCALITY_S3_BRANCH": "rf/azureCredentials"
}

@ironman-machine
Copy link
Contributor

💔 ☔ circleCI test failed.

@electrachong
Copy link
Contributor Author

electrachong commented Oct 30, 2017

end to end retried here: http://ci.ironmann.io/gh/scality/Integration/16559
and here: http://ci.ironmann.io/gh/scality/Integration/16562
and here: http://ci.ironmann.io/gh/scality/Integration/16571
for all three above, tests failed due to replication flakiness

@electrachong
Copy link
Contributor Author

@ironman-machine try

@ironman-machine
Copy link
Contributor

Hello @electrachong

"try": Success: Try build successfully launched on 'http://ci.ironmann.io/gh/scality/Integration/16611' with the following env. args:

{
    "SCALITY_INTEGRATION_BRANCH": "ultron/master",
    "REPO_NAME": "S3",
    "DEFAULT_BRANCH": "master",
    "SCALITY_S3_BRANCH": "rf/azureCredentials"
}

@ironman-machine
Copy link
Contributor

☀️ 👍 circleCI test succeeded!

@LaurenSpiegel LaurenSpiegel merged commit d2ff4e0 into master Oct 31, 2017
@LaurenSpiegel LaurenSpiegel deleted the rf/azureCredentials branch October 31, 2017 19:56
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.

6 participants