Skip to content

Commit

Permalink
default chartVersion: "" to go redpanda's version
Browse files Browse the repository at this point in the history
Prior to this commit `chartVersion` would default to the latest version of the
redpanda chart available at the time the helm repository controller ran.

This ended up being more confusing and possibly dangerous than it did being
convenient. Our documentation has begun telling users to explicitly pin
`chartVersion` themselves for stability.

Additionally, such functionality complicated the incipient de-fluxing
migration.

To resolve the above, this commit has changed the behavior to instead default
`chartVersion` to the version of the redpanda chart that's installed via the
`go.mod` file. At the time of this commit, that version is 5.9.9.
  • Loading branch information
chrisseto authored and RafalKorepta committed Oct 29, 2024
1 parent 4976e07 commit 87317b4
Show file tree
Hide file tree
Showing 14 changed files with 208 additions and 83 deletions.
2 changes: 1 addition & 1 deletion acceptance/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/cucumber/godog v0.14.1
github.com/go-logr/logr v1.4.2
github.com/redpanda-data/common-go/rpadmin v0.1.7-0.20240916201938-8d748d9ac10b
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1
github.com/redpanda-data/redpanda-operator/harpoon v0.0.0-00010101000000-000000000000
github.com/redpanda-data/redpanda-operator/operator v0.0.0-00010101000000-000000000000
github.com/stretchr/testify v1.9.0
Expand Down
2 changes: 1 addition & 1 deletion acceptance/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ github.com/redpanda-data/common-go/rpadmin v0.1.7-0.20240916201938-8d748d9ac10b
github.com/redpanda-data/common-go/rpadmin v0.1.7-0.20240916201938-8d748d9ac10b/go.mod h1:I7umqhnMhIOSEnIA3fvLtdQU7QO/SbWGCwFfFDs3De4=
github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20 h1:+zsE3W1V86k2sjAGWOySIlF0xn5R1aXXQBaIdr80F48=
github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20/go.mod h1:DC42/3+k5PefSo4IalYbDN3yRZrVFP0b69+gC/NwGd4=
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a h1:kNx8tH6z02nJctZS+oYt7LOWWoZgfMW4Ktees89GTh0=
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1 h1:Z1dclhzMIk83tZIa+aXqmojZZ2R03DvtXAfxWpWOqug=
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8 h1:uTQKqF8UPNxYxKBJ11VlG6Vt2l9ctkkeXsmmjHUSUG4=
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8/go.mod h1:97qkjcMI3gDL+y+aY/w5o0xF2qGHFof6rCXIYjnTalM=
github.com/rhnvrm/simples3 v0.6.1/go.mod h1:Y+3vYm2V7Y4VijFoJHHTrja6OgPrJ2cBti8dPGkC3sA=
Expand Down
2 changes: 1 addition & 1 deletion harpoon/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/cucumber/godog v0.14.1
github.com/cucumber/messages/go/v21 v21.0.1
github.com/olekukonko/tablewriter v0.0.5
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e
k8s.io/api v0.30.3
Expand Down
2 changes: 1 addition & 1 deletion harpoon/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT
github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a h1:kNx8tH6z02nJctZS+oYt7LOWWoZgfMW4Ktees89GTh0=
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1 h1:Z1dclhzMIk83tZIa+aXqmojZZ2R03DvtXAfxWpWOqug=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
Expand Down
2 changes: 1 addition & 1 deletion operator/api/redpanda/v1alpha2/redpanda_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type ChartRef struct {
// UseFlux flag set to `false` will prevent helm controller from reconciling helm chart. The operator would be
// tight with `go` based Redpanda helm chart version. The rest of the ChartRef fields would be ignored.
//
// Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.3`
// Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.9`
// version of the Redpanda chart.
//
// RedpandaStatus might not be accurate if flag is set to `false` and HelmRelease is manually deleted.
Expand Down
15 changes: 15 additions & 0 deletions operator/api/redpanda/v1alpha2/redpanda_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/redpanda-data/helm-charts/charts/redpanda"
"github.com/redpanda-data/redpanda-operator/operator/api/apiutil"
"github.com/redpanda-data/redpanda-operator/operator/api/redpanda/v1alpha2"
crds "github.com/redpanda-data/redpanda-operator/operator/config/crd/bases"
"github.com/redpanda-data/redpanda-operator/operator/internal/testutils"
"github.com/stretchr/testify/require"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -64,6 +65,20 @@ var (
})
)

func TestDefluxedMinimumVersion(t *testing.T) {
crd := crds.Redpanda()
// 0 is v1alpha1 and 1 is v1alpha2
recursiveProperties := crd.Spec.Versions[1].Schema.OpenAPIV3Schema.Properties

require.Containsf(
t,
recursiveProperties["spec"].Properties["chartRef"].Properties["useFlux"].Description,
redpanda.Chart.Metadata().Version,
"'useFlux' should reference the version %q of the go.mod installed redpanda chart. Do you need to run 'task generate' or update the comment?",
redpanda.Chart.Metadata().Version,
)
}

// TestRedpanda_ValuesJSON asserts that .ValuesJSON appropriately coalesces the
// value of CloudStorageEnabled into a boolean.
// NOTE: This test is close to being a duplicate of apiutil.JSONBoolean's tests
Expand Down
4 changes: 2 additions & 2 deletions operator/config/crd/bases/cluster.redpanda.com_redpandas.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ spec:
UseFlux flag set to `false` will prevent helm controller from reconciling helm chart. The operator would be
tight with `go` based Redpanda helm chart version. The rest of the ChartRef fields would be ignored.

Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.3`
Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.9`
version of the Redpanda chart.

RedpandaStatus might not be accurate if flag is set to `false` and HelmRelease is manually deleted.
Expand Down Expand Up @@ -9905,7 +9905,7 @@ spec:
UseFlux flag set to `false` will prevent helm controller from reconciling helm chart. The operator would be
tight with `go` based Redpanda helm chart version. The rest of the ChartRef fields would be ignored.

Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.3`
Before setting UseFlux flag to `false` please alight your ChartVersion to at least `5.9.9`
version of the Redpanda chart.

RedpandaStatus might not be accurate if flag is set to `false` and HelmRelease is manually deleted.
Expand Down
111 changes: 111 additions & 0 deletions operator/config/crd/bases/crds.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
// Copyright 2024 Redpanda Data, Inc.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.md
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0

// Package crds provide programmatic access to the CRDs generated by
// controller-gen.
package crds

import (
"embed"
"io/fs"

"github.com/cockroachdb/errors"
"github.com/redpanda-data/helm-charts/pkg/kube"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/runtime"
)

var (
//go:embed *.yaml
//go:embed toolkit.fluxcd.io/*.yaml
crdFS embed.FS

crds []*apiextensionsv1.CustomResourceDefinition
byName map[string]*apiextensionsv1.CustomResourceDefinition
)

func init() {
scheme := runtime.NewScheme()
must(apiextensionsv1.AddToScheme(scheme))

byName = map[string]*apiextensionsv1.CustomResourceDefinition{}

must(fs.WalkDir(crdFS, ".", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}

if d.IsDir() {
return nil
}

data, err := fs.ReadFile(crdFS, path)
if err != nil {
return err
}

objs, err := kube.DecodeYAML(data, scheme)
if err != nil {
return err
}

for _, obj := range objs {
crd := obj.(*apiextensionsv1.CustomResourceDefinition)

crds = append(crds, crd)
byName[crd.Name] = crd
}

return nil
}))
}

func ByName(name string) (*apiextensionsv1.CustomResourceDefinition, error) {
crd, ok := byName[name]
if !ok {
return nil, errors.Newf("no such CRD %q", name)
}
return crd, nil
}

func All() []*apiextensionsv1.CustomResourceDefinition {
ret := make([]*apiextensionsv1.CustomResourceDefinition, len(crds))

for i, crd := range crds {
ret[i] = crd.DeepCopy()
}

return ret
}

// Redpanda returns the Redpanda CustomResourceDefinition.
func Redpanda() *apiextensionsv1.CustomResourceDefinition {
return mustT(ByName("redpandas.cluster.redpanda.com"))
}

// Topic returns the Redpanda CustomResourceDefinition.
func Topic() *apiextensionsv1.CustomResourceDefinition {
return mustT(ByName("topics.cluster.redpanda.com"))
}

// Topic returns the Redpanda CustomResourceDefinition.
func User() *apiextensionsv1.CustomResourceDefinition {
return mustT(ByName("users.cluster.redpanda.com"))
}

func mustT[T any](r T, err error) T {
must(err)
return r
}

func must(err error) {
if err != nil {
panic(err)
}
}
45 changes: 45 additions & 0 deletions operator/config/crd/bases/crds_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright 2024 Redpanda Data, Inc.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.md
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0

package crds_test

import (
"testing"

crds "github.com/redpanda-data/redpanda-operator/operator/config/crd/bases"
"github.com/stretchr/testify/require"
)

func TestCRDS(t *testing.T) {
names := map[string]struct{}{
"buckets.source.toolkit.fluxcd.io": {},
"clusters.redpanda.vectorized.io": {},
"consoles.redpanda.vectorized.io": {},
"gitrepositories.source.toolkit.fluxcd.io": {},
"helmcharts.source.toolkit.fluxcd.io": {},
"helmreleases.helm.toolkit.fluxcd.io": {},
"helmrepositories.source.toolkit.fluxcd.io": {},
"ocirepositories.source.toolkit.fluxcd.io": {},
"redpandas.cluster.redpanda.com": {},
"schemas.cluster.redpanda.com": {},
"topics.cluster.redpanda.com": {},
"users.cluster.redpanda.com": {},
}

foundNames := map[string]struct{}{}
for _, crd := range crds.All() {
foundNames[crd.Name] = struct{}{}
}

require.Equal(t, names, foundNames)

require.Equal(t, "redpandas.cluster.redpanda.com", crds.Redpanda().Name)
require.Equal(t, "topics.cluster.redpanda.com", crds.Topic().Name)
require.Equal(t, "users.cluster.redpanda.com", crds.User().Name)
}
37 changes: 0 additions & 37 deletions operator/config/crd/bases/redpanda_controller_test.go

This file was deleted.

4 changes: 2 additions & 2 deletions operator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/cert-manager/cert-manager v1.14.5
github.com/cisco-open/k8s-objectmatcher v1.9.0
github.com/cloudhut/common v0.10.0
github.com/cockroachdb/errors v1.11.1
github.com/distribution/reference v0.6.0
github.com/fluxcd/helm-controller/api v0.37.2
github.com/fluxcd/helm-controller/shim v0.0.0-00010101000000-000000000000
Expand All @@ -27,7 +28,7 @@ require (
github.com/prometheus/common v0.55.0
github.com/redpanda-data/common-go/rpadmin v0.1.7-0.20240916201938-8d748d9ac10b
github.com/redpanda-data/console/backend v0.0.0-20240303221210-05d5d9e85f20
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8
github.com/scalalang2/golang-fifo v1.0.2
github.com/spf13/afero v1.11.0
Expand Down Expand Up @@ -138,7 +139,6 @@ require (
github.com/chrismellard/docker-credential-acr-env v0.0.0-20230304212654-82a0ddb27589 // indirect
github.com/clbanning/mxj/v2 v2.7.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cockroachdb/errors v1.11.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be // indirect
Expand Down
4 changes: 2 additions & 2 deletions operator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,8 @@ github.com/redpanda-data/flux-controller-shim/helm/shim v0.0.0-20231227162419-a4
github.com/redpanda-data/flux-controller-shim/helm/shim v0.0.0-20231227162419-a45126310240/go.mod h1:5KLXArOMFOrwb3BihpFaRNiPCyo9AXsXhvMdUmrCdUg=
github.com/redpanda-data/flux-controller-shim/source/shim v0.0.0-20240113100428-5e301ef97b19 h1:sJjDhnIbTMOuP4Rnhm1N3GNfgv6BJlocCnGliNvhgbw=
github.com/redpanda-data/flux-controller-shim/source/shim v0.0.0-20240113100428-5e301ef97b19/go.mod h1:T39OECA7eOlhpHZPBSGg+bpuwtt/G4m03fjBkJ821CM=
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a h1:kNx8tH6z02nJctZS+oYt7LOWWoZgfMW4Ktees89GTh0=
github.com/redpanda-data/helm-charts v0.0.0-20241015140509-56e8cc7a5e8a/go.mod h1:TqCaTv9K8+VbAeZHlR/OqHVksTlj0HYAzDkUEtZNyZc=
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1 h1:Z1dclhzMIk83tZIa+aXqmojZZ2R03DvtXAfxWpWOqug=
github.com/redpanda-data/helm-charts v0.0.0-20241025092026-69353dfce9a1/go.mod h1:dmmGZo7DuHNnCy0QOykXN2sY9QI8kbdlkSKgIkCT978=
github.com/redpanda-data/helm-controller v0.37.3-0.20240119022335-c90fadbd044e h1:8HB05vSCY+0MwjT2DIVq6gJV5iw7nQNIDfMqcc1NEC8=
github.com/redpanda-data/helm-controller v0.37.3-0.20240119022335-c90fadbd044e/go.mod h1:jF5kbQy3qT/zufL27DE3lecfYTRWeAzSiVmrbDDQwUw=
github.com/redpanda-data/redpanda/src/go/rpk v0.0.0-20240827155712-244863ea0ae8 h1:uTQKqF8UPNxYxKBJ11VlG6Vt2l9ctkkeXsmmjHUSUG4=
Expand Down
Loading

0 comments on commit 87317b4

Please sign in to comment.