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

Remove not used parameters from request() and add options hive #4537

Merged
merged 2 commits into from Dec 11, 2017

Conversation

HyperBrain
Copy link
Member

@HyperBrain HyperBrain commented Dec 7, 2017

What did you implement:

There were many places were calls to provider.request() received a stage and region parameter, although these are not used since a long time anymore even if the function signature was changed too.

How did you implement it:

Removed the not-used parameters in all calls.

Additionally the new useCache parameter was too specific to be part of the signature, so I added an options object, that can be optionally given and is used as container for options that change the request method's behavior.

How can we verify it:

Todos:

  • Write tests
  • Write documentation
  • Fix linting errors
  • Make sure code coverage hasn't dropped
  • Provide verification config / commands / resources
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: YES
Is it a breaking change?: NO

@HyperBrain HyperBrain changed the title Remove not used parameters from request() and add options hive [WIP] Remove not used parameters from request() and add options hive Dec 7, 2017
@HyperBrain
Copy link
Member Author

Seems that I catched all of them.

@HyperBrain HyperBrain force-pushed the fix-resolve-signature-and-calls branch from 9f58e0e to ba7e279 Compare December 7, 2017 20:20
@HyperBrain HyperBrain changed the title [WIP] Remove not used parameters from request() and add options hive Remove not used parameters from request() and add options hive Dec 7, 2017
@tommedema
Copy link

@HyperBrain the options argument is great. Will this indeed allow me to use provider.request('S3', 'upload', ...) with a second parameter "options"?

E.g. to enable multipart uploading as per the AWS docs (this is currently not possible as provider.request only accepts 1 params object and not an options object):

provider.request('S3', 'upload', params, {
  partSize: 5 * 1024 * 1024,
  queueSize: 10
})

@HyperBrain
Copy link
Member Author

@tommedema , the options hive here is meant to configure the request execution behavior. E.g. you can set options: useCache: true to let request be cached (if the caller's use case supports that).

You specific use case for the upload is out of scope for this PR, but could be added as a second step ,either by having some options.params2 or allow params to be an array of params (in addition to the current state) for the request function.
However, I favor the array semantics, as it expresses that there can be multiple parameters passed to the request function. Options is something different and defines the local behavior rather than the behavior changes configured at the AWS SDK.

@HyperBrain
Copy link
Member Author

@horike37 This must get in now that the vars branch has been merged. It removes the wrong/stale request method signature and corrects the unit tests. Can you please review and approve, so that I can get it in?

Frank Schmid added 2 commits December 11, 2017 12:33
Delete bucket was still using them

Hopefully all :)

Further test fixes.

.... worked too long yesterday

Fixed Variable tests

Remove not used parameters from request() and add options with warning
@HyperBrain HyperBrain force-pushed the fix-resolve-signature-and-calls branch from 008c55c to e4a5a1d Compare December 11, 2017 11:34
Copy link
Member

@horike37 horike37 left a comment

Choose a reason for hiding this comment

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

Thank you for refactoring around request function @HyperBrain 👍

I tried sls deploy on this PR branch, and when enabling SLS_DEBUG, saw WARNING: Inappropriate call of provider.request error continuously as follow.

Was not this done intentionally?

$../serverless/bin/serverless deploy
Serverless: Creating Stack...
Serverless: WARNING: Inappropriate call of provider.request()
Serverless: Checking Stack create progress...
Serverless: WARNING: Inappropriate call of provider.request()
..
Serverless: WARNING: Inappropriate call of provider.request()
.
Serverless: WARNING: Inappropriate call of provider.request()
undefined
Serverless: WARNING: Inappropriate call of provider.request()
Serverless: WARNING: Inappropriate call of provider.request()
Serverless: WARNING: Inappropriate call of provider.request()
..
Serverless: Stack create finished...
Serverless: WARNING: Inappropriate call of provider.request()
Serverless: WARNING: Inappropriate call of provider.request()
Serverless: Uploading CloudFormation file to S3...
Serverless: WARNING: Inappropriate call of provider.request()
Serverless: Uploading artifacts...

@HyperBrain
Copy link
Member Author

HyperBrain commented Dec 11, 2017

@horike37 Do you have any plugin enabled?

It will log a warning if someone (a plugin) calls request with the wrong signature (including stage and region) to find misuses. However without any plugins enabled it should not log the message.

@horike37 horike37 added this to the 1.25 milestone Dec 11, 2017
@horike37
Copy link
Member

Sorry, I saw old commits. I did pull again and it works correctly 💦
I tested it with some commands which are probably affected by this fix like deploy, function deploy, remove and so on.

Then all commands work perfectly. Seems everything is good 💯
merging...

@horike37 horike37 merged commit 1fb90f6 into master Dec 11, 2017
@horike37 horike37 deleted the fix-resolve-signature-and-calls branch December 11, 2017 16:47
@erikerikson
Copy link
Member

erikerikson commented Dec 12, 2017

Sorry I didn't get a review in before this was merged but it looked good. I did have the comment that there was pending dependencies on the use of options.stage && options.region throughout the codebase. (e.g. https://github.com/serverless/serverless/blob/master/lib/plugins/aws/remove/lib/bucket.js#L7 )(another example: https://github.com/serverless/serverless/blob/master/lib/plugins/platform/platform.js#L37 - I don't understand this one and it seems AWS specific despite being not within the scope of the AWS plugin... Weird to me). However, I wanted to provide code of what I meant rather than just call it out and I delayed feedback as a result.
I have created a test and lint passing implementation of this at:
#4560

@HyperBrain
Copy link
Member Author

HyperBrain commented Dec 12, 2017

@erikerikson You're right. For the getDeploymentBucket() in aws/remove, the stage/region retrieval should be included within the function itself utilizing the central provider.getStage() and provider.getRegion() functions. For the platform plugin, it seems that I missed the wrong signature in there - however I do not know if that plugin is bound to AWS. However, the parameters in request were not used anymore for a long time - so there they had no effect at all ...

@erikerikson
Copy link
Member

Thanks for confirming. I'll add that on #4560. Hadn't been sure on scope.

medikoo added a commit to medikoo/serverless-plugin-split-stacks that referenced this pull request Jan 19, 2018
Signature of this method changed on SLS side, also those two parameters were never supported
serverless/serverless#4537
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.

None yet

4 participants