This is a record for my work to product 3pp upgrade.
Preparation
log on a host server to build docker image and test deployment:
- log on a jump server first
- ssh e-id@seroius01502
use xxxx/xxx-compiler(cdt2 image) to build frontend
use xxx/xxx-base(node image) to build backend
Compiler (frontend, cdt2) debugging
Run upgraded cdt2+node images as a container first:
1 | $ docker run --rm -it -d --mount type=bind,src=/home/eshibij/cec-3pp-upgrade,dst=/usr/share sekidocker.rnd.ki.sw.ericsson.se/bolte/bcam/bcam-compiler:cdt_2.6.1-node_14.5 cat |
[–rm](https://blog.csdn.net/nzjdsds/article/details/8hexo 1981732): clean up
-it: wait for container cmds to be executed
-d: run in background and return container id
–mount: https://blog.csdn.net/longlong6682/article/details/104730138
cat: seems like catting the container id
other refs:
1 | $ docker ps |
1 | root@57b9f72a7d6a:/# USER=root |
1 | root@32f850a89d63:/# mkdir ~/.m2 |
The docker/settings.xml
does not exist because in real fast-test environment, all source code will be mounted to the container, here apparently no mounting step has been done. So I just make a docker
directory and copy the settings
file under it.
1 | root@32f850a89d63:/# cat > docker/settings.xml << EOF |
1 | root@32f850a89d63:/# cd coreservice/frontend |
Same reason as before, so I mounted all source codes to container (better do it before start container)
If errors like permission denied, mkdir
happens, try directly coping source code to container path. for example:
1 | [home/eshibij/cec-3pp-upgrade]$ docker cp cec <container-id>:/mnt/share |
issues
lamda-optimizer
1
2
3
4
5
6
7
8
9
10
11
12
13
14/usr/local/lib/node_modules/@uisdk/cdt-build/node_modules/lamda-optimizer/lamda-optimizer.js:25
GLOBAL.define = lamda.define;
^
ReferenceError: GLOBAL is not defined
at module.exports (/usr/local/lib/node_modules/@uisdk/cdt-build/node_modules/lamda-optimizer/lamda-optimizer.js:25:5)
at Object.executeLamda (/usr/local/lib/node_modules/@uisdk/cdt-build/tasks/compile.js:256:35)
at Object.run (/usr/local/lib/node_modules/@uisdk/cdt-build/tasks/compile.js:115:14)
at Runner.<anonymous> (/usr/local/lib/node_modules/@uisdk/cdt-build/config/runner.js:98:18)
at Runner.emit (events.js:314:20)
at Runner.<anonymous> (/usr/local/lib/node_modules/@uisdk/cdt-build/config/runner.js:72:18)
at Runner.emit (events.js:314:20)
at Runner.<anonymous> (/usr/local/lib/node_modules/@uisdk/cdt-build/config/runner.js:114:18)
at Runner.emit (events.js:314:20)
at Runner.<anonymous> (/usr/local/lib/node_modules/@uisdk/cdt-build/config/runner.js:106:18)Base (backend, node) debugging
Container is already built up in above, so just enter the source code and run compile script. It turned out no error.
Then come to the part of compile each service and run unit test. Some problems and solution during this proceed:target port is already in use
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22root@f7748a275a7a:/mnt/share/cellinfoservice# npm test
> BCAM_Cell_Info_Handler@1.0.0 test /mnt/share/cellinfoservice
> cross-env NODE_ENV=LOCAL mocha test --exit --timeout=10000
1) Uncaught error outside test suite
cell info server test
(node:2739) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
✓ /
✓ post file (100ms)
✓ upload fail
✓ get files
✓ delete files
✓ import cells (93ms)
✓ import cells with iplanet (64ms)
7 passing (440ms)
1 failing
1) Uncaught error outside test suite:
Uncaught Error: listen EADDRINUSE: address already in use :::8082
at Server.setupListenHandle [as _listen2] (net.js:1316:16)
at listenInCluster (net.js:1364:12)
at Server.listen (net.js:1450:7)
...solution: kill all node processes inside the container.
- find all processes:
docker exec <container-id> ps
the different betweendocker exec ps
anddocker top <container-id>
is that the previous one returns pid inside container, but the latter returns pid and ppid of these processes on host server. Both cmds are executed outside the target container. - enter container and kill all node processes using
kill <pid>
sample:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23[home/eshibij/cec-3pp-upgrade]$ docker exec f7748a275a7a ps
PID TTY TIME CMD
1309 ? 00:00:00 node
1331 ? 00:00:00 sh
1332 ? 00:00:00 node
1343 ? 00:00:00 node
1365 ? 00:00:00 sh
1366 ? 00:00:00 node
1377 ? 00:00:00 node
1399 ? 00:00:00 sh
1400 ? 00:00:00 node
2534 ? 00:00:00 node
2546 ? 00:00:00 sh
2547 ? 00:00:00 node
2759 ? 00:00:00 ps
[home/eshibij/cec-3pp-upgrade]$ docker exec -it f7748a275a7a bash
root@f7748a275a7a:/# kill 1309
root@f7748a275a7a:/# kill 1332
root@f7748a275a7a:/# kill 1343
...
[home/eshibij/cec-3pp-upgrade]$ docker exec f7748a275a7a ps
PID TTY TIME CMD
2779 ? 00:00:00 psRe-enter and run
npm test
to check unit test for each part:1
2
3
4
5
6
7
8
9
10
11
12
13
14root@f7748a275a7a:/mnt/share/cellinfoservice# npm test
> BCAM_Cell_Info_Handler@1.0.0 test /mnt/share/cellinfoservice
> cross-env NODE_ENV=LOCAL mocha test --exit --timeout=10000
cell info server test
(node:2815) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
✓ /
✓ post file (88ms)
✓ upload fail
✓ get files
✓ delete files
✓ import cells (78ms)
✓ import cells with iplanet (53ms)
7 passing (388ms)- find all processes:
cross-env: Permission denied
error code:1
2
3
4
5root@f7748a275a7a:/mnt/share/coreservice/backend# npm test
> BCAM_Backend_Handler@1.0.0 test /mnt/share/coreservice/backend
> cross-env NODE_ENV=LOCAL mocha test --exit --timeout=10000
sh: 1: cross-env: Permission denied
npm ERR! Test failed. See above for more detailssolution: rebuild and run test again
1
$ npm rebuild
local test failed due to
"before all" hook
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16root@f7748a275a7a:/mnt/share/coreservice/backend# npm test
> BCAM_Backend_Handler@1.0.0 test /mnt/share/coreservice/backend
> cross-env NODE_ENV=LOCAL mocha test --exit --timeout=10000
sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators node_modules/sequelize/lib/sequelize.js:245:13
#model.js
#Cell test()
1) "before all" hook
#ENMJobtest.js
2) "before all" hook: create ENMJobTest Datas
3) "after all" hook
#ENodeBTest.js
#ENodeB test()
4) "before all" hook: create ENodeBTest Datas
#model.js
#MbsArea test()
5) "before all" hookIt happened due to no local db was found by the test procedures, create postgre db using image
postgres:12.3-alpine
with1
$ docker run --name bcamdb -e POSTGRES_PASSWORD=bcam -p5432:5432 -d postgres:12.3-alpine
Enter the db and get its local address:
1
2
3
4
5
6
7
8
9bash-5.0# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
14468: eth0@if14469: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP
link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
valid_lft forever preferred_lft foreverRe-enter to backend container and ping the address to test connection:
1
2
3
4
5
6
7root@f7748a275a7a:/# ping 172.17.0.2
PING 172.17.0.2 (172.17.0.2) 56(84) bytes of data.
64 bytes from 172.17.0.2: icmp_seq=1 ttl=64 time=0.067 ms
64 bytes from 172.17.0.2: icmp_seq=2 ttl=64 time=0.050 ms
^C
--- 172.17.0.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999msre-write the backend env file
application-default.yml
andapplication-local.yml
, retry and still failed.- check if connection is able to be built:no error throw out, so request to can be sent to db container
1
$ >/dev/tcp/172.17.0.2/5432
- other debug:
&
means running in background, also can be added afternpm test &
, here I tried to do package capture but failedcheck process in running and kill process:1
2$ apt install tcpdump
$ tcpdump -i any port 5432 &1
2
3
4$ ps -ef
$ pkill npm
$ pkill node
$ pkill node npm - logon the default postgre: It is the issue concerning with
1
2$ su - postgres
ddacfbb38c89:~$ psqlpg
module: https://github.com/brianc/node-postgres/issues/2170
update the version of pg to v8.0.3 or above solved this problem.
updated solution
use--net
to attach your container directly to the host’s network interfaces.1
$ docker run --name <container-name> -e POSTGRES_PASSWORD=postgres --net=container:<target-container-id> -d <image-name>:<tag>
backend 3pp upgrade
For upgrade part, firstly get to know https://docs.npmjs.com/cli/update and https://docs.npmjs.com/cli/install
other refs:- check if connection is able to be built:
- https://stackoverflow.com/questions/43127863/node-update-a-specific-package
- https://stackoverflow.com/questions/16073603/how-do-i-update-each-dependency-in-package-json-to-the-latest-version
- https://stackoverflow.com/questions/15890958/how-to-install-a-previous-exact-version-of-a-npm-package
Update step:
update
package.json
file with given versionsrun
npm install
to update package in./node_modules
run
npm test
for all UTs or addonly
beforeit
to run a single test like:1
/mnt/share/coreservice/backend $ npm test /test/CellTest.js -- -t "#Cell test()"
Handle errors
- port is in use:for case that
1
21) Uncaught error outside test suite:
Uncaught Error: listen EADDRINUSE: address already in use :::8083netstat
is not installed, usess -lp
instead to check port:1
2
3
4root@f7748a275a7a:/mnt/share/enmservice# natstat -ano |grep 8083
bash: natstat: command not found
root@f7748a275a7a:/mnt/share/enmservice# ss -lp |grep 8083
tcp LISTEN 0 128 :::8083 :::* users:(("node",pid=7662,fd=21))ss
is auto-defined as “another utility to investigate sockets”. For more information you can usess --help
orman ss
1
$ kill 7662
- package
connect-multiparty
not compatible with node v14.
ref: https://github.com/expressjs/connect-multiparty/issues/29
change to libmultiparty
or update node version to v14.6.0
- port is in use:
- Error: EPERM: operation not permitted, unlink ‘C:\work\cec\saiservice\node_modules.staging\semver-9c480dbf\README.md’
This usually occurs when the network connection is not stable. thx to https://blog.csdn.net/SilenceJude/article/details/101196261
Solution:- delete
node_modules
folder in related package - npm install again
- if not work,
npm cache clean -f
before installing
- delete