From a76204a57f802453515ec1ee6daeeab8b73a0ba3 Mon Sep 17 00:00:00 2001 From: Andrew Gouin Date: Fri, 27 Oct 2023 11:44:58 -0600 Subject: [PATCH] Allow adding additional start args --- api/v1/cosmosfullnode_types.go | 4 ++++ api/v1/zz_generated.deepcopy.go | 5 +++++ .../bases/cosmos.strange.love_cosmosfullnodes.yaml | 5 +++++ internal/fullnode/pod_builder.go | 3 +++ internal/fullnode/pod_builder_test.go | 14 ++++++++++++++ 5 files changed, 31 insertions(+) diff --git a/api/v1/cosmosfullnode_types.go b/api/v1/cosmosfullnode_types.go index eae4ce89..0622a653 100644 --- a/api/v1/cosmosfullnode_types.go +++ b/api/v1/cosmosfullnode_types.go @@ -542,6 +542,10 @@ type ChainSpec struct { // If not provided, the operator will not upgrade the chain, and will use the image specified in the pod spec. // +optional Versions []ChainVersion `json:"versions"` + + // Additional arguments to pass to the chain start command. + // +optional + AdditionalStartArgs []string `json:"additionalStartArgs"` } type ChainVersion struct { diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index ea3d8dc5..206dcb1b 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -109,6 +109,11 @@ func (in *ChainSpec) DeepCopyInto(out *ChainSpec) { *out = make([]ChainVersion, len(*in)) copy(*out, *in) } + if in.AdditionalStartArgs != nil { + in, out := &in.AdditionalStartArgs, &out.AdditionalStartArgs + *out = make([]string, len(*in)) + copy(*out, *in) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChainSpec. diff --git a/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml b/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml index 581a229d..c9c2afdd 100644 --- a/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml +++ b/config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml @@ -45,6 +45,11 @@ spec: chain: description: Blockchain-specific configuration. properties: + additionalStartArgs: + description: Additional arguments to pass to the chain start command. + items: + type: string + type: array addrbookScript: description: 'Specify shell (sh) script commands to properly download and save the address book file. Prefer AddrbookURL if the file diff --git a/internal/fullnode/pod_builder.go b/internal/fullnode/pod_builder.go index 4590f02c..903e52e2 100644 --- a/internal/fullnode/pod_builder.go +++ b/internal/fullnode/pod_builder.go @@ -473,6 +473,9 @@ func startCommandArgs(crd *cosmosv1.CosmosFullNode) []string { if format := cfg.LogFormat; format != nil { args = append(args, "--log_format", *format) } + if len(crd.Spec.ChainSpec.AdditionalStartArgs) > 0 { + args = append(args, crd.Spec.ChainSpec.AdditionalStartArgs...) + } return args } diff --git a/internal/fullnode/pod_builder_test.go b/internal/fullnode/pod_builder_test.go index 96fc7d20..bdb393be 100644 --- a/internal/fullnode/pod_builder_test.go +++ b/internal/fullnode/pod_builder_test.go @@ -202,6 +202,20 @@ func TestPodBuilder(t *testing.T) { test.RequireValidMetadata(t, pod) }) + t.Run("additional args", func(t *testing.T) { + crd := defaultCRD() + + crd.Spec.ChainSpec.AdditionalStartArgs = []string{"--foo", "bar"} + + builder := NewPodBuilder(&crd) + pod, err := builder.WithOrdinal(0).Build() + require.NoError(t, err) + + test.RequireValidMetadata(t, pod) + + require.Equal(t, []string{"start", "--home", "/home/operator/cosmos", "--foo", "bar"}, pod.Spec.Containers[0].Args) + }) + t.Run("containers", func(t *testing.T) { crd := defaultCRD() const wantWrkDir = "/home/operator"