Skip to content

Commit

Permalink
Sudo execution improvements (#93)
Browse files Browse the repository at this point in the history
Sudo execution improvements
Chmod database folder when sudo
Manual Alpha publishing
Increasing baseRetryDelay and maxConnectionAttempts in rest
Updated Wallet
  • Loading branch information
fboucquez authored Dec 17, 2020
1 parent 2b64c6b commit bfb3bb4
Show file tree
Hide file tree
Showing 26 changed files with 59 additions and 57 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ node_js:
services:
- docker
env:
global:
- DEV_BRANCH=dev
- RELEASE_BRANCH=main
- POST_RELEASE_BRANCH=main
- RELEASE_MESSAGE=release
global:
- DEV_BRANCH=dev
- RELEASE_BRANCH=main
- POST_RELEASE_BRANCH=main
- RELEASE_MESSAGE=release
cache:
bundler: true
directories:
Expand Down Expand Up @@ -38,7 +38,7 @@ jobs:
if: branch = env(DEV_BRANCH) AND type = push
- name: alpha npm
script: npm pack && /bin/bash travis/node-functions.sh node_publish_alpha
if: branch = env(DEV_BRANCH) AND type = push
if: (branch = env(DEV_BRANCH) AND type = push) OR (type = api AND commit_message = alpha)
- stage: release
name: release npm
script: npm pack && /bin/bash travis/node-functions.sh node_publish_release
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,20 @@ All notable changes to this project will be documented in this file.

The changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [0.3.0] - NEXT
## [0.3.1] - Dec-17-2020

**Milestone**: Hippopotamus(0.10.0.4)

Package | Version | Link
---|---|---
Symbol Bootstrap | v0.3.1 | [symbol-bootstrap](https://www.npmjs.com/package/symbol-bootstrap)

- Allowed Bootstrap to run as sudo/root. NOT RECOMMENDED!
- Added Chmod 777 permission change to the db data folder when running as sudo/root.
- Increased Rest's DB connection attempts and retries. This avoids Rest shutting down if the DB creation takes longer.
- Updated Wallet to latest 0.13.6 release

## [0.3.0] - Dec-15-2020

**Milestone**: Hippopotamus(0.10.0.4)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ $ npm install -g symbol-bootstrap
$ symbol-bootstrap COMMAND
running command...
$ symbol-bootstrap (-v|--version|version)
symbol-bootstrap/0.3.0 linux-x64 node-v10.23.0
symbol-bootstrap/0.3.1 linux-x64 node-v12.18.4
$ symbol-bootstrap --help [COMMAND]
USAGE
$ symbol-bootstrap COMMAND
Expand Down
2 changes: 1 addition & 1 deletion docs/clean.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ EXAMPLE
$ symbol-bootstrap clean
```

_See code: [src/commands/clean.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.0/src/commands/clean.ts)_
_See code: [src/commands/clean.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.1/src/commands/clean.ts)_
2 changes: 1 addition & 1 deletion docs/compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ EXAMPLE
$ symbol-bootstrap compose
```

_See code: [src/commands/compose.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.0/src/commands/compose.ts)_
_See code: [src/commands/compose.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.1/src/commands/compose.ts)_
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ EXAMPLE
$ symbol-bootstrap config -p bootstrap
```

_See code: [src/commands/config.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.0/src/commands/config.ts)_
_See code: [src/commands/config.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.1/src/commands/config.ts)_
2 changes: 1 addition & 1 deletion docs/healthCheck.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ EXAMPLE
$ symbol-bootstrap healthCheck
```

_See code: [src/commands/healthCheck.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.0/src/commands/healthCheck.ts)_
_See code: [src/commands/healthCheck.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.1/src/commands/healthCheck.ts)_
2 changes: 1 addition & 1 deletion docs/link.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ EXAMPLE
$ symbol-bootstrap link
```

_See code: [src/commands/link.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.0/src/commands/link.ts)_
_See code: [src/commands/link.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.1/src/commands/link.ts)_
2 changes: 1 addition & 1 deletion docs/report.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ EXAMPLE
$ symbol-bootstrap report
```

_See code: [src/commands/report.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.0/src/commands/report.ts)_
_See code: [src/commands/report.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.1/src/commands/report.ts)_
2 changes: 1 addition & 1 deletion docs/resetData.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ EXAMPLE
$ symbol-bootstrap resetData
```

_See code: [src/commands/resetData.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.0/src/commands/resetData.ts)_
_See code: [src/commands/resetData.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.1/src/commands/resetData.ts)_
2 changes: 1 addition & 1 deletion docs/run.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ EXAMPLE
$ symbol-bootstrap run
```

_See code: [src/commands/run.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.0/src/commands/run.ts)_
_See code: [src/commands/run.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.1/src/commands/run.ts)_
2 changes: 1 addition & 1 deletion docs/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ EXAMPLES
$ symbol-bootstrap start -p testnet -a dual
```

_See code: [src/commands/start.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.0/src/commands/start.ts)_
_See code: [src/commands/start.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.1/src/commands/start.ts)_
2 changes: 1 addition & 1 deletion docs/stop.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ EXAMPLE
$ symbol-bootstrap stop
```

_See code: [src/commands/stop.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.0/src/commands/stop.ts)_
_See code: [src/commands/stop.ts](https://github.com/nemtech/symbol-bootstrap/blob/v0.3.1/src/commands/stop.ts)_
2 changes: 0 additions & 2 deletions presets/bootstrap/network.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ gateways:
apiNodeBrokerHost: 'api-node-broker-{{$index}}'
name: 'rest-gateway-{{$index}}'
description: 'catapult development network'
maxConnectionAttempts: 7
baseRetryDelay: 750
databaseHost: 'db-{{$index}}'
openPort: '{{add $index 3000}}'
ipv4_address: '172.20.0.{{add $index 25}}'
Expand Down
4 changes: 3 additions & 1 deletion presets/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ symbolServerToolsImage: symbolplatform/symbol-server:tools-gcc-0.10.0.4
symbolServerImage: symbolplatform/symbol-server:gcc-0.10.0.4
symbolRestImage: symbolplatform/symbol-rest:2.2.1
symbolExplorerImage: symbolplatform/symbol-explorer:0.6.3-alpha
symbolWalletImage: symbolplatform/symbol-desktop-wallet:0.13.5-alpha
symbolWalletImage: symbolplatform/symbol-desktop-wallet:0.13.6
symbolFaucetImage: symbolplatform/symbol-faucet:0.4.0
mongoImage: mongo:4.2.6-bionic
logLevel: 'Info'
Expand Down Expand Up @@ -187,6 +187,8 @@ apiNodeBrokerPort: 7902
apiNodeBrokerPortMonitorInterval: 500
apiNodeBrokerConnectTimeout: 10000
apiNodeBrokerMonitorLoggingThrottle: 60000
maxConnectionAttempts: 15
baseRetryDelay: 750

#voting
votingKeyStartEpoch: 1
Expand Down
2 changes: 0 additions & 2 deletions presets/testnet/assembly-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ gateways:
apiNodeBrokerHost: 'api-broker'
description: 'catapult public test network'
databaseHost: 'db'
maxConnectionAttempts: 5
baseRetryDelay: 500
openPort: true
ipv4_address: 172.20.0.25
2 changes: 0 additions & 2 deletions presets/testnet/assembly-dual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,5 @@ gateways:
apiNodeBrokerHost: 'api-broker'
description: 'catapult public test network'
databaseHost: 'db'
maxConnectionAttempts: 5
baseRetryDelay: 500
openPort: true
ipv4_address: 172.20.0.25
14 changes: 11 additions & 3 deletions src/service/BootstrapUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,13 @@ export class BootstrapUtils {
return BootstrapUtils.dockerUserId;
}
try {
const { stdout } = await this.exec('echo $(id -u):$(id -g)');
logger.info(`User for docker resolved: ${stdout}`);
const user = stdout.trim();
const userId = process?.getuid();
const groupId = process?.getgid();
const user = `${userId}:${groupId}`;
logger.info(`User for docker resolved: ${user}`);
if (userId === 0) {
logger.error('YOU ARE RUNNING BOOTSTRAP AS ROOT!!!! THIS IS NOT RECOMMENDED!!!');
}
BootstrapUtils.dockerUserId = user;
return user;
} catch (e) {
Expand All @@ -432,6 +436,10 @@ export class BootstrapUtils {
}
}

public static isRoot(): boolean {
return !this.isWindows() && process?.getuid() === 0;
}

public static isWindows(): boolean {
return process.platform === 'win32';
}
Expand Down
2 changes: 1 addition & 1 deletion src/service/ForgeCertificateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { BootstrapUtils } from './BootstrapUtils';
type CertificateParams = { target: string };

/**
* TODO remote if not used!
* TODO remove if not used!
*/
export class ForgeCertificateService {
constructor(protected readonly params: CertificateParams) {}
Expand Down
6 changes: 5 additions & 1 deletion src/service/RunService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { existsSync } from 'fs';
import { chmodSync, existsSync } from 'fs';
import * as _ from 'lodash';
import { join } from 'path';
import { NodeStatusEnum } from 'symbol-openapi-typescript-fetch-client';
Expand Down Expand Up @@ -217,6 +217,10 @@ export class RunService {
volumenList.map(async (v) => {
const volumenPath = join(this.params.target, `docker`, v);
if (!existsSync(volumenPath)) await BootstrapUtils.mkdir(volumenPath);
if (v.startsWith('../databases') && BootstrapUtils.isRoot()) {
logger.info(`Chmod 777 folder ${volumenPath}`);
chmodSync(volumenPath, '777');
}
}),
);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,4 @@ networks:
default:
ipam:
config:
-
subnet: 172.20.0.0/24
- subnet: 172.20.0.0/24
5 changes: 2 additions & 3 deletions test/composes/expected-docker-compose-bootstrap-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ services:
ipv4_address: 172.20.0.25
wallet-0:
container_name: wallet-0
image: 'symbolplatform/symbol-desktop-wallet:0.13.5-alpha'
image: 'symbolplatform/symbol-desktop-wallet:0.13.6'
stop_signal: SIGINT
working_dir: /symbol-workdir
ports:
Expand Down Expand Up @@ -150,5 +150,4 @@ networks:
default:
ipam:
config:
-
subnet: 172.20.0.0/24
- subnet: 172.20.0.0/24
7 changes: 3 additions & 4 deletions test/composes/expected-docker-compose-bootstrap-repeat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ services:
ipv4_address: 172.20.0.28
wallet-0:
container_name: wallet-0
image: 'symbolplatform/symbol-desktop-wallet:0.13.5-alpha'
image: 'symbolplatform/symbol-desktop-wallet:0.13.6'
stop_signal: SIGINT
working_dir: /symbol-workdir
ports:
Expand All @@ -325,7 +325,7 @@ services:
- '../wallets/wallet-0:/usr/share/nginx/html/config:ro'
wallet-1:
container_name: wallet-1
image: 'symbolplatform/symbol-desktop-wallet:0.13.5-alpha'
image: 'symbolplatform/symbol-desktop-wallet:0.13.6'
stop_signal: SIGINT
working_dir: /symbol-workdir
ports:
Expand Down Expand Up @@ -461,5 +461,4 @@ networks:
default:
ipam:
config:
-
subnet: 172.20.0.0/24
- subnet: 172.20.0.0/24
3 changes: 1 addition & 2 deletions test/composes/expected-docker-compose-bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,4 @@ networks:
default:
ipam:
config:
-
subnet: 172.20.0.0/24
- subnet: 172.20.0.0/24
3 changes: 1 addition & 2 deletions test/composes/expected-testnet-dual-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ networks:
default:
ipam:
config:
-
subnet: 172.20.0.0/24
- subnet: 172.20.0.0/24
14 changes: 0 additions & 14 deletions test/service/ConfigLoader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ describe('ConfigLoader', () => {
apiNodeBrokerHost: 'api-node-broker-{{$index}}',
name: 'rest-gateway-{{$index}}',
description: 'catapult development network',
maxConnectionAttempts: 7,
baseRetryDelay: 750,
databaseHost: 'db-{{$index}}',
openPort: true,
ipv4_address: '172.20.0.{{add $index 5}}',
Expand All @@ -95,8 +93,6 @@ describe('ConfigLoader', () => {
apiNodeBrokerHost: 'api-node-broker-0',
name: 'rest-gateway-0',
description: 'catapult development network',
maxConnectionAttempts: 7,
baseRetryDelay: 750,
databaseHost: 'db-0',
openPort: true,
ipv4_address: '172.20.0.5',
Expand All @@ -107,8 +103,6 @@ describe('ConfigLoader', () => {
apiNodeBrokerHost: 'api-node-broker-1',
name: 'rest-gateway-1',
description: 'catapult development network',
maxConnectionAttempts: 7,
baseRetryDelay: 750,
databaseHost: 'db-1',
openPort: true,
ipv4_address: '172.20.0.6',
Expand All @@ -119,8 +113,6 @@ describe('ConfigLoader', () => {
apiNodeBrokerHost: 'api-node-broker-2',
name: 'rest-gateway-2',
description: 'catapult development network',
maxConnectionAttempts: 7,
baseRetryDelay: 750,
databaseHost: 'db-2',
openPort: true,
ipv4_address: '172.20.0.7',
Expand All @@ -138,8 +130,6 @@ describe('ConfigLoader', () => {
apiNodeBrokerHost: 'api-node-broker-{{$index}}',
name: 'rest-gateway-{{$index}}',
description: 'catapult development network',
maxConnectionAttempts: 7,
baseRetryDelay: 750,
databaseHost: 'db-{{$index}}',
openPort: true,
ipv4_address: '172.20.0.{{add $index 5}}',
Expand All @@ -159,8 +149,6 @@ describe('ConfigLoader', () => {
apiNodeBrokerHost: 'api-node-broker-{{$index}}',
name: 'rest-gateway-{{$index}}',
description: 'catapult development network',
maxConnectionAttempts: 7,
baseRetryDelay: 750,
databaseHost: 'db-{{$index}}',
openPort: true,
ipv4_address: '172.20.0.{{add $index 5}}',
Expand All @@ -176,8 +164,6 @@ describe('ConfigLoader', () => {
apiNodeBrokerHost: 'api-node-broker-{{$index}}',
name: 'rest-gateway-{{$index}}',
description: 'catapult development network',
maxConnectionAttempts: 7,
baseRetryDelay: 750,
databaseHost: 'db-{{$index}}',
openPort: true,
ipv4_address: '172.20.0.{{add $index 5}}',
Expand Down

0 comments on commit bfb3bb4

Please sign in to comment.