Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.

Conversation

@tbarlow12
Copy link
Contributor

Updates

  • Adds new rollback plugin
  • Fixes deploy list to show actual timestamp from name, which is used for rollback
  • Adds required functionality to AzureBlobStorageService and ArmService
  • Adds previously missing tests of required functionality

How to Use

  1. Get a timestamp. Use
sls deploy list

to retrieve one.
2. Roll back function app to timestamp

sls rollback -t <timestamp>

Options

In deploy section of serverless.yml, you can specify whether to run from a blob URL or deploy the package directly to the function app by setting:

deploy:
  # Default is false
  runFromBlobUrl: true|false

Resolves [AB#317]

@tbarlow12 tbarlow12 requested a review from wbreza July 4, 2019 01:54
@tbarlow12 tbarlow12 self-assigned this Jul 4, 2019
@tbarlow12 tbarlow12 requested a review from mydiemho July 4, 2019 01:58
@tbarlow12 tbarlow12 removed their assignment Jul 4, 2019
const parameterValue = deployment.parameters[key];
if (parameterValue) {
deploymentParameters[key] = { value: deployment.parameters[key] };
deploymentParameters[key] = (typeof parameterValue === "string") ? { value: parameterValue } : { value: parameterValue.value }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wbreza When I get the ARM template from the previous deployment, the parameter values look like:

{
   type: "String",
   value: "value1"
}

When I just used that object rather than extracting the value, it fails. I guess it doesn't like the type attribute for some reason. Do you have any cleaner ways for how to do this?

Copy link
Contributor

Choose a reason for hiding this comment

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

The deployTemplate(...) is called it is called with deployment params of simple key/value pairs and then converted into the final format ARM templates expect by default. What I imagine is happening is you are passing the params as already final constructed ARM params from the pre-existing deployment.

Copy link
Contributor

@wbreza wbreza left a comment

Choose a reason for hiding this comment

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

Looking good! Added a few questions and suggestions.

expect(sls.cli.log).lastCalledWith(expectedLogStatement);
});

it("lists deployments without timestamps", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would a deployment NOT have a timestamp?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think i see now - You are interpolating it from the file name - not the timestamp from the actual deployment?

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 "stamp" it when the package is being created. I wanted to use the timestamp from the deployment, but since someone "could" have the same deployment name, I'd have to scan through all deployments to check which one was most recent. It seemed more safe to just include the timestamp in the name of the deployment. I checked the response from the deployment of the resource group, and the only property included is the provisioning state

const parameterValue = deployment.parameters[key];
if (parameterValue) {
deploymentParameters[key] = { value: deployment.parameters[key] };
deploymentParameters[key] = (typeof parameterValue === "string") ? { value: parameterValue } : { value: parameterValue.value }
Copy link
Contributor

Choose a reason for hiding this comment

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

The deployTemplate(...) is called it is called with deployment params of simple key/value pairs and then converted into the final format ARM templates expect by default. What I imagine is happening is you are passing the params as already final constructed ARM params from the pre-existing deployment.

await this.uploadZippedArfifactToFunctionApp(functionApp);
await this.uploadZippedArtifactToBlobStorage();
const functionZipFile = this.getFunctionZipFile();
await this.uploadZippedArfifactToFunctionApp(functionApp, functionZipFile);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can these be done in parallel via Promise.all() ??

}

private async uploadZippedArfifactToFunctionApp(functionApp) {
public async uploadZippedArfifactToFunctionApp(functionApp: Site, functionZipFile: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why switching to public? Needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used inside the rollback service now. to re-deploy function zip to the function app

const { template } = await resourceService.getDeploymentTemplate(deployment.name);
return {
template,
parameters: deployment.properties.parameters,
Copy link
Contributor

Choose a reason for hiding this comment

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

If you convert the params back to the expected format here you can remove the special case in the ArmService that you had asked me about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will do. thanks

@tbarlow12 tbarlow12 force-pushed the tabarlow/rollback-plugin branch 2 times, most recently from 7d84091 to ce90f3f Compare July 5, 2019 21:40
Copy link
Contributor

@PIC123 PIC123 left a comment

Choose a reason for hiding this comment

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

Looks good to me! Still testing it out fully locally, and you have some conflicts that need to be resolved first, but everything seems good! Very excited to have this feature out

@tbarlow12 tbarlow12 force-pushed the tabarlow/rollback-plugin branch from ce90f3f to 057c446 Compare July 6, 2019 02:29
@tbarlow12 tbarlow12 merged commit cb1f295 into dev Jul 6, 2019
@tbarlow12 tbarlow12 deleted the tabarlow/rollback-plugin branch July 6, 2019 02:55
tbarlow12 added a commit that referenced this pull request Sep 13, 2019
## Updates
- Adds new `rollback` plugin
- Fixes `deploy list` to show actual timestamp from name, which is used for rollback
- Adds required functionality to `AzureBlobStorageService` and `ArmService`
- Adds previously missing tests of required functionality

## How to Use
1. Get a timestamp. Use
```
sls deploy list
```
to retrieve one.
2. Roll back function app to timestamp
```
sls rollback -t <timestamp>
```

## Options
In `deploy` section of `serverless.yml`, you can specify whether to run from a blob URL or deploy the package directly to the function app by setting:
```yaml
deploy:
  # Default is false
  runFromBlobUrl: true|false
```

Resolves [AB#317]
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants