Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

Long time to deploy the pipeline #60

Open
s1mrankaur opened this issue Mar 15, 2021 · 10 comments
Open

Long time to deploy the pipeline #60

s1mrankaur opened this issue Mar 15, 2021 · 10 comments
Labels
question Further information is requested

Comments

@s1mrankaur
Copy link

It takes a fairly long time (About 6-8 minutes( to deploy on making a change of 1 line of code as well. Is there a way around it?

@srijitm srijitm added the question Further information is requested label Mar 15, 2021
@srijitm
Copy link
Contributor

srijitm commented Mar 15, 2021

@s1mrankaur Is that for the entire pipeline or just the deploy stage?

You can try and assign more CPU/Memory to the CodeBuild job: https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-compute-types.html

@s1mrankaur
Copy link
Author

@srijitm Deploy stage: The command I am running is:

cdk deploy --all --profile profile-name

@srijitm
Copy link
Contributor

srijitm commented Mar 15, 2021

Remove the --all and include only the stack you want to deploy.

@s1mrankaur
Copy link
Author

@srijitm Is there a way for it to automatically detect what stack should be deployed?

@srijitm
Copy link
Contributor

srijitm commented Mar 15, 2021

No.

Cloudformation (and therefore CDK) only pushes the changes anyways. However, it may take some time for it to do the diff.

@s1mrankaur
Copy link
Author

That explains it. Thank you

@s1mrankaur
Copy link
Author

Also, I have a question related to issue #61 . Does npm install command need to be run in all the scripts i.e build.sh, deploy.sh and test.sh ? lerna run commands seem to be running okay in build.sh where the npm install command runs but throws MODULE_NOT_FOUND errr in deploy.sh and test.sh @srijitm

@srijitm
Copy link
Contributor

srijitm commented Mar 15, 2021

You should take a look and see if everything is being packaged correctly (can probably run the ls -al command to check). Also take a look at how lerna includes the node_modules (whether they are symlinks, relative links etc). Fully qualified symlinks will likely not work because the CODEBUILD_SRC_DIR changes between the stages. Running npm install might be the easiest thing to do but that will increase execution time.

@s1mrankaur
Copy link
Author

s1mrankaur commented Mar 15, 2021

@srijitm lerna created symlinks but I tried adding npm install in each of the 3 shell scripts i.e test.sh, build.sh and deploy.sh but still am getting the error in test.sh and deploy.sh

I did run npm install in test.sh as well,

but it still failed. while the same command runs just fine in build.sh

So here's what my build.sh looks like:

#! /bin/bash

set -e
set -u
set -o pipefail

echo "Building services..................!"
npm install
npm run test
echo "Build completed..................!"

Here's what my test.sh looks like:

#! /bin/bash

set -e
set -u
set -o pipefail

echo "Running tests...........................!"
npm install
npm run test
echo "Tests completed.........................!"

The build stage completed okay, and the test stage throws this error:


> [email protected] postinstall
--
66 | > lerna bootstrap
67 |  
68 | internal/modules/cjs/loader.js:834
69 | throw err;
70 | ^
71 |  
72 | Error: Cannot find module '.'
73 | Require stack:
74 | - /codebuild/output/src188079499/src/node_modules/.bin/lerna
75 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:831:15)
76 | at Function.Module._load (internal/modules/cjs/loader.js:687:27)
77 | at Module.require (internal/modules/cjs/loader.js:903:19)
78 | at require (internal/modules/cjs/helpers.js:74:18)
79 | at Object.<anonymous> (/codebuild/output/src188079499/src/node_modules/.bin/lerna:11:3)
80 | at Module._compile (internal/modules/cjs/loader.js:1015:30)
81 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
82 | at Module.load (internal/modules/cjs/loader.js:879:32)
83 | at Function.Module._load (internal/modules/cjs/loader.js:724:14)
84 | at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
85 | code: 'MODULE_NOT_FOUND',
86 | requireStack: [ '/codebuild/output/src188079499/src/node_modules/.bin/lerna' ]
87 | }
88 | npm ERR! code 1
89 | npm ERR! path /codebuild/output/src188079499/src
90 | npm ERR! command failed
91 | npm ERR! command sh -c lerna bootstrap
92 |  
93 | npm ERR! A complete log of this run can be found in:
94 | npm ERR!     /root/.npm/_logs/2021-03-15T23_15_26_005Z-debug.log
95 |  
96 | [Container] 2021/03/15 23:15:26 Command did not exit successfully bash ${CODEBUILD_SRC_DIR}/scripts/test.sh exit status 1
97 | [Container] 2021/03/15 23:15:26 Phase complete: BUILD State: FAILED
98 | [Container] 2021/03/15 23:15:26 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: bash ${CODEBUILD_SRC_DIR}/scripts/test.sh. Reason: exit status 1
99 | [Container] 2021/03/15 23:15:26 Entering phase POST_BUILD
100 | [Container] 2021/03/15 23:15:26 Phase complete: POST_BUILD State: SUCCEEDED
101 | [Container] 2021/03/15 23:15:26 Phase context status code:  Message:
102 | [Container] 2021/03/15 23:15:26 Expanding base directory path: .
103 | [Container] 2021/03/15 23:15:26 Assembling file list
104 | [Container] 2021/03/15 23:15:26 Expanding .
105 | [Container] 2021/03/15 23:15:26 Expanding file paths for base directory .
106 | [Container] 2021/03/15 23:15:26 Assembling file list
107 | [Container] 2021/03/15 23:15:26 Expanding **/*
108 | [Container] 2021/03/15 23:15:26 Found 34591 file(s)
109 | [Container] 2021/03/15 23:15:35 Phase complete: UPLOAD_ARTIFACTS State: SUCCEEDED
110 | [Container] 2021/03/15 23:15:35 Phase context status code:  Message:
111 |  



@srijitm

@s1mrankaur
Copy link
Author

@srijitm If it's relevant, I needed the pipeline to use node runtime 15, so I had added following in

1.tets-project.js
2. deploy-project.ts
3. build-project.ts


          install: {
            commands: [
              'npm install npm@latest -g',
              'npm install lerna@latest -g'
            ]
          },

and removed:


        phases: {
          install: {
            'runtime-versions': {
              nodejs: '10'
            }
          },

Please let me know if that's not right or could be causing the issue. 


Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants