From c698e4c8fc71f3a334bf546dce8d1994c2a68adf Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Sun, 5 Jul 2020 12:52:40 -0600 Subject: [PATCH 1/2] fix: remove controller ag-solo, as it is obsolete --- .../roles/fetch-controller/tasks/main.yml | 2 +- .../roles/init-controller/tasks/main.yml | 37 ++++++----- .../ansible/roles/init-cosmos/tasks/main.yml | 5 -- .../ansible/roles/start/tasks/main.yml | 3 +- .../ansible/roles/stop/tasks/main.yml | 3 +- packages/deployment/main.js | 61 +------------------ 6 files changed, 21 insertions(+), 90 deletions(-) diff --git a/packages/deployment/ansible/roles/fetch-controller/tasks/main.yml b/packages/deployment/ansible/roles/fetch-controller/tasks/main.yml index 14ade7cdabf..8c0d0eb3d1e 100644 --- a/packages/deployment/ansible/roles/fetch-controller/tasks/main.yml +++ b/packages/deployment/ansible/roles/fetch-controller/tasks/main.yml @@ -2,4 +2,4 @@ fetch: dest: "{{ data | default(service + '/data') }}/{{ inventory_hostname }}/boot-address.txt" flat: yes - src: "/home/{{ service }}/controller/ag-cosmos-helper-address" + src: "/home/{{ service }}/.{{ service }}/ag-cosmos-helper-address" diff --git a/packages/deployment/ansible/roles/init-controller/tasks/main.yml b/packages/deployment/ansible/roles/init-controller/tasks/main.yml index 42508bc303d..a1c343f690c 100644 --- a/packages/deployment/ansible/roles/init-controller/tasks/main.yml +++ b/packages/deployment/ansible/roles/init-controller/tasks/main.yml @@ -1,18 +1,3 @@ -- name: Synchronize vat directory - synchronize: - src: "{{ APPDIR }}/lib/ag-solo/vats/" - dest: /usr/src/ag-solo/lib/ag-solo/vats/ - dirs: yes - delete: yes - mode: push - -- name: "Initialize {{ service }}" - become: yes - become_user: "{{ service }}" - shell: - cmd: "rm -rf controller && ag-solo init controller" - chdir: "/home/{{ service }}" - - name: "Ensure /home/{{ service }}/.ag-pserver/wwwroot/{{ CHAIN_NAME }} exists" become: yes become_user: "{{ service }}" @@ -20,10 +5,22 @@ path: "/home/{{ service }}/.ag-pserver/wwwroot/{{ CHAIN_NAME }}" state: directory -- name: "Clone ag-cosmos-helper-statedir to pserver" +- name: "Create provisioning mnemonic" + delegate_to: localhost + shell: + cmd: "ag-cosmos-helper keys mnemonic | tee provisioning-mnemonic.txt" + register: mnemonic + +- name: "Create {{ service }} ag-solo key" + become: yes + become_user: "{{ service }}" + shell: + cmd: "ag-cosmos-helper --home=.{{ service }}/ag-cosmos-helper-statedir --keyring-backend=test keys add ag-solo" + stdin: "{{ mnemonic.stdout_lines }}" + +- name: "Create ag-cosmos-helper-address" become: yes become_user: "{{ service }}" - delegate_to: "{{ inventory_hostname }}" - synchronize: - src: "/home/{{ service }}/controller/ag-cosmos-helper-statedir/" - dest: "/home/{{ service }}/.ag-pserver/ag-cosmos-helper-statedir/" + shell: + cmd: "ag-cosmos-helper --home=.{{ service }}/ag-cosmos-helper-statedir \ + --keyring-backend=test keys show -a ag-solo > .{{ service }}/ag-cosmos-helper-address" diff --git a/packages/deployment/ansible/roles/init-cosmos/tasks/main.yml b/packages/deployment/ansible/roles/init-cosmos/tasks/main.yml index 7a671d4b991..815443b04f8 100644 --- a/packages/deployment/ansible/roles/init-cosmos/tasks/main.yml +++ b/packages/deployment/ansible/roles/init-cosmos/tasks/main.yml @@ -24,8 +24,3 @@ become: yes become_user: "{{ service }}" shell: "{{ service }} init --overwrite {{ inventory_hostname }} --chain-id={{ CHAIN_NAME }}" - -#- name: "Add coins to {{ service }}" -# become: yes -# become_user: "{{ service }}" -# shell: "{{ service }} add-genesis-account {{ BOOTSTRAP_ADDRESS }} {{ BOOTSTRAP_TOKENS }}" diff --git a/packages/deployment/ansible/roles/start/tasks/main.yml b/packages/deployment/ansible/roles/start/tasks/main.yml index 6bc611c91c9..67949a44dc1 100644 --- a/packages/deployment/ansible/roles/start/tasks/main.yml +++ b/packages/deployment/ansible/roles/start/tasks/main.yml @@ -1,5 +1,4 @@ --- - name: start service - service: "name={{service}} state=started" - + service: "name={{service}} state=started enabled=yes" diff --git a/packages/deployment/ansible/roles/stop/tasks/main.yml b/packages/deployment/ansible/roles/stop/tasks/main.yml index 7db356f224a..effeb636c0a 100644 --- a/packages/deployment/ansible/roles/stop/tasks/main.yml +++ b/packages/deployment/ansible/roles/stop/tasks/main.yml @@ -1,5 +1,4 @@ --- - name: stop service - service: "name={{service}} state=stopped" - + service: "name={{service}} state=stopped enabled=no" diff --git a/packages/deployment/main.js b/packages/deployment/main.js index d5ed5b7a6cd..b7af3e069e4 100644 --- a/packages/deployment/main.js +++ b/packages/deployment/main.js @@ -407,9 +407,6 @@ show-config display the client connection parameters needReMain(['play', 'install-cosmos']), ); - const bootAddress = await needBacktick( - `${shellEscape(progname)} show-bootstrap-address`, - ); await guardFile(`${COSMOS_DIR}/service.stamp`, () => needReMain([ 'play', @@ -417,7 +414,6 @@ show-config display the client connection parameters `-eexecline=${shellEscape( '/usr/src/cosmic-swingset/bin/ag-chain-cosmos start --pruning=nothing', )}`, - `-eserviceLines="Environment=BOOT_ADDRESS=${bootAddress}"`, ]), ); await guardFile(`${COSMOS_DIR}/start.stamp`, () => @@ -460,43 +456,6 @@ show-config display the client connection parameters needReMain(['play', 'install-controller']), ); - await guardFile(`${CONTROLLER_DIR}/solo-service.stamp`, () => - needReMain([ - 'play', - 'install', - '-eservice=ag-controller', - '-euser=ag-pserver', - '-echdir=/home/ag-pserver/controller', - `-eexecline="/usr/local/bin/ag-solo start --role=controller"`, - ]), - ); - await guardFile(`${CONTROLLER_DIR}/solo-start.stamp`, async () => { - await needReMain([ - 'play', - 'start', - '-eservice=ag-controller', - '-euser=ag-pserver', - ]); - - const svc = 'ag-controller'; - await waitForStatus( - 'ag-pserver', // user - PROVISIONER_NODE, // host - svc, // service - _retries => - sleep( - SECONDS_BETWEEN_BLOCKS + 1, - `to check if ${chalk.underline(svc)} has found a block`, - ), - (buf, code) => { - if (code) { - return undefined; - } - return buf.match(/: new block on/) ? true : undefined; - }, - ); - }); - // Install any pubkeys from a former instantiation. await guardFile(`${CONTROLLER_DIR}/pubkeys.stamp`, () => needReMain([ @@ -578,15 +537,6 @@ ${chalk.yellow.bold(`curl ${pserverUrl}/request-code?nickname=MY-NICK`)} break; } - case 'show-bootstrap-address': { - await inited(); - const bootAddress = await trimReadFile( - `${CONTROLLER_DIR}/data/${PROVISIONER_NODE}/boot-address.txt`, - ); - process.stdout.write(bootAddress); - break; - } - case 'ssh': { const [host, ...sshArgs] = args.slice(1); if (!host) { @@ -618,19 +568,12 @@ ${chalk.yellow.bold(`curl ${pserverUrl}/request-code?nickname=MY-NICK`)} setSilent(true); await chdir(SETUP_HOME); await inited(); - const [ - chainName, - gci, - peers, - rpcAddrs, - bootstrapAddress, - ] = await Promise.all( + const [chainName, gci, peers, rpcAddrs] = await Promise.all( [ 'show-chain-name', 'show-gci', 'show-peers', 'show-rpcaddrs', - 'show-bootstrap-address', ].map(subcmd => needBacktick([progname, subcmd].map(shellEscape).join(' ')), ), @@ -640,7 +583,6 @@ ${chalk.yellow.bold(`curl ${pserverUrl}/request-code?nickname=MY-NICK`)} gci, peers: peers.split(','), rpcAddrs: rpcAddrs.split(','), - bootstrapAddress, }; process.stdout.write(`${JSON.stringify(obj, undefined, 2)}\n`); break; @@ -959,7 +901,6 @@ ${name}: ? `\ units: - ag-pserver.service - - ag-controller.service - ag-chain-cosmos.service ` : ''; From c9af5a11ac5ffa1afcbc47c6399f35945055e3b2 Mon Sep 17 00:00:00 2001 From: Michael FIG Date: Sun, 5 Jul 2020 19:05:07 -0600 Subject: [PATCH 2/2] fix: remove more controller references --- packages/cosmic-swingset/Dockerfile | 2 +- .../roles/init-controller/tasks/main.yml | 19 ++++++++++++++----- .../roles/install-controller/tasks/main.yml | 7 ------- packages/deployment/docker/ag-setup-cosmos | 4 ---- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/packages/cosmic-swingset/Dockerfile b/packages/cosmic-swingset/Dockerfile index eb268d57e10..401d445f80c 100644 --- a/packages/cosmic-swingset/Dockerfile +++ b/packages/cosmic-swingset/Dockerfile @@ -1,6 +1,6 @@ # The Golang build container. # TODO This should be split out into the cosmos-connector. -FROM golang:1.13-stretch +FROM golang:1.14-stretch WORKDIR /usr/src/app COPY go.mod go.sum ./ diff --git a/packages/deployment/ansible/roles/init-controller/tasks/main.yml b/packages/deployment/ansible/roles/init-controller/tasks/main.yml index a1c343f690c..7a1aed218e2 100644 --- a/packages/deployment/ansible/roles/init-controller/tasks/main.yml +++ b/packages/deployment/ansible/roles/init-controller/tasks/main.yml @@ -8,19 +8,28 @@ - name: "Create provisioning mnemonic" delegate_to: localhost shell: - cmd: "ag-cosmos-helper keys mnemonic | tee provisioning-mnemonic.txt" + cmd: "ag-cosmos-helper keys mnemonic 2>&1 | tee provisioning-mnemonic.txt" + chdir: "{{ SETUP_HOME }}" register: mnemonic +- name: "Delete {{ service }} ag-solo key" + become: yes + become_user: "{{ service }}" + shell: + cmd: "ag-cosmos-helper --home=/home/{{ service }}/.ag-pserver/ag-cosmos-helper-statedir --keyring-backend=test keys delete ag-solo --yes" + removes: "/home/{{ service }}/.ag-pserver/ag-cosmos-helper-statedir" + ignore_errors: yes + - name: "Create {{ service }} ag-solo key" become: yes become_user: "{{ service }}" shell: - cmd: "ag-cosmos-helper --home=.{{ service }}/ag-cosmos-helper-statedir --keyring-backend=test keys add ag-solo" - stdin: "{{ mnemonic.stdout_lines }}" + cmd: "ag-cosmos-helper --home=/home/{{ service }}/.ag-pserver/ag-cosmos-helper-statedir --keyring-backend=test keys add --recover ag-solo" + stdin: "{{ mnemonic.stdout }}" - name: "Create ag-cosmos-helper-address" become: yes become_user: "{{ service }}" shell: - cmd: "ag-cosmos-helper --home=.{{ service }}/ag-cosmos-helper-statedir \ - --keyring-backend=test keys show -a ag-solo > .{{ service }}/ag-cosmos-helper-address" + cmd: "ag-cosmos-helper --home=/home/{{ service }}/.ag-pserver/ag-cosmos-helper-statedir \ + --keyring-backend=test keys show -a ag-solo > /home/{{ service }}/.ag-pserver/ag-cosmos-helper-address" diff --git a/packages/deployment/ansible/roles/install-controller/tasks/main.yml b/packages/deployment/ansible/roles/install-controller/tasks/main.yml index b9993731a20..b655506e5c3 100644 --- a/packages/deployment/ansible/roles/install-controller/tasks/main.yml +++ b/packages/deployment/ansible/roles/install-controller/tasks/main.yml @@ -34,13 +34,6 @@ path: "/home/{{ service }}/.{{ service }}/wwwroot/current" src: "{{ CHAIN_NAME }}" -- name: "set-gci-ingress for controller" - become_user: "{{ service }}" - become: true - shell: - cmd: "ag-solo set-gci-ingress --chainID={{ CHAIN_NAME }} {{ GCI }} {{ RPC_ADDRS }}" - chdir: "/home/{{ service }}/controller" - - name: "Add {{ NETWORK_NAME }} keys" synchronize: src: "{{ SETUP_HOME }}/{{ NETWORK_NAME }}.{{ item }}" diff --git a/packages/deployment/docker/ag-setup-cosmos b/packages/deployment/docker/ag-setup-cosmos index 56efd39ad5f..76e024926a8 100755 --- a/packages/deployment/docker/ag-setup-cosmos +++ b/packages/deployment/docker/ag-setup-cosmos @@ -21,10 +21,6 @@ show-*) TTY=-i ;; esac -if test -n "$CONTROLLER_VATS"; then - # Mount the specified controller vats directory. - FLAGS="$FLAGS --volume=`cd "$CONTROLLER_VATS" && pwd`:/usr/src/app/lib/ag-solo/vats" -fi exec docker run --rm $TTY $FLAGS \ --volume=ag-setup-cosmos-chains:/usr/src/app/chains \ --volume=ag-cosmos-helper-state:/root/.ag-cosmos-helper \