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

[kube-config-manager] Fix updating configmap by a hook #557

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

miklezzzz
Copy link
Contributor

@miklezzzz miklezzzz commented Jan 27, 2025

Overview

Updating the addon-operator's configmap by a hook had been broken after one of many refactorings. The module's config values would be updated in the operator's runtime, yet not in the configmap.
This pr mends that functional.

What this PR does / why we need it

Closes #536

Special notes for your reviewer

@miklezzzz miklezzzz added the bug Something isn't working label Jan 27, 2025
@miklezzzz miklezzzz self-assigned this Jan 27, 2025
Signed-off-by: Mikhail Scherba <[email protected]>
@miklezzzz miklezzzz force-pushed the fix-update-configmap branch from 34d39e6 to 9906f8a Compare January 27, 2025 09:58
@miklezzzz
Copy link
Contributor Author

hook config

bash-5.1# cat modules/001-sysctl-tuner/hooks/test-hook.sh 
#!/bin/bash

if [[ $1 == "--config" ]] ; then
  cat <<EOF
{
  "configVersion":"v1",
  "beforeHelm": 1,
  "afterHelm": 1,
  "afterDeleteHelm": 1
}
EOF
exit 0
fi

binding=$(jq -r '.[0].binding' "${BINDING_CONTEXT_PATH}")
echo "Binding: $binding"
if [[ $binding == "beforeHelm" ]]; then
cat > $CONFIG_VALUES_JSON_PATCH_PATH <<EOF
    [{"op":"add", "path":"/sysctlTuner/param11", "value":"value11"}]
EOF
echo "Patching: $binding"
fi

before

bash-5.1# ./addon-operator module values sysctl-tuner
env: testing2
param11: value11


kubectl get cm addon-operator -o yaml
apiVersion: v1
data:
  global: |
    param12: value12
    test: test
  sysctlTuner: |
    env: testing2
    param11: value11
  sysctlTunerEnabled: "true"
  testModule: |
    val: val1
kind: ConfigMap
metadata:
  name: addon-operator
  namespace: default

after

bash-5.1# ./addon-operator module values sysctl-tuner
env: testing2
param11: value11


kubectl get cm addon-operator -o yaml
apiVersion: v1
data:
  global: |
    param12: value12
    test: test
  sysctlTuner: |
    env: testing2
    param11: value11
  sysctlTunerEnabled: "true"
  testModule: |
    val: val1
kind: ConfigMap
metadata:
  name: addon-operator
  namespace: default

@miklezzzz miklezzzz marked this pull request as ready for review January 27, 2025 10:20
@miklezzzz
Copy link
Contributor Author

"error":"module hook 'v0.7.104/hooks/test-hook.sh': set kube module config failed: saving patch values in ModuleConfig is forbidden",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

using $CONFIG_VALUES_JSON_PATCH_PATH in someModule hooks but it not work
1 participant