Skip to content

Improve Stage and Region Usage - #4560

Merged
HyperBrain merged 2 commits into
serverless:masterfrom
erikerikson:fix-resolve-signature-and-calls
Dec 12, 2017
Merged

HyperBrain merged 2 commits into
serverless:masterfrom
erikerikson:fix-resolve-signature-and-calls

Conversation

@erikerikson

Copy link
Copy Markdown
Contributor

What did you implement:

Centralize throughout the codebase to using the aws provider's getStage and getRegion methods.

Remove the errant (but understandable) distributed usage of region and stage settings. This otherwise locks in a multitude of bugs around the improper algorithm for selecting (given all context) the proper region or stage setting. Instead, all code should use the centralized algorithm for determining such values. This creates a strange first and second class configuration concept but these two are sufficiently varied and complex in their creation and use that this seems appropriate.

How did you implement it:

Centralize throughout the codebase to using the aws provider's getStage and getRegion methods.

How can we verify it:

verify by noting the tests continue to pass.

is there something more extensive than the unit tests that I should run in the future to verify across the cli interactions or the like?

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

Remove the errant (but understandable) distributed usage of region and stage settings.  This otherwise locks in a multitude of bugs around the improper algorithm for selecting (given all context) the proper region or stage setting.  Instead, all code should use the centralized algorithm for determining such values.  This creates a strange first and second class configuration concept but these two are sufficiently varied and complex in their creation and use that this seems appropriate.
@erikerikson

Copy link
Copy Markdown
Contributor Author

While these changes seem to be the "right" thing for the framework, there is a risk implicit that these changes could negatively impact plugins if it creates an asynchronicity between plugin's expectations of the frameworks evaluation of these values from the context and its own evaluation of them from the context (which may well be copied code from the framework). However, for the long term centralizing such algorithms (if not some time generalizing them) seems the right anti-entropy choice.

@HyperBrain HyperBrain left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A big step in the right direction!

@HyperBrain HyperBrain added this to the 1.25 milestone Dec 12, 2017
Comment thread lib/plugins/aws/rollback/index.test.js Outdated
timestamp: 1476779096930,
};
serverless.setProvider('aws', new AwsProvider(serverless));
provider = new AwsProvider(serverless);

@HyperBrain HyperBrain Dec 12, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@erikerikson The AwsProvider constructor in the tests should include the options parameter, as AwsProvider.options is evaluated to fetch the stage in getStage(). Otherwise it will default to whatever is set as default or set in serverless.config.stage or serverless.service.provider.stage.
E.g. the test options here set it to dev (which is coincidentally the default), but when setting it here to someStage it will fail, because you did not give the actual options to the constructor.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. Incoming in a moment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks like there were others (a search for new AwsProvider(serverless) uncovered them easily). Given that no tests are failing, I'll add them in the cases where an options hive is defined but will otherwise not provide the parameter. Let me know if you think I should be more aggressive on that front.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Be as aggressive as you have to be :-D
Imo, if there are explicit test options defined, they should be given to the provider.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This and others are addressed in the latest commit.

@horike37 horike37 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @erikerikson 👍
LGTM since all tests have been passed.

However, for the long term centralizing such >algorithms (if not some time generalizing them) >seems the right anti-entropy choice.

You are right. The only thing for that quite recently is that doing test
thoroughly on the master branch before next release.

Add explicit use of options where they were defined.
@erikerikson

Copy link
Copy Markdown
Contributor Author

This should be GTM unless Frank desires a more aggressive provision of option hives.

@HyperBrain

Copy link
Copy Markdown
Contributor

I'm perfectly fine with that :) The other occurences that are out of scope here can be touched when someone works there.

@HyperBrain

HyperBrain commented Dec 12, 2017 •

Copy link
Copy Markdown
Contributor

For the coverage decrease -> let's ignore that :) it seems it just uses different code branches now and draws in some files...

@HyperBrain
HyperBrain merged commit f62116c into serverless:master Dec 12, 2017
@erikerikson
erikerikson deleted the fix-resolve-signature-and-calls branch December 12, 2017 20:35
@HyperBrain

HyperBrain commented Dec 12, 2017 •

Copy link
Copy Markdown
Contributor

BTW: Coveralls seems to be drunk:
image
The merge even increased the coverage...

@erikerikson

Copy link
Copy Markdown
Contributor Author

Haha. Thanks for calling this out, the laugh was pleasant!

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.

3 participants