Skip to content

Commit

Permalink
[node] Fix: parachain flags affect relaychain node (#325)
Browse files Browse the repository at this point in the history
* fix relaychain

* fix
  • Loading branch information
BulatSaif authored Jan 17, 2024
1 parent 731d9f4 commit 8f67d23
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 13 deletions.
2 changes: 1 addition & 1 deletion charts/node/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: node
description: A Helm chart to deploy Substrate/Polkadot nodes
type: application
version: 5.6.0
version: 5.6.1
maintainers:
- name: Parity
url: https://github.com/paritytech/helm-charts
Expand Down
2 changes: 1 addition & 1 deletion charts/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This is intended behaviour. Make sure to run `git add -A` once again to stage ch

# Substrate/Polkadot node Helm chart

![Version: 5.6.0](https://img.shields.io/badge/Version-5.6.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)
![Version: 5.6.1](https://img.shields.io/badge/Version-5.6.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square)

## Maintainers

Expand Down
21 changes: 21 additions & 0 deletions charts/node/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,24 @@ Define a regex matcher to check if the passed node flags are managed by the char
{{- define "node.chartManagedFlagsRegex" -}}
{{- "(\\W|^)(--name|--base-path|--chain|--state-pruning|--validator|--collator|--light|--database|--prometheus-external|--prometheus-port|--node-key|--wasm-runtime-overrides|--jaeger-agent|--rpc-external|--unsafe-rpc-external|--ws-external|--unsafe-ws-external|--rpc-methods|--rpc-cors|--rpc-port|--ws-port|--enable-offchain-indexing)(\\W|$)" }}
{{- end }}


{{/*
Return true if we have collator with Relaychain
*/}}
{{- define "node.hasCollatorRelaychain" -}}
{{- if and .Values.node.isParachain (not .Values.node.collatorExternalRelayChain.enabled) (not .Values.node.collatorLightClient.enabled) }}
{{- true -}}
{{- else -}}
{{- end -}}
{{- end -}}

{{/*
Return true if we have a Relaychain, a single Relaychain, or if it's part of a collator.
*/}}
{{- define "node.hasRelaychain" -}}
{{- if or (not .Values.node.isParachain) (and (not .Values.node.collatorExternalRelayChain.enabled ) (not .Values.node.collatorLightClient.enabled)) }}
{{- true -}}
{{- else -}}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/node/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ spec:
{{- end }}
{{- end }}
---
{{- if $.Values.node.perNodeServices.relayP2pService.enabled }}
{{- if and $.Values.node.perNodeServices.relayP2pService.enabled (include "node.hasRelaychain" $) }}
apiVersion: v1
kind: Service
metadata:
Expand Down
20 changes: 10 additions & 10 deletions charts/node/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ spec:
runAsUser: 0
{{- end }}
{{- end }}
{{- if and .Values.node.collatorRelayChain.chainData.chainSnapshot.enabled (and (not .Values.node.collatorExternalRelayChain.enabled ) (not .Values.node.collatorLightClient.enabled)) }}
{{- if and .Values.node.collatorRelayChain.chainData.chainSnapshot.enabled (include "node.hasCollatorRelaychain" .) }}
- name: download-relay-chain-snapshot
image: {{ .Values.initContainers.downloadChainSnapshot.image.repository }}:{{ .Values.initContainers.downloadChainSnapshot.image.tag }}
command: [ "/bin/sh" ]
Expand Down Expand Up @@ -264,7 +264,7 @@ spec:
volumeMounts:
- mountPath: /chain-data
name: chain-data
{{- if and .Values.node.isParachain .Values.node.collatorRelayChain.customChainspecUrl (and (not .Values.node.collatorExternalRelayChain.enabled ) (not .Values.node.collatorLightClient.enabled))}}
{{- if and .Values.node.collatorRelayChain.customChainspecUrl (include "node.hasCollatorRelaychain" .) }}
- mountPath: /relaychain-data
name: relaychain-data
{{- end }}
Expand Down Expand Up @@ -435,7 +435,7 @@ spec:
- |
set -eu -o pipefail {{ if .Values.initContainers.retrieveServiceInfo.debug }}-x{{ end }}
POD_INDEX="${HOSTNAME##*-}"
{{- if and .Values.node.perNodeServices.relayP2pService.enabled (and (not .Values.node.collatorExternalRelayChain.enabled ) (not .Values.node.collatorLightClient.enabled)) (eq .Values.node.perNodeServices.relayP2pService.type "NodePort") }}
{{- if and .Values.node.perNodeServices.relayP2pService.enabled (include "node.hasRelaychain" .) (eq .Values.node.perNodeServices.relayP2pService.type "NodePort") }}
RELAY_CHAIN_P2P_PORT="$(kubectl --namespace {{ .Release.Namespace }} get service {{ $fullname }}-${POD_INDEX}-relay-chain-p2p -o jsonpath='{.spec.ports[?(@.name=="p2p")].nodePort}')"
{{- if .Values.node.perNodeServices.relayP2pService.ws.enabled }}
RELAY_CHAIN_P2P_PORT_WS="$(kubectl --namespace {{ .Release.Namespace }} get service {{ $fullname }}-${POD_INDEX}-relay-chain-p2p -o jsonpath='{.spec.ports[?(@.name=="ws")].nodePort}')"
Expand All @@ -446,7 +446,7 @@ spec:
echo "Retrieved Kubernetes service node port from {{ $fullname }}-${POD_INDEX}-relay-chain-p2p"
echo "Saved ${RELAY_CHAIN_P2P_PORT} to /chain-data/relay_chain_p2p_port"
{{- end }}
{{- if and .Values.node.perNodeServices.paraP2pService.enabled (eq .Values.node.perNodeServices.paraP2pService.type "NodePort") }}
{{- if and .Values.node.isParachain .Values.node.perNodeServices.paraP2pService.enabled (eq .Values.node.perNodeServices.paraP2pService.type "NodePort") }}
PARA_CHAIN_P2P_PORT="$(kubectl --namespace {{ .Release.Namespace }} get service {{ $fullname }}-${POD_INDEX}-para-chain-p2p -o jsonpath='{.spec.ports[0].nodePort}')"
echo "${PARA_CHAIN_P2P_PORT}" > /chain-data/para_chain_p2p_port
echo "Retrieved Kubernetes service node port from {{ $fullname }}-${POD_INDEX}-para-chain-p2p, saved ${PARA_CHAIN_P2P_PORT} to /chain-data/para_chain_p2p_port"
Expand Down Expand Up @@ -484,7 +484,7 @@ spec:
EXTERNAL_IP="$(cat /chain-data/node_external_ip)"
echo "EXTERNAL_IP=${EXTERNAL_IP}"
{{- end }}
{{- if and (not .Values.node.collatorExternalRelayChain.enabled) (not .Values.node.collatorLightClient.enabled) }}
{{- if (include "node.hasRelaychain" .) }}
{{- if and .Values.node.perNodeServices.relayP2pService.enabled (eq .Values.node.perNodeServices.relayP2pService.type "NodePort") }}
{{- /* For NodePort services, set the p2p port to the value saved in the retrieve-service-info init container */}}
RELAY_CHAIN_P2P_PORT="$(cat /chain-data/relay_chain_p2p_port)"
Expand Down Expand Up @@ -653,7 +653,7 @@ spec:
{{- end }}
{{- end }}
{{- end }}
{{- if .Values.node.perNodeServices.relayP2pService.enabled }}
{{- if and .Values.node.perNodeServices.relayP2pService.enabled (include "node.hasRelaychain" .) }}
{{- if .Values.node.perNodeServices.setPublicAddressToExternalIp.enabled }}
--public-addr=/ip4/${EXTERNAL_IP}/tcp/${RELAY_CHAIN_P2P_PORT} \
{{- if .Values.node.perNodeServices.relayP2pService.ws.enabled }}
Expand All @@ -664,7 +664,7 @@ spec:
--listen-addr=/ip4/0.0.0.0/tcp/30334/ws \
{{- end }}
{{- end }}
{{- if (and (not .Values.node.collatorExternalRelayChain.enabled) (not .Values.node.collatorLightClient.enabled)) }}
{{- if (include "node.hasRelaychain" .) }}
--listen-addr=/ip4/0.0.0.0/tcp/30333 \
{{- end }}
env:
Expand Down Expand Up @@ -730,7 +730,7 @@ spec:
name: chain-data
- mountPath: /keystore
name: chain-keystore
{{- if and .Values.node.isParachain (not .Values.node.collatorExternalRelayChain.enabled) (not .Values.node.collatorLightClient.enabled) }}
{{- if (include "node.hasCollatorRelaychain" .) }}
- mountPath: /relaychain-data
name: relaychain-data
- mountPath: /relaychain-keystore
Expand Down Expand Up @@ -911,7 +911,7 @@ spec:
sizeLimit: {{ .Values.node.chainKeystore.mountInMemory.sizeLimit }}
{{- end }}
{{- end }}
{{- if and .Values.node.isParachain .Values.node.collatorRelayChain.chainKeystore.mountInMemory.enabled }}
{{- if and (include "node.hasCollatorRelaychain" .) .Values.node.collatorRelayChain.chainKeystore.mountInMemory.enabled }}
- name: relaychain-keystore
emptyDir:
medium: "Memory"
Expand Down Expand Up @@ -970,7 +970,7 @@ spec:
requests:
storage: {{ .Values.node.chainKeystore.volumeSize }}
{{- end }}
{{- if and .Values.node.isParachain (and (not .Values.node.collatorExternalRelayChain.enabled ) (not .Values.node.collatorLightClient.enabled)) }}
{{- if (include "node.hasCollatorRelaychain" .) }}
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
Expand Down

0 comments on commit 8f67d23

Please sign in to comment.