Skip to content

Commit

Permalink
Parameterize fabric_domain
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-at-luther committed Sep 17, 2024
1 parent 26590d2 commit dd000d6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ spec:
aws s3 cp --recursive "${ARTIFACT_ROOT}/channel-artifacts/" /channel-artifacts
aws s3 cp "${ARTIFACT_ROOT}/collections.json" /collections-config/
aws s3 cp --recursive "${ARTIFACT_ROOT}/crypto-config/ordererOrganizations/luther.systems/orderers/orderer0.luther.systems/msp/tlscacerts/" /orderertls
aws s3 cp --recursive "${ARTIFACT_ROOT}/crypto-config/ordererOrganizations/{{ .Values.dlt.domain }}/orderers/orderer0.{{ .Values.dlt.domain }}/msp/tlscacerts/" /orderertls
{{- if eq .Values.dlt.organization "orderer" }}
aws s3 cp --recursive "${ARTIFACT_ROOT}/crypto-config/ordererOrganizations/luther.systems/users/Admin@{{ .Values.dlt.domain }}/msp/" /msp
aws s3 cp --recursive "${ARTIFACT_ROOT}/crypto-config/ordererOrganizations/luther.systems/orderers/orderer{{ .Values.dlt.peerIndex }}.luther.systems/tls/" /tls
aws s3 cp --recursive "${ARTIFACT_ROOT}/crypto-config/ordererOrganizations/{{ .Values.dlt.domain }}/users/Admin@{{ .Values.dlt.domain }}/msp/" /msp
aws s3 cp --recursive "${ARTIFACT_ROOT}/crypto-config/ordererOrganizations/{{ .Values.dlt.domain }}/orderers/orderer{{ .Values.dlt.peerIndex }}.{{ .Values.dlt.domain }}/tls/" /tls
{{- else }}
aws s3 cp --recursive "${ARTIFACT_ROOT}/crypto-config/peerOrganizations/{{ .Values.dlt.organization }}.{{ .Values.dlt.domain }}/users/Admin@{{ .Values.dlt.organization }}.{{ .Values.dlt.domain }}/msp/" /msp
aws s3 cp --recursive "${ARTIFACT_ROOT}/crypto-config/peerOrganizations/{{ .Values.dlt.organization }}.{{ .Values.dlt.domain }}/peers/{{ list .Values.dlt.peerIndex . | include "fabric-cli.peer-fqdn" }}/tls/" /tls
Expand Down
1 change: 1 addition & 0 deletions ansible-roles/k8s_fabric_orderer/tasks/inner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
environment: "{{ kubectl_env | combine(extra_env_vars) }}"
vars:
extra_env_vars:
FABRIC_DOMAIN: "{{k8s_fabric_orderer_domain_root}}"
PAUSING_AT: orderer
WHICH: "{{ item }}"
CHANNEL: luther
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ spec:
args:
- |
set -xe;
aws s3 cp --recursive "s3://{{ .Values.global.aws.staticBucket }}/{{ .Values.global.lutherEnv }}/fabric-artifacts/crypto-config/ordererOrganizations/luther.systems/orderers/orderer0.luther.systems/msp/tlscacerts/" /orderertls
aws s3 cp --recursive "s3://{{ .Values.global.aws.staticBucket }}/{{ .Values.global.lutherEnv }}/fabric-artifacts/crypto-config/ordererOrganizations/{{ .Values.dlt.domain }}/orderers/orderer0.{{ .Values.dlt.domain }}/msp/tlscacerts/" /orderertls
aws s3 cp --recursive "s3://{{ .Values.global.aws.staticBucket }}/{{ .Values.global.lutherEnv }}/fabric-artifacts/crypto-config/peerOrganizations/{{ .Values.dlt.organization }}.{{ .Values.dlt.domain }}/peers/{{ include "fabric-peer.self-fqdn" . }}/msp/" /msp
aws s3 cp --recursive "s3://{{ .Values.global.aws.staticBucket }}/{{ .Values.global.lutherEnv }}/fabric-artifacts/crypto-config/peerOrganizations/{{ .Values.dlt.organization }}.{{ .Values.dlt.domain }}/peers/{{ include "fabric-peer.self-fqdn" . }}/tls/" /tls
aws s3 cp --recursive "s3://{{ .Values.global.aws.staticBucket }}/{{ .Values.global.lutherEnv }}/fabric-artifacts/crypto-config/peerOrganizations/{{ .Values.dlt.organization }}.{{ .Values.dlt.domain }}/users/Admin@{{ .Values.dlt.organization }}.{{ .Values.dlt.domain }}/msp/" /adminmsp
Expand Down
1 change: 1 addition & 0 deletions ansible-roles/k8s_fabric_peer/tasks/inner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
environment: "{{ kubectl_env | combine(extra_env_vars) }}"
vars:
extra_env_vars:
FABRIC_DOMAIN: "{{k8s_fabric_peer_domain_root}}"
PAUSING_AT: peer
WHICH: "{{ item }}"
CHANNEL: luther
Expand Down
75 changes: 30 additions & 45 deletions ansible-roles/k8s_fabric_scripts/files/scripts/upgrade-pauser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,98 +11,83 @@ set -o pipefail
# CHANNEL
# ORDERERC
# PEER_ORG
# FABRIC_DOMAIN

function get_height_for_orderer()
{
PARSEABLE="$(kubectl -n "$THRUNAME" exec "$THRUPEER" -- peer channel fetch newest /dev/null -c "$CHANNEL" -o orderer"$1".luther.systems:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/orderertls/tlsca.luther.systems-cert.pem 2>&1)"
source "${BASH_SOURCE%/*}/channel-utils.sh"

function get_height_for_orderer() {
PARSEABLE="$(kubectl -n "$THRUNAME" exec "$THRUPEER" -- peer channel fetch newest /dev/null -c "$CHANNEL" -o orderer"$1".${FABRIC_DOMAIN}:7050 --tls --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/orderertls/tlsca.${FABRIC_DOMAIN}-cert.pem 2>&1)"
PARSEABLE="$(echo "$PARSEABLE" | egrep -o 'Received block: [0-9]+$')"
HEIGHT_FOR_ORDERER="$(echo "$PARSEABLE" | cut -d " " -f 3)"
}

function get_height_for_peer()
{
function get_height_for_peer() {
PARSEABLE="$(kubectl -n "$THRUNAME" exec "$THRUPEER" -- peer channel getinfo -c "$CHANNEL")"
PARSEABLE="$(echo "$PARSEABLE" | egrep -o '\{[^\}]*\}')"
HEIGHT_FOR_PEER="$(echo "$PARSEABLE" | jq .height)"
}

function get_peak()
{
function get_peak() {
# determine where the highest orderer is at
PEAK=0
for i in $(seq 0 "$(( ORDERERC-1 ))")
do
if [ "$i" != "$1" ] # support for excluding an orderer
then
for i in $(seq 0 "$((ORDERERC - 1))"); do
if [ "$i" != "$1" ]; then # support for excluding an orderer
get_height_for_orderer "$i"
if (( HEIGHT_FOR_ORDERER > PEAK ))
then
if ((HEIGHT_FOR_ORDERER > PEAK)); then
PEAK="$HEIGHT_FOR_ORDERER"
fi
fi
done
}

function g_orderer()
{
function g_orderer() {
THRUNAME="fabric-org1"
THRUPEER="$(kubectl -n "$THRUNAME" get pod | egrep '^fabric-peer0-org1-' | cut -d " " -f 1)"

get_peak "$WHICH"

# wait until the orderer regains that level
while [ 1 ]
do
if ! get_height_for_orderer "$WHICH"
then
while [ 1 ]; do
if ! get_height_for_orderer "$WHICH"; then
sleep 3
continue
fi

if (( HEIGHT_FOR_ORDERER >= PEAK ))
then

if ((HEIGHT_FOR_ORDERER >= PEAK)); then
break
fi

sleep 3
done
}

function g_peer()
{
function g_peer() {
THRUNAME="fabric-$PEER_ORG"
THRUPEER="$(kubectl -n "$THRUNAME" get pod | egrep '^fabric-peer'"$WHICH"'-'"$PEER_ORG"'-' | cut -d " " -f 1)"

while ! get_peak invalid
do

while ! get_peak invalid; do
sleep 3
done

# wait until the peer gains that level
while [ 1 ]
do
if ! get_height_for_peer
then
while [ 1 ]; do
if ! get_height_for_peer; then
sleep 3
continue
fi

if (( HEIGHT_FOR_PEER >= PEAK ))
then

if ((HEIGHT_FOR_PEER >= PEAK)); then
break
fi

sleep 3
done
}

function g()
{
if [ "$PAUSING_AT" == "orderer" ]
then
function g() {
if [ "$PAUSING_AT" == "orderer" ]; then
g_orderer
elif [ "$PAUSING_AT" == "peer" ]
then
elif [ "$PAUSING_AT" == "peer" ]; then
g_peer
else
exit 1
Expand Down

0 comments on commit dd000d6

Please sign in to comment.