Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move config map to go #1268

Merged
merged 11 commits into from
Jun 17, 2024
Merged

Move config map to go #1268

merged 11 commits into from
Jun 17, 2024

Conversation

RafalKorepta
Copy link
Contributor

@RafalKorepta RafalKorepta commented May 5, 2024

ec39960 Add ability to annotate functions with ignore statement

99bb6e0 Fix typo from interation to iteration

b016311 Improve rewrite error reporting

6012dbb Add RegexReplaceAll sprig function

75f28bb Generate values to helm template

Methods improves readability of Redpanda configuration.

IsAccessKeyReferenceValid and IsSecretKeyReferenceValid functions are not used.

e0fad8c Fix for loops using selector expression

Previous implementation would panic as type assertion was hardcoded for ast.Ident.

2e38275 Change tiered helper function to Storage methods

6df252f Add Monitoring coreos.com custom resources to the scheme

When Prometheus Redpanda helm chart dependency is enabled, then DecodeYAMLFrom
is not working due to missing ServiceMonitor custom resource in scheme.

=== CONT  TestConfigMap/14-prometheus-no-tls-values.yaml
    chart_test.go:182:
        	Error Trace:	/Users/rafalkorepta/workspace/redpanda/helm-charts/charts/redpanda/chart_test.go:182
        	Error:      	Received unexpected error:
        	            	no kind "ServiceMonitor" is registered for version "monitoring.coreos.com/v1" in scheme "pkg/runtime/scheme.go:100"
        	Test:       	TestConfigMap/14-prometheus-no-tls-values.yaml
    --- FAIL: TestConfigMap/14-prometheus-no-tls-values.yaml (0.08s)

28d2f13 Convert config maps to go base implementation

97a80f2 Remove old config map implementation

Update Statefulset config map hash calculation

9ef78e3 Handle overprovisioned differently from the desire implementation

Changes to the input values are anti-pattern and relay on order of execution.
Our test shows that overprovioned are incorrectly set when CPU is bellowed
1000m.

Reference
(overproviosned is set to false)[https://github.com/redpanda-data/helm-charts/blob/5e30ecbaf15da44691402f6128194d6639652845/charts/redpanda/testdata/ci/22-gke-tiered-storage-with-creds-values.yaml.tpl.golden#L481]


Returns the SMP CPU count in whole cores, with minimum of 1, and sets
"resources.cpu.overprovisioned: true" when the "resources.cpu.cores" is less
than 1 core.

{{- $_ := set $.Values.resources.cpu "overprovisioned" true -}}

Follow up PRs

#1358
#1359

@RafalKorepta RafalKorepta force-pushed the rk/gh-1202/move-configmap-to-go branch 2 times, most recently from 45f71be to e795535 Compare May 22, 2024 09:10
@RafalKorepta RafalKorepta marked this pull request as ready for review May 22, 2024 09:11
@RafalKorepta RafalKorepta force-pushed the rk/gh-1202/move-configmap-to-go branch 2 times, most recently from 295c011 to 5704515 Compare May 22, 2024 09:29
@RafalKorepta RafalKorepta changed the title [WIP] Move config map to go Move config map to go May 22, 2024
Copy link
Contributor

@chrisseto chrisseto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huge PR and great work! Could we possibly split up some distinct pieces of this and merge it in one at a time? Extracting out all the gotohelm changes would be a great start and then we can make sure they get appropriate tests as well.

I'd like to talk about the proposed schema changes in a bit more depth as well. I think that would be a good candidate for being extracted into it's own commit/PR.

pkg/gotohelm/transpiler.go Outdated Show resolved Hide resolved
pkg/gotohelm/transpiler.go Outdated Show resolved Hide resolved
pkg/gotohelm/transpiler.go Outdated Show resolved Hide resolved
pkg/gotohelm/helmette/sprig.go Outdated Show resolved Hide resolved
pkg/gotohelm/helmette/sprig.go Outdated Show resolved Hide resolved
charts/redpanda/chart_test.go Outdated Show resolved Hide resolved
charts/redpanda/chart_test.go Outdated Show resolved Hide resolved
charts/redpanda/chart_test.go Outdated Show resolved Hide resolved
charts/redpanda/chart_test.go Outdated Show resolved Hide resolved
charts/redpanda/chart_test.go Outdated Show resolved Hide resolved
@RafalKorepta RafalKorepta force-pushed the rk/gh-1202/move-configmap-to-go branch 4 times, most recently from b2f27bc to b6bfb03 Compare May 23, 2024 10:52
@RafalKorepta RafalKorepta force-pushed the rk/gh-1202/move-configmap-to-go branch 7 times, most recently from 8767ad7 to 7cf3055 Compare June 13, 2024 16:14
pkg/gotohelm/transpiler.go Outdated Show resolved Hide resolved
charts/redpanda/configmap.tpl.go Outdated Show resolved Hide resolved
charts/redpanda/configmap.tpl.go Outdated Show resolved Hide resolved
charts/redpanda/values.go Outdated Show resolved Hide resolved
charts/redpanda/values.go Show resolved Hide resolved
charts/redpanda/values.go Outdated Show resolved Hide resolved
charts/redpanda/values.go Outdated Show resolved Hide resolved
charts/redpanda/chart_test.go Outdated Show resolved Hide resolved
charts/redpanda/configmap.tpl.go Outdated Show resolved Hide resolved
charts/redpanda/configmap.tpl.go Outdated Show resolved Hide resolved
pkg/helm/helm.go Outdated Show resolved Hide resolved
pkg/helm/helm.go Outdated
@@ -300,12 +304,18 @@ func (c *Client) Template(ctx context.Context, chart string, opts TemplateOption
// to set it ourselves.
client.ReleaseName = releaseName

previous := os.Getenv("HELM_CONFIG_HOME")
os.Setenv("HELM_CONFIG_HOME", path.Join(c.configHome, "helm-config"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to set this? I don't see anything reading this value

Copy link
Contributor Author

@RafalKorepta RafalKorepta Jun 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why it isn't picked up by the install action. I agree it might affect other parallel runs. Using other helm commands this env var is passed into helm cli subproces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that locate chart would work with

	chart, err = client.ChartPathOptions.LocateChart(chart, &cli.EnvSettings{
		RegistryConfig:   envOr("HELM_REGISTRY_CONFIG", helmpath.ConfigPath("registry/config.json")),
		RepositoryConfig: envOr("HELM_REPOSITORY_CONFIG", helmpath.ConfigPath("repositories.yaml")),
		RepositoryCache:  envOr("HELM_REPOSITORY_CACHE", helmpath.CachePath("repository")),
		Debug:            true,
	})

apparently the c.configHome needs to be injected into tree of those environment variables.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RafalKorepta RafalKorepta enabled auto-merge (rebase) June 13, 2024 17:58
Copy link
Contributor

@chrisseto chrisseto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are passing, let's merge and refactor from there!

@RafalKorepta RafalKorepta force-pushed the rk/gh-1202/move-configmap-to-go branch 5 times, most recently from 54894a0 to 079fd76 Compare June 16, 2024 00:04
@RafalKorepta RafalKorepta force-pushed the rk/gh-1202/move-configmap-to-go branch from 61579ed to 933db92 Compare June 17, 2024 09:13
Methods improves readability of Redpanda configuration.
Previous implementation would panic as type assertion was hardcoded for Ident.
When Prometheus Redpanda helm chart dependency is enabled, then DecodeYAMLFrom
is not working due to missing ServiceMonitor custom resource in scheme.
```
=== CONT  TestConfigMap/14-prometheus-no-tls-values.yaml
    chart_test.go:182:
        	Error Trace:	/Users/rafalkorepta/workspace/redpanda/helm-charts/charts/redpanda/chart_test.go:182
        	Error:      	Received unexpected error:
        	            	no kind "ServiceMonitor" is registered for version "monitoring.coreos.com/v1" in scheme "pkg/runtime/scheme.go:100"
        	Test:       	TestConfigMap/14-prometheus-no-tls-values.yaml
    --- FAIL: TestConfigMap/14-prometheus-no-tls-values.yaml (0.08s)
```

address := fmt.Sprintf("%s-%d", Fullname(dot), int(i))
if ptr.Deref(values.External.Domain, "") != "" {
// TODO: TPL DOES NOT WORK. Maybe tpl call could be removed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: tpl is now implemented

client, err := helm.New(helm.Options{ConfigHome: testutil.TempDir(t)})
require.NoError(t, err)

// Downloading Redpanda helm chart release is required as client.Template
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels fixable but we can worry about it later 👍

@RafalKorepta RafalKorepta merged commit 0082341 into main Jun 17, 2024
41 checks passed
@RafalKorepta RafalKorepta deleted the rk/gh-1202/move-configmap-to-go branch June 17, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants