Skip to content

Commit 6cb572d

Browse files
Merge pull request #4115 from onflow/update-bn2-automation
[BN2] Update BN2 automation
2 parents a525801 + ad864f3 commit 6cb572d

File tree

8 files changed

+107
-105
lines changed

8 files changed

+107
-105
lines changed

integration/benchnet2/Makefile

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
# eventually, DOCKER_TAG will use the git commit hash
2-
# this isn't working fully yet so fow now we will specify the explicit Git tag to use as the Docker tag
3-
#DOCKER_TAG := $(shell git rev-parse --short HEAD)
4-
FLOW_GO_TAG := v0.28.15
5-
BRANCH_NAME:=$(shell git rev-parse --abbrev-ref HEAD | tr '/' '-')
6-
DOCKER_TAG := $(FLOW_GO_TAG)
7-
COMMIT_SHA:=$(shell git rev-parse --short=9 HEAD)
8-
9-
ifeq ($(strip $(FLOW_GO_TAG)),)
10-
$(eval FLOW_GO_TAG=$(BRANCH_NAME))
11-
endif
12-
131
# default value of the Docker base registry URL which can be overriden when invoking the Makefile
142
DOCKER_REGISTRY := us-west1-docker.pkg.dev/dl-flow-benchnet-automation/benchnet
153

@@ -27,6 +15,8 @@ validate:
2715
ifeq ($(strip $(VALID_EXECUTION)), 1)
2816
# multiple execution nodes are required to prevent seals being generated in case of execution forking.
2917
$(error Number of Execution nodes should be no less than 2)
18+
else ifeq ($(strip $(NETWORK_ID)),)
19+
$(error NETWORK_ID cannot be empty)
3020
else ifeq ($(strip $(VALID_CONSENSUS)), 1)
3121
$(error Number of Consensus nodes should be no less than 2)
3222
else ifeq ($(strip $(VALID_COLLECTION)), 1)
@@ -35,23 +25,19 @@ else ifeq ($(strip $(NAMESPACE)),)
3525
$(error NAMESPACE cannot be empty)
3626
endif
3727

38-
init:
39-
ifeq ($(strip $(PROJECT_NAME)),)
40-
$(eval PROJECT_NAME=$(COMMIT_SHA))
41-
endif
42-
4328
# assumes there is a checked out version of flow-go in a "flow-go" sub-folder at this level so that the bootstrap executable
4429
# for the checked out version will be run in the sub folder but the bootstrap folder will be created here (outside of the checked out flow-go in the sub folder)
4530
gen-bootstrap: clone-flow
46-
cd flow-go/cmd/bootstrap && go run -tags relic . genconfig --address-format "%s%d-${PROJECT_NAME}.${NAMESPACE}:3569" --access $(ACCESS) --collection $(COLLECTION) --consensus $(CONSENSUS) --execution $(EXECUTION) --verification $(VERIFICATION) --weight 100 -o ./ --config ../../../bootstrap/conf/node-config.json
31+
cd flow-go && make crypto_setup_gopath
32+
cd flow-go/cmd/bootstrap && go run -tags relic . genconfig --address-format "%s%d-${NETWORK_ID}.${NAMESPACE}:3569" --access $(ACCESS) --collection $(COLLECTION) --consensus $(CONSENSUS) --execution $(EXECUTION) --verification $(VERIFICATION) --weight 100 -o ./ --config ../../../bootstrap/conf/node-config.json
4733
cd flow-go/cmd/bootstrap && go run -tags relic . keygen --machine-account --config ../../../bootstrap/conf/node-config.json -o ../../../bootstrap/keys
4834
echo {} > ./bootstrap/conf/partner-stakes.json
4935
mkdir ./bootstrap/partner-nodes
5036
cd flow-go/cmd/bootstrap && go run -tags relic . rootblock --root-chain bench --root-height 0 --root-parent 0000000000000000000000000000000000000000000000000000000000000000 --config ../../../bootstrap/conf/node-config.json -o ../../../bootstrap/ --fast-kg --partner-dir ../../../bootstrap/partner-nodes --partner-weights ../../../bootstrap/conf/partner-stakes.json --internal-priv-dir ../../../bootstrap/keys/private-root-information
51-
cd flow-go/cmd/bootstrap && go run -tags relic . finalize --root-commit 0000000000000000000000000000000000000000000000000000000000000000 --service-account-public-key-json "{\"PublicKey\":\"R7MTEDdLclRLrj2MI1hcp4ucgRTpR15PCHAWLM5nks6Y3H7+PGkfZTP2di2jbITooWO4DD1yqaBSAVK8iQ6i0A==\",\"SignAlgo\":2,\"HashAlgo\":1,\"SeqNumber\":0,\"Weight\":1000}" --config ../../../bootstrap/conf/node-config.json -o ../../../bootstrap/ --partner-dir ../../../bootstrap/partner-nodes --partner-weights ../../../bootstrap/conf/partner-stakes.json --collection-clusters 1 --epoch-counter 0 --epoch-length 1600 --epoch-staking-phase-length 50 --epoch-dkg-phase-length 500 --genesis-token-supply="1000000000.0" --protocol-version=0 --internal-priv-dir ../../../bootstrap/keys/private-root-information --dkg-data ../../../bootstrap/private-root-information/root-dkg-data.priv.json --root-block ../../../bootstrap/public-root-information/root-block.json --root-block-votes-dir ../../../bootstrap/public-root-information/root-block-votes/
37+
cd flow-go/cmd/bootstrap && go run -tags relic . finalize --root-commit 0000000000000000000000000000000000000000000000000000000000000000 --service-account-public-key-json "{\"PublicKey\":\"R7MTEDdLclRLrj2MI1hcp4ucgRTpR15PCHAWLM5nks6Y3H7+PGkfZTP2di2jbITooWO4DD1yqaBSAVK8iQ6i0A==\",\"SignAlgo\":2,\"HashAlgo\":1,\"SeqNumber\":0,\"Weight\":1000}" --config ../../../bootstrap/conf/node-config.json -o ../../../bootstrap/ --partner-dir ../../../bootstrap/partner-nodes --partner-weights ../../../bootstrap/conf/partner-stakes.json --collection-clusters 1 --epoch-counter 0 --epoch-length 30000 --epoch-staking-phase-length 20000 --epoch-dkg-phase-length 2000 --genesis-token-supply="1000000000.0" --protocol-version=0 --internal-priv-dir ../../../bootstrap/keys/private-root-information --dkg-data ../../../bootstrap/private-root-information/root-dkg-data.priv.json --root-block ../../../bootstrap/public-root-information/root-block.json --root-block-votes-dir ../../../bootstrap/public-root-information/root-block-votes/ --epoch-commit-safety-threshold=1000
5238

5339
gen-helm-l1:
54-
go run automate/cmd/level1/bootstrap.go --data bootstrap/public-root-information/root-protocol-state-snapshot.json --dockerTag $(DOCKER_TAG) --dockerRegistry $(DOCKER_REGISTRY)
40+
go run automate/cmd/level1/bootstrap.go --data bootstrap/public-root-information/root-protocol-state-snapshot.json --dockerTag $(NETWORK_ID) --dockerRegistry $(DOCKER_REGISTRY)
5541

5642
gen-helm-l2:
5743
go run automate/cmd/level2/template.go --data template-data.json --template automate/templates/helm-values-all-nodes.yml --outPath="./values.yml"
@@ -60,13 +46,16 @@ gen-helm-l2:
6046
# runs bootstrap to generate all node info
6147
# runs level 1 automation to read bootstrap data and generate data input for level 2
6248
# runs level 2 automation to generate values.yml based on template and data values from previous step
63-
gen-helm-values: validate init gen-bootstrap gen-helm-l1 gen-helm-l2
49+
gen-helm-values: validate gen-bootstrap gen-helm-l1 gen-helm-l2
6450

6551
# main target for deployment
66-
deploy-all: validate init gen-helm-values k8s-secrets-create helm-deploy
52+
deploy-all: validate gen-helm-values k8s-secrets-create helm-deploy
6753

6854
# main target for cleaning up a deployment
69-
clean-all: validate init k8s-delete k8s-delete-secrets clean-bootstrap clean-gen-helm clean-flow
55+
clean-all: validate k8s-delete k8s-delete-secrets clean-bootstrap clean-gen-helm clean-flow
56+
57+
# target to be used in workflow as local clean up will not be needed
58+
remote-clean-all: validate k8s-delete-secrets k8s-delete
7059

7160
clean-bootstrap:
7261
rm -rf ./bootstrap
@@ -76,20 +65,20 @@ clean-gen-helm:
7665
rm -f template-data.json
7766

7867
k8s-secrets-create:
79-
bash ./create-secrets.sh ${PROJECT_NAME} ${NAMESPACE}
68+
bash ./create-secrets.sh ${NETWORK_ID} ${NAMESPACE}
8069

8170
helm-deploy:
82-
helm upgrade --install -f ./values.yml ${PROJECT_NAME} ./flow --set commit="${PROJECT_NAME}" --debug --namespace ${NAMESPACE}
71+
helm upgrade --install -f ./values.yml ${NETWORK_ID} ./flow --set networkId="${NETWORK_ID}" --set owner="${OWNER}" --debug --namespace ${NAMESPACE} --wait
8372

8473
k8s-delete:
85-
helm delete ${PROJECT_NAME} --namespace ${NAMESPACE}
86-
kubectl delete pvc -l project=${PROJECT_NAME} --namespace ${NAMESPACE}
74+
helm delete ${NETWORK_ID} --namespace ${NAMESPACE}
75+
kubectl delete pvc -l networkId=${NETWORK_ID} --namespace ${NAMESPACE}
8776

8877
k8s-delete-secrets:
89-
kubectl delete secrets -l project=${PROJECT_NAME} --namespace ${NAMESPACE}
78+
kubectl delete secrets -l networkId=${NETWORK_ID} --namespace ${NAMESPACE}
9079

9180
k8s-expose-locally: validate
92-
kubectl port-forward service/access1-${PROJECT_NAME} 9000:9000 --namespace ${NAMESPACE}
81+
kubectl port-forward service/access1-${NETWORK_ID} 9000:9000 --namespace ${NAMESPACE}
9382

9483
k8s-pod-health: validate
9584
kubectl get pods --namespace ${NAMESPACE}
@@ -100,7 +89,8 @@ k8s-test-network-accessibility:
10089

10190
clone-flow: clean-flow
10291
# this cloned repo will be used for generating bootstrap info specific to that tag / version
103-
git clone --depth 1 --branch $(FLOW_GO_TAG) https://github.com/onflow/flow-go.git --single-branch
92+
git clone https://github.com/onflow/flow-go.git
93+
cd flow-go && git checkout $(REF_FOR_BOOTSTRAP)
10494

10595
clean-flow:
10696
rm -rf flow-go

integration/benchnet2/automate/templates/helm-values-all-nodes.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
# from https://github.com/onflow/flow-go/blob/fa60c8f96b4a22f0f252c4b82a5dc4bbf54128c1/integration/localnet/values.yml
2-
branch: fake-branch
3-
# Commit must be a string
4-
commit: "123456"
52

63
defaults: {}
74
access:
@@ -48,8 +45,6 @@ collection:
4845
args:{{template "args" .}}
4946
- --loglevel=INFO
5047
- --block-rate-delay=950ms
51-
- --hotstuff-timeout=2.15s
52-
- --hotstuff-min-timeout=2.15s
5348
- --ingress-addr=0.0.0.0:9000
5449
- --insecure-access-api=false
5550
- --access-node-ids=*
@@ -73,8 +68,6 @@ consensus:
7368
args:{{template "args" .}}
7469
- --loglevel=DEBUG
7570
- --block-rate-delay=800ms
76-
- --hotstuff-timeout=2s
77-
- --hotstuff-min-timeout=2s
7871
- --chunk-alpha=1
7972
- --emergency-sealing-active=false
8073
- --insecure-access-api=false

integration/benchnet2/create-secrets.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
# Set Arguments
4-
PROJECT_NAME=$1
4+
NETWORK_ID=$1
55
NAMESPACE=$2
66

77
# Create execution-state secrets required to run network
@@ -12,12 +12,12 @@ for f in bootstrap/execution-state/*; do
1212
# Example start bootstrap/execution-state/00000000
1313
# Example result 00000000
1414
PREFIXREMOVED=${f//bootstrap\/execution-state\//};
15-
PREFIXREMOVED="$PROJECT_NAME.$PREFIXREMOVED";
15+
PREFIXREMOVED="$NETWORK_ID.$PREFIXREMOVED";
1616

1717
# Create the secret after string manipulation
1818
kubectl create secret generic $PREFIXREMOVED --from-file=$f --namespace=$NAMESPACE;
1919
kubectl label secret $PREFIXREMOVED "service=flow" --namespace=$NAMESPACE
20-
kubectl label secret $PREFIXREMOVED "project=$PROJECT_NAME" --namespace=$NAMESPACE
20+
kubectl label secret $PREFIXREMOVED "networkId=$NETWORK_ID" --namespace=$NAMESPACE
2121
done
2222

2323
# Create private-root-information secrets required to run network
@@ -28,7 +28,7 @@ for f in bootstrap/private-root-information/*/*; do
2828
# Remove the bootstrap/private-root-information/private-node-info_ prefix to ensure NodeId is retained
2929
# Example result 416c65782048656e74736368656c00e4e3235298a4b91382ecd84f13b9c237e6/node-info.priv.json
3030
PREFIXREMOVED=${f//bootstrap\/private-root-information\/private-node-info_/};
31-
PREFIXREMOVED="$PROJECT_NAME.$PREFIXREMOVED";
31+
PREFIXREMOVED="$NETWORK_ID.$PREFIXREMOVED";
3232

3333
# Substitute the forward slash "/" for a period "."
3434
# Example $PREFIXREMOVED value 416c65782048656e74736368656c00e4e3235298a4b91382ecd84f13b9c237e6/node-info.priv.json
@@ -38,7 +38,7 @@ for f in bootstrap/private-root-information/*/*; do
3838
# Create the secret after string manipulation
3939
kubectl create secret generic $KEYNAME --from-file=$f --namespace=$NAMESPACE;
4040
kubectl label secret $KEYNAME "service=flow" --namespace=$NAMESPACE
41-
kubectl label secret $KEYNAME "project=$PROJECT_NAME" --namespace=$NAMESPACE
41+
kubectl label secret $KEYNAME "networkId=$NETWORK_ID" --namespace=$NAMESPACE
4242
done
4343

4444
# Create public-root-information secrets required to run network
@@ -49,10 +49,10 @@ for f in bootstrap/public-root-information/*.json; do
4949
# Example start bootstrap/public-root-information/node-infos.pub.json
5050
# Example result node-info.pub.json
5151
PREFIXREMOVED=${f//bootstrap\/public-root-information\//};
52-
PREFIXREMOVED="$PROJECT_NAME.$PREFIXREMOVED";
52+
PREFIXREMOVED="$NETWORK_ID.$PREFIXREMOVED";
5353

5454
# Create the secret after string manipulation
5555
kubectl create secret generic $PREFIXREMOVED --from-file=$f --namespace=$NAMESPACE ;
5656
kubectl label secret $PREFIXREMOVED "service=flow" --namespace=$NAMESPACE
57-
kubectl label secret $PREFIXREMOVED "project=$PROJECT_NAME" --namespace=$NAMESPACE
57+
kubectl label secret $PREFIXREMOVED "networkId=$NETWORK_ID" --namespace=$NAMESPACE
5858
done

integration/benchnet2/flow/templates/access.yml

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ metadata:
77
name: {{ $k }}
88
labels:
99
app: {{ $k }}
10-
branch: {{ $.Values.branch }}
10+
networkId: {{ $.Values.networkId }}
1111
nodeType: access
12+
owner: {{ $.Values.owner }}
1213
service: flow
13-
project: {{ $.Values.commit }} # Prefixing the project name as label
1414

1515
spec:
1616
serviceName: {{ $k }}
@@ -20,16 +20,19 @@ spec:
2020
app: {{ $k }}
2121
nodeType: access
2222
service: flow
23-
project: {{ $.Values.commit }}
23+
networkId: {{ $.Values.networkId }}
2424

2525
template:
2626
metadata:
27+
annotations:
28+
prometheus.io/scrape: "true"
29+
prometheus.io/path: /metrics
30+
prometheus.io/port: "8080"
2731
labels:
2832
app: {{ $k }}
29-
branch: {{ $.Values.branch }}
3033
nodeType: access
3134
service: flow
32-
project: {{ $.Values.commit }}
35+
networkId: {{ $.Values.networkId }}
3336
spec:
3437
containers:
3538
- name: {{ $k }}
@@ -92,29 +95,29 @@ spec:
9295
volumes:
9396
- name: node-info-priv-json
9497
secret:
95-
secretName: {{ $.Values.commit }}.{{ $v.nodeId }}.node-info.priv.json
98+
secretName: {{ $.Values.networkId }}.{{ $v.nodeId }}.node-info.priv.json
9699

97100
- name: node-info-pub-json
98101
secret:
99-
secretName: {{ $.Values.commit }}.node-infos.pub.json
102+
secretName: {{ $.Values.networkId }}.node-infos.pub.json
100103

101104
- name: root-block-json
102105
secret:
103-
secretName: {{ $.Values.commit }}.root-block.json
106+
secretName: {{ $.Values.networkId }}.root-block.json
104107

105108
- name: root-protocol-state-snapshot-json
106109
secret:
107-
secretName: {{ $.Values.commit }}.root-protocol-state-snapshot.json
110+
secretName: {{ $.Values.networkId }}.root-protocol-state-snapshot.json
108111

109112
- name: secretsdb-key
110113
secret:
111-
secretName: {{ $.Values.commit }}.{{ $v.nodeId }}.secretsdb-key
114+
secretName: {{ $.Values.networkId }}.{{ $v.nodeId }}.secretsdb-key
112115

113116
volumeClaimTemplates:
114117
- metadata:
115118
name: data
116119
labels:
117-
project: {{ $.Values.commit }}
120+
networkId: {{ $.Values.networkId }}
118121
spec:
119122
accessModes: ["ReadWriteOnce"]
120123
resources:
@@ -135,7 +138,7 @@ metadata:
135138
name: {{ $k }}
136139
labels:
137140
app: {{ $k }}
138-
project: {{ $.Values.commit }}
141+
networkId: {{ $.Values.networkId }}
139142
spec:
140143
{{ if $v.servicePorts }}
141144
ports: {{ $v.servicePorts | toYaml | nindent 12 }}

integration/benchnet2/flow/templates/collection.yml

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ metadata:
77
name: {{ $k }}
88
labels:
99
app: {{ $k }}
10-
branch: {{ $.Values.branch }}
10+
networkId: {{ $.Values.networkId }}
1111
nodeType: collection
12+
owner: {{ $.Values.owner }}
1213
service: flow
13-
project: {{ $.Values.commit }}
1414

1515
spec:
1616
serviceName: {{ $k }}
@@ -23,12 +23,15 @@ spec:
2323

2424
template:
2525
metadata:
26+
annotations:
27+
prometheus.io/scrape: "true"
28+
prometheus.io/path: /metrics
29+
prometheus.io/port: "8080"
2630
labels:
2731
app: {{ $k }}
28-
branch: {{ $.Values.branch }}
2932
nodeType: collection
3033
service: flow
31-
project: {{ $.Values.commit }}
34+
networkId: {{ $.Values.networkId }}
3235
spec:
3336
containers:
3437
- name: {{ $k }}
@@ -97,33 +100,33 @@ spec:
97100
volumes:
98101
- name: node-info-priv-json
99102
secret:
100-
secretName: {{ $.Values.commit }}.{{ $v.nodeId }}.node-info.priv.json
103+
secretName: {{ $.Values.networkId }}.{{ $v.nodeId }}.node-info.priv.json
101104

102105
- name: node-info-pub-json
103106
secret:
104-
secretName: {{ $.Values.commit }}.node-infos.pub.json
107+
secretName: {{ $.Values.networkId }}.node-infos.pub.json
105108

106109
- name: root-block-json
107110
secret:
108-
secretName: {{ $.Values.commit }}.root-block.json
111+
secretName: {{ $.Values.networkId }}.root-block.json
109112

110113
- name: root-protocol-state-snapshot-json
111114
secret:
112-
secretName: {{ $.Values.commit }}.root-protocol-state-snapshot.json
115+
secretName: {{ $.Values.networkId }}.root-protocol-state-snapshot.json
113116

114117
- name: node-machine-account-info-priv-json
115118
secret:
116-
secretName: {{ $.Values.commit }}.{{ $v.nodeId }}.node-machine-account-info.priv.json
119+
secretName: {{ $.Values.networkId }}.{{ $v.nodeId }}.node-machine-account-info.priv.json
117120

118121
- name: secretsdb-key
119122
secret:
120-
secretName: {{ $.Values.commit }}.{{ $v.nodeId }}.secretsdb-key
123+
secretName: {{ $.Values.networkId }}.{{ $v.nodeId }}.secretsdb-key
121124

122125
volumeClaimTemplates:
123126
- metadata:
124127
name: data
125128
labels:
126-
project: {{ $.Values.commit }}
129+
networkId: {{ $.Values.networkId }}
127130
spec:
128131
accessModes: ["ReadWriteOnce"]
129132
resources:
@@ -143,7 +146,8 @@ metadata:
143146
name: {{ $k }}
144147
labels:
145148
app: {{ $k }}
146-
project: {{ $.Values.commit }}
149+
networkId: {{ $.Values.networkId }}
150+
owner: {{ $.Values.owner }}
147151
spec:
148152
{{ if $v.servicePorts }}
149153
ports: {{ $v.servicePorts | toYaml | nindent 12 }}

0 commit comments

Comments
 (0)