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

Deploy v0.9.6 to v0.9.7 to DEV without loosing blockchain contents #82

Closed
joaoluis-pdm opened this issue Jun 23, 2022 · 2 comments
Closed
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@joaoluis-pdm
Copy link
Contributor

joaoluis-pdm commented Jun 23, 2022

Pre-requirements: the tag is created and pushed into master. master points to v0.9.7. blockchain-hf-workspace is running on DEV.

Removing locally built docker images, but not local external volumes.

pharmaledger@fgt-dev-pl:~/fgt-workspace/docker/api$ docker-compose down --rmi local
WARNING: The SIMPLE variable is not set. Defaulting to a blank string.
WARNING: The DOMAIN variable is not set. Defaulting to a blank string.
WARNING: The PROTOCOL variable is not set. Defaulting to a blank string.
WARNING: The SWAGGER variable is not set. Defaulting to a blank string.
Stopping pha-zuellig       ... done
Stopping pha1              ... done
Stopping pha2              ... done
Stopping whs2              ... done
Stopping whs-takeda        ... done
Stopping whs1              ... done
Stopping mah-pfizer        ... done
Stopping mah-bayer         ... done
Stopping mah-sanofi        ... done
Stopping mah-novo-nordisk  ... done
Stopping mah-takeda        ... done
Stopping mah-msd           ... done
Stopping mah-gsk           ... done
Stopping mah-roche         ... done
Stopping fgt-workspace     ... done
Stopping traefik-logrotate ... done
Stopping traefik           ... done
Removing pha-zuellig       ... done
Removing pha1              ... done
Removing pha2              ... done
Removing whs2              ... done
Removing whs-takeda        ... done
Removing whs1              ... done
Removing mah-pfizer        ... done
Removing mah-bayer         ... done
Removing mah-sanofi        ... done
Removing mah-novo-nordisk  ... done
Removing mah-takeda        ... done
Removing mah-msd           ... done
Removing mah-gsk           ... done
Removing mah-roche         ... done
Removing fgt-workspace     ... done
Removing traefik-logrotate ... done
Removing traefik           ... done
Removing network traceability-net
Removing network api_default
Removing image api_fgt-workspace
Removing image api_mah-roche
Removing image api_mah-bayer
Removing image api_mah-gsk
Removing image api_mah-msd
Removing image api_mah-novo-nordisk
Removing image api_mah-pfizer
Removing image api_mah-takeda
Removing image api_mah-sanofi
Removing image api_whs-1
Removing image api_whs-2
Removing image api_whs-takeda
Removing image api_pha-1
Removing image api_pha-2
Removing image api_pha-zuellig

pharmaledger@fgt-dev-pl:~/fgt-workspace/docker/api$ git pull

pharmaledger@fgt-dev-pl:~/fgt-workspace/docker/api$ ./bootCompose.sh eth-dev
@joaoluis-pdm joaoluis-pdm added the documentation Improvements or additions to documentation label Jun 23, 2022
@joaoluis-pdm joaoluis-pdm self-assigned this Jun 23, 2022
@joaoluis-pdm
Copy link
Contributor Author

joaoluis-pdm commented Jun 23, 2022

bootCompose is failing in building fgt-workspace:

pharmaledger@fgt-dev-pl:~$ docker logs --timestamps -f fgt-workspace 2>&1 | less 

2022-06-23T09:37:13.055343735Z rm: can't remove 'apihub-root/external-volume/config/domains/traceability.json': Permission denied
2022-06-23T09:37:13.055379845Z rm: can't remove 'apihub-root/external-volume/config/domains/predefined.json': Permission denied
2022-06-23T09:37:13.055382685Z rm: can't remove 'apihub-root/external-volume/config/domains/epi.json': Permission denied
2022-06-23T09:37:13.055384765Z rm: can't remove 'apihub-root/external-volume/config/domains/vault.json': Permission denied
2022-06-23T09:37:13.055386805Z rm: can't remove 'apihub-root/external-volume/config/domains/default.json': Permission denied
2022-06-23T09:37:13.055388805Z rm: can't remove 'apihub-root/external-volume/config/apihub.json': Permission denied
2022-06-23T09:37:13.055390755Z rm: can't remove 'apihub-root/external-volume/config/bdns.hosts': Permission denied
2022-06-23T09:37:13.055737408Z cp: can't create directory 'apihub-root/external-volume/config/config': Permission denied
2022-06-23T09:37:13.361406464Z 
2022-06-23T09:37:13.361423334Z > [email protected] switch-to-test-chain
2022-06-23T09:37:13.361439934Z > node ./node_modules/octopus/scripts/setEnv --file=../../../env.json "node ./node_modules/octopus/scripts/run switch-
to-test-chain"
2022-06-23T09:37:13.361443054Z 
2022-06-23T09:37:13.396593928Z Running in STABLE (FREEZED) mode
2022-06-23T09:37:13.397976999Z Environment updated accordingly to env file passed as argument.
2022-06-23T09:37:13.398071190Z Preparing to execute cmd node ./node_modules/octopus/scripts/run switch-to-test-chain
2022-06-23T09:37:13.432212896Z Looking for configuration file at path /fgt-workspace/octopus-freeze.json
2022-06-23T09:37:13.449083738Z Action buildWebCardinalComponents was registered.
2022-06-23T09:37:13.449646782Z [Octopus] Start checking switch-to-test-chain...
2022-06-23T09:37:13.449654532Z [Octopus] Found 1 switch-to-test-chain...
2022-06-23T09:37:13.449733573Z [Octopus] Running tasks for: [0] Switch apihub configs to a local test blockchain. Apihub needs restart.
2022-06-23T09:37:13.450083036Z Start copying ./blockchain-patch/apply/external-volume to folder ./apihub-root/external-volume
2022-06-23T09:37:13.455920871Z /fgt-workspace/node_modules/octopus/scripts/run.js:22
2022-06-23T09:37:13.455933211Z     throw err;
2022-06-23T09:37:13.455935561Z     ^
2022-06-23T09:37:13.455937481Z 
2022-06-23T09:37:13.455939421Z Error: EACCES: permission denied, open '/fgt-workspace/apihub-root/external-volume/config/domains/traceability.json'
2022-06-23T09:37:13.455941811Z     at Object.openSync (node:fs:585:3)
2022-06-23T09:37:13.455943721Z     at Object.writeFileSync (node:fs:2157:35)
2022-06-23T09:37:13.455945601Z     at __copyFile (/fgt-workspace/node_modules/octopus/lib/utils/FSExtension.js:168:16)
2022-06-23T09:37:13.455947611Z     at __copyDir (/fgt-workspace/node_modules/octopus/lib/utils/FSExtension.js:135:17)
2022-06-23T09:37:13.455949531Z     at __copyDir (/fgt-workspace/node_modules/octopus/lib/utils/FSExtension.js:130:17)
2022-06-23T09:37:13.455962051Z     at __copyDir (/fgt-workspace/node_modules/octopus/lib/utils/FSExtension.js:130:17)
2022-06-23T09:37:13.455964141Z     at Object.__copy [as copy] (/fgt-workspace/node_modules/octopus/lib/utils/FSExtension.js:89:17)
2022-06-23T09:37:13.455967611Z     at Object.ActionsRegistry.actions.copy (/fgt-workspace/node_modules/octopus/ActionsRegistry.js:701:19)
2022-06-23T09:37:13.455969611Z     at wrapper (/fgt-workspace/node_modules/octopus/ActionsRegistry.js:909:30)
2022-06-23T09:37:13.455971531Z     at __runAction (/fgt-workspace/node_modules/octopus/Runner.js:259:13) {
2022-06-23T09:37:13.455973401Z   errno: -13,
...

This error is due to the introduction of the "node" user best-practice, while the external volumes where created before that practice was introduced.

Aborted bootCompose.sh

pharmaledger@fgt-dev-pl:~/fgt-workspace/docker/api$ docker-compose down --rmi local

root@fgt-dev-pl:~# ls -l /var/lib/docker/volumes/api_traceability_vol/_data
total 12
drwxr-xr-x 3 root root 4096 May 17 12:30 config
drwxr-xr-x 5 root root 4096 May 17 12:31 domains
-rw-r--r-- 1 root root   57 May 16 19:28 read.me

# 1000 is the UID and GID of user "node".

root@fgt-dev-pl:~# chown -R 1000:1000 /var/lib/docker/volumes/api_traceability_vol/_data
root@fgt-dev-pl:~# chown -R 1000:1000 /var/lib/docker/volumes/api_*_vol/_data

# UID 1000 will map to user techsupport, and GID to group techsupport in PDM environment

pharmaledger@fgt-dev-pl:~/fgt-workspace/docker/api$ ./bootCompose.sh eth-dev

Run a full test, from a laptop:

jpsl@PDM-00781:/export/home/jpsl/develop/PharmaLedger/fgt-workspace/bin/environment$ node --unhandled-rejections=strict wsCreateStuff.js --env=dev --sleep=80000 2>&1 | tee -a wsCreateDevKeepBC.log
...
https POST {"path":"/traceability/sale/create","method":"POST","headers":{"content-type":"application/json","content-length":141,"Authorization":"Basic UEhBMDAwMDAxOlRoaXMxc1N1Y2hBUzNjdXJlUGFzc3cwcmQ="},"hostname":"api-pha1-fgt-dev.pharmaledger.pdmfc.com","port":"443"} {"id":"PHA000001-2022-06-23T11:01:32.335Z","productList":[{"gtin":"00366582505358","batchNumber":"R034995","serialNumber":"46418548939454"}]}
res 6115ms {
  status: 400,
  error: 'Bad Request',
  message: 'Product gtin 00366582505358, batch R034995: is not available for sale, because batchStatus is recall. '
}
/export/home/jpsl/develop/PharmaLedger/fgt-workspace/bin/environment/wsCreateStuff.js:741
            throw new Error("sale/create "+batch.batchNumber+" at "+sellerActor.id.secret+" reply has no productList: "+JSON.stringify(resSale));
                  ^

Error: sale/create R034995 at PHA000001 reply has no productList: {"status":400,"error":"Bad Request","message":"Product gtin 00366582505358, batch R034995: is not available for sale, because batchStatus is recall. "}
    at salesCreateTest (/export/home/jpsl/develop/PharmaLedger/fgt-workspace/bin/environment/wsCreateStuff.js:741:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async salesCreate (/export/home/jpsl/develop/PharmaLedger/fgt-workspace/bin/environment/wsCreateStuff.js:755:9)
    at async /export/home/jpsl/develop/PharmaLedger/fgt-workspace/bin/environment/wsCreateStuff.js:833:5

The result is correct, as the batch R034995 was previously recalled in DEV, and the system does not allow /sale/create of recalled items. (Previous shipments where successful!)

SUCCESS! Code was updated from v0.9.6 to v0.9.7 and BC anchoring and bricking data was preserved.

@joaoluis-pdm
Copy link
Contributor Author

PS: Just a side note: Deployment of v0.9.7 on TST was done with external volume removal.

pharmaledger@fgt-tst-pl:~/fgt-workspace/docker/api$ docker-compose down -v --rmi local
pharmaledger@fgt-dev-pl:~/fgt-workspace/docker/api$ ./bootCompose.sh tst

The permissions of the files on the external volume look like:

root@fgt-tst-pl:~# ls -l /var/lib/docker/volumes/api_*_vol/_data
/var/lib/docker/volumes/api_mah-bayer_vol/_data:
total 12
drwxr-xr-x 3 techsupport techsupport 4096 Jun 23 11:03 config
drwxr-xr-x 4 techsupport techsupport 4096 Jun 23 11:03 domains
-rw-r--r-- 1 techsupport root          57 Jun 23 10:50 read.me
...
root@fgt-tst-pl:~# ls -l /var/lib/docker/volumes/api_mah-bayer_vol/_data/domains/vault/anchors/
total 32
-rw-r--r-- 1 techsupport techsupport    85 Jun 23 11:03 7saRdSm81FqYLzhW8xB5TD77WKFiQBZVgs9tEZZJhC17TY6ri7uah4pnnJaHuekp6VMS9L1cDuSJGefugmhfd
...

Note that the read.me is from the root group, and not from the techsupport (gid=1000) group. But all child folders and child folder files have ownership techsupport:techsupport.

This is not the case in DEV due to the chown... But should only be a problem if the read.me needs to be changed by the container. Closing the issue anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant