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

fix(deadline): fix import and HTTPS redirect errors in stage-deadline #181

Merged
merged 3 commits into from
Oct 16, 2020

Conversation

jusiskin
Copy link
Contributor

@jusiskin jusiskin commented Oct 16, 2020

Fixes #177

Problem

There are two issues with the stage-deadline script in RFDK 0.18.0 (see #177):

1. Failed import of aws-sdk

The stage-deadline.ts file imported some code from the shared lambda directory:

import {IUris, Platform, Product, VersionProvider } from '../lib/core/lambdas/nodejs/version-provider';

This then imports from handler.ts:

Which imports from custom-resource.ts:

import { CfnRequestEvent, SimpleCustomResource } from '../lib/custom-resource';

Which imports from dynamo-backed-resource.ts:

Which imports the aws-sdk:

This causes an import error when running the command through npx since we do not specify aws-sdk in the list of dependencies for the aws-rfdk package that contains stage-deadline.

2. HTTP 301 Redirect from HTTP -> HTTPS causes abort

The VersionProvider class uses Node.JS's built-in http module to fetch the download index.

http.get(options, (res: http.IncomingMessage) => {

But, the download index is an HTTPS URL:

const productionInfoURL = 'https://downloads.thinkboxsoftware.com/version_info.json';

The http module appears to accept the https:// URL, but makes a plain-HTTP request. The response comes back as an HTTP 301 redirect. The VersionProvider handles this as an error:

if (res.statusCode === 200) {
try {
// convert the response to a json object and return.
const data = JSON.parse(json);
resolve(data);
} catch (e) {
reject(e);
}
} else {
reject(new Error(`Expected status code 200, but got ${res.statusCode}`));
}

Solution

Create a 0.18.1 patch release of RFDK that resolves the two bugs mentioned above. Each of the fix is addressed in their own commit. Summary of the changes:

1. Failed import of aws-sdk

Import the symbols directly from packages/aws-rfdk/lib/core/lambdas/nodejs/version-provider/version-provider' to avoid the import of aws-sdk`.

2. HTTP 301 Redirect from HTTP -> HTTPS causes abort

Replaced the usage of http module with https.

Patch release

Created a bump commit that increments the patch version. Also note that this pull request targets the releases/0.18.1 branch. Once this is merged, a release pipeline will be ran against this branch.

Follow-up PR(s) will be created to merge the fixing commits back to the mainline branch.

Testing

Reproduce issue using a dev build

  1. Created a new CDK application in a separate directory:

     npx cdk@1.66.0 init --language typescript
  2. Link the dev build using the link-all.sh script

    ${PATH_TO_RFDK_CHECKOUT}/link-all.sh
  3. Rename the aws-sdk directory in ${PATH_TO_RFDK_CHECKOUT}/node_modules to aws-sdk2

  4. Attempt to stage Deadline:

    npx stage-deadline
  5. Confirmed I get the reproduced error message:

    Cannot find module 'aws-sdk'
    

After fixing confirm the errors are gone and Deadline is staged

  1. Same process as above after applying the fix to my changes to my RFDK development build

  2. Confirmed no errors and Deadline is staged:

    $ tree stage
    stage
    ├── bin
    │   └── DeadlineClient-10.1.10.6-linux-x64-installer.run
    ├── deadline_docker
    ├── dlconfig
    │   ├── client-rq-connection
    │   ├── dlconfig
    │   ├── fetch_file
    │   ├── fetch_secret
    │   └── json-query
    ├── dldocker
    │   ├── commands.py
    │   ├── docker.py
    │   ├── formatters.py
    │   ├── __init__.py
    │   ├── __main__.py
    │   ├── manifest.py
    │   └── recipe.py
    ├── Dockerfile
    ├── LICENSE
    ├── license-forwarder
    │   ├── README.md
    │   └── root
    │       ├── app
    │       │   └── configure-license-forwarder.sh
    │       └── dlconfig
    │           ├── ubl-certificates
    │           ├── ubl-limits
    │           └── ubl_limits.py
    ├── manifest.json
    ├── NOTICE
    ├── rcs
    │   ├── README.md
    │   └── root
    │       ├── app
    │       │   └── configure-rcs.sh
    │       └── dlconfig
    │           ├── database-credentials
    │           ├── direct-repo-connection
    │           └── rcs-tls
    └── README.md
    
    11 directories, 29 files

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@jusiskin jusiskin added the contribution/core This is a PR that came from AWS. label Oct 16, 2020
@jusiskin jusiskin changed the title Stage deadline fix fix(deadline): fix import and HTTPS redirect errors in stage-deadline Oct 16, 2020
@jusiskin
Copy link
Contributor Author

Heads up: when merging, please don't squash the commits, since they are already written using conventional commits and one includes the bump commit that needs to be separate for our release automation.

@ddneilson ddneilson merged commit d6e880d into aws:releases/0.18.1 Oct 16, 2020
This was referenced Oct 16, 2020
@jusiskin jusiskin deleted the stage_deadline_fix branch October 28, 2020 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants