Skip to content

Update artifact deployment process - #1906

Merged
flomotlik merged 9 commits into
masterfrom
update-artifact-deployment-process
Aug 24, 2016
Merged

flomotlik merged 9 commits into
masterfrom
update-artifact-deployment-process

Conversation

@pmuens

@pmuens pmuens commented Aug 19, 2016 •

Copy link
Copy Markdown
Contributor

This PR implements a way so that artifacts (right now the zipped service and the corresponding CloudFormation file) are uploaded to a directory (with a timestamp as a name) in S3 rather than the root directory.

This way it's possible to keep different versions of deployments and switch between different deployments (e.g. rollback could be solved with this).

Stuff todo:

  • Clean S3 bucket before deployment (only keep 5 versions)
  • Remove dead deployFunctions code
  • Remove unnecessary timestamp in zip file name (to make the filename more predictable)
  • Move getServerlessDeploymentBucketName method in deploy:deploy hook into own method
  • Make sure noDeploy still works
  • Take a look a test coverage for this new feature
  • Update docs

Corresponding issue: #1898

@flomotlik @eahefnawy would be cool if you could take a look at it!

Furthermore I'd like to know if we should implement a "keep only 5 versions" functionality or just store each and every deployment. Might pollute the S3 bucket but this way the user has the whole history of deployments.

@pmuens pmuens added this to the v1.0.0-beta.3 milestone Aug 19, 2016
@pmuens pmuens self-assigned this Aug 19, 2016
newFunction.Properties.Code
.S3Key = this.serverless.service.package.artifact.split(path.sep).pop();
.S3Key = `${this.serverless.service.package.artifactDirectoryName
}/${this.serverless.service.package.artifact.split(path.sep).pop()}`;

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.

We should not use the filename of the artefact, but create our own filename. Otherwise files might not be correctly renamed and CF won't detect an update. This also means we have more control over it

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.

My bad it actually will work as we put it into separate folders that have a date in the folder name, so everything will change. I this case this is fine for me like this

@flomotlik

Copy link
Copy Markdown
Contributor

I think we should keep the last 5 folders for now. One thing to also make sure is that --noDeploy also works in this PR still, I didn't see that in the update artefacts code yet.

@pmuens

pmuens commented Aug 19, 2016

Copy link
Copy Markdown
Contributor Author

Thanks! Will add a note about it in the todo list!

@pmuens

pmuens commented Aug 22, 2016

Copy link
Copy Markdown
Contributor Author

@flomotlik just pushed some changes and finished the implementation

@flomotlik

Copy link
Copy Markdown
Contributor

�With existing buckets it looks like it is throwing an exception. I could replicate it by uploading a random file into there:

TypeError: Cannot read property '1' of null
    at /app/lib/plugins/aws/deploy/lib/cleanupS3Bucket.js:22:70
    at Array.forEach (native)
    at /app/lib/plugins/aws/deploy/lib/cleanupS3Bucket.js:21:27
    at tryCatcher (/app/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/app/node_modules/bluebird/js/release/promise.js:504:31)
    at Promise._settlePromise (/app/node_modules/bluebird/js/release/promise.js:561:18)
    at Promise._settlePromise0 (/app/node_modules/bluebird/js/release/promise.js:606:10)
    at Promise._settlePromises (/app/node_modules/bluebird/js/release/promise.js:685:18)
    at Async._drainQueue (/app/node_modules/bluebird/js/release/async.js:138:16)
    at Async._drainQueues (/app/node_modules/bluebird/js/release/async.js:148:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/app/node_modules/bluebird/js/release/async.js:17:14)
    at tryOnImmediate (timers.js:534:15)
    at processImmediate [as _immediateCallback] (timers.js:514:5)

@flomotlik

flomotlik commented Aug 22, 2016 •

Copy link
Copy Markdown
Contributor

Deploying a Java app through the package->artefact header worked perfectly fine. Other than the bug mentioned before this works great

@pmuens

pmuens commented Aug 23, 2016

Copy link
Copy Markdown
Contributor Author

Alright. Thanks for testing it. Will look into it!

@pmuens
pmuens force-pushed the update-artifact-deployment-process branch from 0098353 to b233ee3 Compare August 23, 2016 07:06
@pmuens

pmuens commented Aug 23, 2016

Copy link
Copy Markdown
Contributor Author

@flomotlik just pushed a fix which prevents the error above.

pmuens added 6 commits August 24, 2016 11:37
So that the S3Key properties are prepended with the artifactDirectoryName.
So that it's more encapsulated and easier to test in isolation.
The timestamp is not necessary anymore as the zip file is uploaded into a timestamped
directory on S3.
@pmuens
pmuens force-pushed the update-artifact-deployment-process branch from b233ee3 to d72617d Compare August 24, 2016 09:38
@flomotlik
flomotlik merged commit 39c3305 into master Aug 24, 2016
@flomotlik
flomotlik deleted the update-artifact-deployment-process branch August 24, 2016 14:27
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.

2 participants