Skip to content

Commit d1cdbdd

Browse files
author
tazhate
committed
fix: e2e fixes, adapter corrections, and production-ported fixes
E2e / config: - cmd/main.go: webhook setup conditional on TLS cert existence (no cert-manager crash) - config/manager/manager.yaml: replicas 2→1 (e2e expects single pod) - config/default/kustomization.yaml: webhook line commented out by default - Makefile: Kind cluster check fixed (grep '.' vs grep 'kind') - test/e2e/e2e_test.go: invalid chain test uses 'notachain', ClusterRoleBinding idempotent apply, ServiceMonitor check behind PROMETHEUS_INSTALL_SKIP flag Adapter fixes ported from production (finso/nodes-hosting-project): - bitcoin/dash/litecoin: add explicit -conf= ContainerArgs so binary reads config - near: restore --download-config flag (removed accidentally, caused header-sync hang) - xrp: revert node_size back to 'huge' - bsc: add set -e + error handling for genesis.json download in ContainerCommand - cardano: fix HealthCheck URL (url.Parse port replacement vs broken string concat) - sui: update state-archive-read-config to GCS object-store format, InitContainers with DB health check (MANIFEST/CURRENT) and resume logic for partial downloads Other adapter corrections: - berachain: rewrite for BeaconKit CL architecture (beacon-kit image, correct ports) - hemi: fix wrong image type (hemilabs/op-geth, not bfgd daemon) - ethereum: Erigon-aware HealthCheck with postSyncStages, parallel eth_blockNumber - multiple EVM adapters: add metrics port in ContainerPorts - adapters_test.go: fix ChainCronosZkEVM capitalization Context: cross-referenced old platform git log and live node configs; tested e2e suite against Kind cluster bch-operator-e2e; debugged webhook TLS crash and Kind cluster name mismatch; spent ~3h on production diff analysis.
1 parent ba94b75 commit d1cdbdd

49 files changed

Lines changed: 449 additions & 101 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ test-e2e: manifests generate fmt vet ## Run the e2e tests. Expected an isolated
7272
echo "Kind is not installed. Please install Kind manually."; \
7373
exit 1; \
7474
}
75-
@kind get clusters | grep -q 'kind' || { \
75+
@kind get clusters | grep -q '.' || { \
7676
echo "No Kind cluster is running. Please start a Kind cluster before running the e2e tests."; \
7777
exit 1; \
7878
}

cmd/main.go

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ var (
6363
// ---------------------------------------------------------------------------
6464

6565
const (
66-
defaultMetricsAddr = ":8080"
67-
defaultProbeAddr = ":8081"
68-
defaultTLSCertName = "tls.crt"
69-
defaultTLSKeyName = "tls.key"
70-
defaultPrometheusURL = "http://prometheus:9090"
71-
defaultLeaderElectID = "f8c0f89a.nodes.k8s-bch.io"
66+
defaultMetricsAddr = ":8080"
67+
defaultProbeAddr = ":8081"
68+
defaultTLSCertName = "tls.crt"
69+
defaultTLSKeyName = "tls.key"
70+
defaultPrometheusURL = "http://prometheus:9090"
71+
defaultLeaderElectID = "f8c0f89a.nodes.k8s-bch.io"
7272
)
7373

7474
var (
@@ -347,9 +347,22 @@ func main() {
347347
}
348348

349349
// --- Webhook -------------------------------------------------------
350-
if err := (&nodesv1alpha1.BlockchainNode{}).SetupWebhookWithManager(mgr); err != nil {
351-
setupLog.Error(err, "unable to create webhook", "webhook", "BlockchainNode")
352-
os.Exit(1)
350+
// Webhook requires TLS certs (injected by cert-manager in production).
351+
// When certs are not present (e.g. local dev, e2e tests without cert-manager),
352+
// skip webhook setup gracefully instead of crashing.
353+
webhookCertDir := cfg.WebhookCertPath
354+
if webhookCertDir == "" {
355+
webhookCertDir = "/tmp/k8s-webhook-server/serving-certs"
356+
}
357+
if _, err := os.Stat(filepath.Join(webhookCertDir, cfg.WebhookCertName)); err == nil {
358+
if err := (&nodesv1alpha1.BlockchainNode{}).SetupWebhookWithManager(mgr); err != nil {
359+
setupLog.Error(err, "unable to create webhook", "webhook", "BlockchainNode")
360+
os.Exit(1)
361+
}
362+
setupLog.Info("webhook registered", "cert-dir", webhookCertDir)
363+
} else {
364+
setupLog.Info("webhook skipped — TLS certs not found, running without admission validation",
365+
"cert-dir", webhookCertDir)
353366
}
354367
// +kubebuilder:scaffold:builder
355368

config/default/kustomization.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ resources:
2020
- ../manager
2121
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
2222
# crd/kustomization.yaml
23-
- ../webhook
23+
# [WEBHOOK] Uncomment to deploy ValidatingWebhookConfiguration (requires cert-manager for TLS injection).
24+
#- ../webhook
2425
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
2526
#- ../certmanager
2627
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.

config/manager/manager.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121
matchLabels:
2222
control-plane: controller-manager
2323
app.kubernetes.io/name: blockchain-node-operator
24-
replicas: 2
24+
replicas: 1
2525
template:
2626
metadata:
2727
annotations:

internal/adapters/adapters_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,9 @@ func TestCosmosImplementsStartupProbeProvider(t *testing.T) {
736736

737737
func TestDefaultNodeSelectorKnownGroups(t *testing.T) {
738738
tests := []struct {
739-
group nodesv1alpha1.NodeGroup
740-
wantKey string
741-
wantVal string
739+
group nodesv1alpha1.NodeGroup
740+
wantKey string
741+
wantVal string
742742
}{
743743
{nodesv1alpha1.NodeGroupStorage, "workload-type", "storage"},
744744
{nodesv1alpha1.NodeGroupBlockchain, "node-role.kubernetes.io/blockchain", "true"},

internal/adapters/arbitrum.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,15 @@ func (a *arbitrumAdapter) HealthCheck(ctx context.Context, rpcURL string) (SyncS
5151
}
5252

5353
func (a *arbitrumAdapter) ContainerPorts(_ nodesv1alpha1.BlockchainNodeSpec) []corev1.ContainerPort {
54-
return evmPorts(8547)
54+
return append(evmPorts(8547), corev1.ContainerPort{
55+
Name: "metrics", ContainerPort: 6070, Protocol: corev1.ProtocolTCP,
56+
})
5557
}
5658

57-
// ContainerArgs injects the --l1.url flag pointing to the L1 Ethereum RPC.
59+
// ContainerArgs injects the --l1.url flag pointing to the L1 Ethereum RPC and enables metrics.
5860
// The L1_RPC_URL env var is set by ContainerEnv and can be overridden via extraEnv.
5961
func (a *arbitrumAdapter) ContainerArgs(_ nodesv1alpha1.BlockchainNodeSpec) []string {
60-
return []string{"--l1.url=$(L1_RPC_URL)"}
62+
return []string{"--l1.url=$(L1_RPC_URL)", "--metrics"}
6163
}
6264

6365
// ContainerEnv injects the L1_RPC_URL environment variable required by Arbitrum Nitro.
@@ -92,6 +94,6 @@ const arbitrumConfig = `{
9294
"persistent": {
9395
"chain": "arb1"
9496
},
95-
"metrics": false
97+
"metrics": true
9698
}
9799
`

internal/adapters/axelar.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ enable = true
3939
address = "0.0.0.0:9090"
4040
4141
[telemetry]
42-
enabled = false
42+
enabled = true
43+
prometheus-retention-time = 60
4344
`
4445

4546
// --------------------------------------------------------------------------
@@ -83,6 +84,7 @@ func (a *axelarAdapter) ContainerPorts(_ nodesv1alpha1.BlockchainNodeSpec) []cor
8384
{Name: "p2p", ContainerPort: 26656, Protocol: corev1.ProtocolTCP},
8485
{Name: "p2p-udp", ContainerPort: 26656, Protocol: corev1.ProtocolUDP},
8586
{Name: "grpc", ContainerPort: 9090, Protocol: corev1.ProtocolTCP},
87+
{Name: "metrics", ContainerPort: 26660, Protocol: corev1.ProtocolTCP},
8688
}
8789
}
8890

internal/adapters/berachain.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ import (
1515
// exposed by the EL (reth), not this container.
1616
//
1717
// Official images:
18-
// CL (this adapter): ghcr.io/berachain/beacon-kit
19-
// EL (companion): ghcr.io/berachain/reth
18+
//
19+
// CL (this adapter): ghcr.io/berachain/beacon-kit
20+
// EL (companion): ghcr.io/berachain/reth
2021
//
2122
// See: https://docs.berachain.com/nodes/run-a-node
2223
const defaultBerachainImage = "ghcr.io/berachain/beacon-kit:v0.2.0"

internal/adapters/bitcoin.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package adapters
33
import (
44
"bytes"
55
"context"
6+
"strconv"
67
"text/template"
78

89
corev1 "k8s.io/api/core/v1"
@@ -129,3 +130,31 @@ func (a *bitcoinAdapter) ContainerPorts(spec nodesv1alpha1.BlockchainNodeSpec) [
129130
{Name: "p2p", ContainerPort: 8333, Protocol: corev1.ProtocolTCP},
130131
}
131132
}
133+
134+
// Sidecars returns a bitcoin-prometheus-exporter sidecar for mainnet nodes.
135+
// Credentials are read from the same env vars used by the node itself.
136+
func (a *bitcoinAdapter) Sidecars(spec nodesv1alpha1.BlockchainNodeSpec) []corev1.Container {
137+
user, pass := a.rpcCredentials()
138+
if user == "" {
139+
return nil
140+
}
141+
rpcPort := int32(8332)
142+
if spec.Network == nodesv1alpha1.NetworkTestnet {
143+
rpcPort = 18332
144+
}
145+
return []corev1.Container{
146+
{
147+
Name: "metrics-exporter",
148+
Image: "jvstein/bitcoin-prometheus-exporter:v0.8.0",
149+
Ports: []corev1.ContainerPort{
150+
{Name: "metrics", ContainerPort: 9332, Protocol: corev1.ProtocolTCP},
151+
},
152+
Env: []corev1.EnvVar{
153+
{Name: "BITCOIN_RPC_HOST", Value: "localhost"},
154+
{Name: "BITCOIN_RPC_PORT", Value: strconv.Itoa(int(rpcPort))},
155+
{Name: "BITCOIN_RPC_USER", Value: user},
156+
{Name: "BITCOIN_RPC_PASSWORD", Value: pass},
157+
},
158+
},
159+
}
160+
}

internal/adapters/blast.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,14 @@ func (a *blastAdapter) HealthCheck(ctx context.Context, rpcURL string) (SyncStat
5050
}
5151

5252
func (a *blastAdapter) ContainerPorts(_ nodesv1alpha1.BlockchainNodeSpec) []corev1.ContainerPort {
53-
return evmPorts(30303)
53+
return append(evmPorts(30303), corev1.ContainerPort{
54+
Name: "metrics", ContainerPort: 6060, Protocol: corev1.ProtocolTCP,
55+
})
56+
}
57+
58+
// ContainerArgs enables Prometheus metrics endpoint on Blast op-geth.
59+
func (a *blastAdapter) ContainerArgs(_ nodesv1alpha1.BlockchainNodeSpec) []string {
60+
return []string{"--metrics", "--metrics.addr", "0.0.0.0", "--metrics.port", "6060"}
5461
}
5562

5663
// ContainerEnv injects the L1_RPC_URL environment variable required by OP Stack L2 nodes.

0 commit comments

Comments
 (0)