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

Handle overprovisioned flag based on CPU values #1358

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

RafalKorepta
Copy link
Contributor

@RafalKorepta RafalKorepta commented Jun 17, 2024

Overprovisioned till Redpanda chart version 5.8.8 should be
set to true when Statefulset CPU request value is bellow 1000 mili cores.

Function redpanda-smp, that should overwrite overprovisioned flag,
was not called before setting overprovisioned flag.

Reference

redpanda-smp template -

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

redpanda-smp template invocation -
{{- get ((include "redpanda.RedpandaAdditionalStartFlags" (dict "a" (list . (include "redpanda-smp" .) ))) | fromJson) "r" | toYaml | nindent 4 }}

overprovisioned flag -
overprovisioned: {{ dig "cpu" "overprovisioned" false .Values.resources }}

@RafalKorepta RafalKorepta force-pushed the rk/gh-1202/fixes-overprovisioned-flag branch from 7f68e81 to 6d78e70 Compare June 17, 2024 10:01
@RafalKorepta RafalKorepta force-pushed the rk/gh-1202/fixes-overprovisioned-flag branch 3 times, most recently from 2f6f9eb to 2b3df38 Compare June 17, 2024 14:38
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.

Could you explain the original issue a bit more? Either in the commit message or as a comment somewhere. I don't think I fully understand why this is a fix?

@@ -238,6 +239,9 @@ func extractRedpandaConfigsFromConfigMap(manifests []byte) (*configmapRepresenta
}
result.redpanda = string(jsonR)

rex := regexp.MustCompile("\"overprovisioned\":(true|false)")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: This is kinda hidden right now and using regex to change up JSON always feels a bit sketchy. What about moving this up to line 205 and making it something like:

// If this path is deeper, use the `unstructured` package from k8s to access it
// Explain the old bug here. Now that it's considered fixed, we'll ignore this diff by pushing the correct value into the old conf
oldConf.redpanda["overprovisioned"] = newConf.redpanda["overprovisioned"]

Placing this right before the assertion will help group up all the logic that we start to accumulate like this.

You could also compute a JSON diff and remove the overprovisioned field from it in a similar way.

Copy link
Contributor Author

@RafalKorepta RafalKorepta Jun 17, 2024

Choose a reason for hiding this comment

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

What about moving this up to line 205

If this path is deeper, use the unstructured package from k8s to access it

I can not use on manifests as --- (YAML delimiter) is unrecognized by the unstructured unmarshall function.

Received unexpected error:
invalid character '-' in numeric literal

Placing this right before the assertion will help group up all the logic that we start to accumulate like this.

I agree.

You could also compute a JSON diff and remove the overprovisioned field from it in a similar way.

Which JSON diff function/library?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can not use on manifests as --- (YAML delimiter) is unrecognized by the unstructured unmarshall function.

Wouldn't that be a non issue around line 205 as you won't be working with manifests (multi-document YAMLs) but with the parsed out configmap values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

newConf.redpanda holds a raw redpanda config not K8S ConfigMap. When I'm unmarshall raw redpanda config I get the error:

Received unexpected error:
Object 'Kind' is missing in ...

//}
//
//return *rr.CPU.Overprovisioned
if int(rr.RedpandaCoresInMillis()) < 1000 {
Copy link
Contributor

Choose a reason for hiding this comment

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

There's a really interesting issue from @StephanDollberg on what the correct way to set this is. Curious if he (currently) has any suggestions on what we should be doing here.

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure I understand the full PR but this change only seems to be concerned with setups where we have less than one 1 core/1000 millicpus assigned to Redpanda?

In that case using overprovisioned unconditionally is the right thing to do.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's exactly what it is, I just didn't understand at the time 😓

Thank you for confirming! I was going to seek further guidance on the --overprovisioned flag but we'll do that at a later time.

Overprovisioned till Redpanda chart version 5.8.8 should be
set to `true` when Statefulset CPU request value is bellow 1000 mili cores.

Function `redpanda-smp`, that should overwrite `overprovisioned` flag,
was not called before setting `overprovisioned` flag.

Reference

redpanda-smp template - https://github.com/redpanda-data/helm-charts/blob/5f287d45a3bda2763896840e505fb3de82b968b6/charts/redpanda/templates/_helpers.tpl#L187
redpanda-smp template invocation - https://github.com/redpanda-data/helm-charts/blob/5f287d45a3bda2763896840e505fb3de82b968b6/charts/redpanda/templates/_configmap.tpl#L610
overprovisioned flag - https://github.com/redpanda-data/helm-charts/blob/5f287d45a3bda2763896840e505fb3de82b968b6/charts/redpanda/templates/_configmap.tpl#L607
@RafalKorepta RafalKorepta force-pushed the rk/gh-1202/fixes-overprovisioned-flag branch from 2b3df38 to e89b886 Compare June 17, 2024 18:50
@RafalKorepta RafalKorepta merged commit 5c3c3ad into main Jun 19, 2024
41 checks passed
@RafalKorepta RafalKorepta deleted the rk/gh-1202/fixes-overprovisioned-flag branch June 19, 2024 15:20
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.

3 participants