Skip to content

MK8S-184 - Add restart script to react when control plane ingress change#4822

Merged
bert-e merged 12 commits intodevelopment/133.0from
feature/MK8S-184-restart-script
Mar 25, 2026
Merged

MK8S-184 - Add restart script to react when control plane ingress change#4822
bert-e merged 12 commits intodevelopment/133.0from
feature/MK8S-184-restart-script

Conversation

@ChengYanJin
Copy link
Copy Markdown
Contributor

@ChengYanJin ChengYanJin commented Mar 17, 2026

Component: Salt

Context:
This PR adds an automatic restart mechanism for the oauth2-proxy deployments when the CA certificate secret changes.

When OIDC authentication is enabled, the oauth2-proxy pods use a k8s-sidecar to sync the CA certificate from a Kubernetes secret. However, when the CA secret is updated (e.g., certificate rotation), the oauth2-proxy process keeps using the old CA loaded in memory, causing authentication failures.

Summary:
Leverage the k8s-sidecar's SCRIPT feature to run a Python script whenever the CA secret changes. The script:

  1. Computes a SHA256 hash of the CA files on disk
  2. Compares it with the previously stored hash
  3. If changed, triggers a rolling restart of the deployment via the Kubernetes API (same as kubectl rollout restart)
  4. On initial startup, saves the hash and skips restart to avoid a restart loop

Acceptance criteria:

When the CA secret data changes, the oauth2-proxy pods (prometheus and alertmanager) are automatically restarted via a rolling restart.


[Closes: #MK8S-184]

@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Mar 17, 2026

Hello chengyanjin,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Mar 17, 2026

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

Peer approvals must include at least 1 approval from the following list:

@ChengYanJin ChengYanJin force-pushed the feature/MK8S-184-restart-script branch from 1a109d4 to 103f7c0 Compare March 18, 2026 09:21
@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Mar 18, 2026

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

Peer approvals must include at least 1 approval from the following list:

@ChengYanJin ChengYanJin force-pushed the feature/MK8S-184-restart-script branch from 103f7c0 to 8498223 Compare March 18, 2026 09:33
@ChengYanJin ChengYanJin force-pushed the feature/MK8S-184-restart-script branch from 8498223 to 092df26 Compare March 18, 2026 09:45
@ChengYanJin ChengYanJin marked this pull request as ready for review March 18, 2026 10:19
@ChengYanJin ChengYanJin requested a review from a team as a code owner March 18, 2026 10:19
@ChengYanJin ChengYanJin force-pushed the feature/MK8S-184-restart-script branch from a6bb1c3 to 42b899c Compare March 18, 2026 10:59
Copy link
Copy Markdown
Collaborator

@TeddyAndrieux TeddyAndrieux left a comment

Choose a reason for hiding this comment

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

I do not really like using script in configmap like that 😕 but I don't have any quick easy way to handle it so ... let's go like this for now

@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Mar 19, 2026

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

Peer approvals must include at least 1 approval from the following list:

@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Mar 23, 2026

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

Peer approvals must include at least 1 approval from the following list:

@ChengYanJin ChengYanJin force-pushed the feature/MK8S-184-restart-script branch 3 times, most recently from 1db7250 to a7ff0d9 Compare March 23, 2026 13:48
@ChengYanJin ChengYanJin force-pushed the feature/MK8S-184-restart-script branch from a7ff0d9 to ab2f406 Compare March 23, 2026 13:52
@@ -0,0 +1,208 @@
"""Tests for the restart-on-ca-change.py script."""
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing __init__.py in salt/tests/unit/scripts/. Every other test subdirectory under salt/tests/unit/ has one (e.g. formulas/, mocks/). Without it, pytest with the default import mode may not discover these tests.

— Claude Code

- name: restart-script
configMap:
name: oidc-proxy-restart-script
defaultMode: "0555"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

defaultMode should be an integer (0555), not a string ("0555"). Kubernetes accepts strings here but interprets them as decimal — "0555" becomes octal 01053 (decimal 555), which is not what you want. Use an unquoted integer instead.

— Claude Code

- name: restart-script
configMap:
name: oidc-proxy-restart-script
defaultMode: "0555"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same issue: defaultMode should be an integer, not a string. "0555" is interpreted as decimal 555 (octal 01053), not as octal 0555.

— Claude Code

@claude
Copy link
Copy Markdown

claude bot commented Mar 24, 2026

  • defaultMode: "0555" in both deployment templates (oidc-proxy-prometheus.sls:111, oidc-proxy-alertmanager.sls:112) uses a quoted string instead of an integer. In YAML 1.1 (PyYAML/Salt), unquoted 0555 is parsed as octal (365 decimal = rwxr-xr-x), but "0555" is a string that may be coerced to decimal 555 (octal 01053) or rejected by the K8s API. Remove the quotes to get the intended permissions.
    • Change defaultMode: "0555" to defaultMode: 0555 in both files
  • Missing __init__.py in salt/tests/unit/scripts/ — all other test subdirectories under salt/tests/unit/ have one, and without it pytest may not discover these tests.
    • Add an empty __init__.py to salt/tests/unit/scripts/

      Review by Claude Code

@ChengYanJin ChengYanJin force-pushed the feature/MK8S-184-restart-script branch from 17e78ea to 60f0f10 Compare March 24, 2026 15:06
- name: restart-script
configMap:
name: oidc-proxy-restart-script
defaultMode: "0555"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

defaultMode in Kubernetes expects an integer, not a string. 0555 quoted is a YAML string and may be passed as-is to the API, where it could be rejected or misinterpreted. Use the unquoted octal literal 0555 (YAML interprets this as decimal 365) or just 365. The existing thanos-chart.sls uses defaultMode: 420 (integer) as a reference.

— Claude Code

- name: restart-script
configMap:
name: oidc-proxy-restart-script
defaultMode: "0555"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same issue: defaultMode should be an integer, not a string.

— Claude Code

@claude
Copy link
Copy Markdown

claude bot commented Mar 24, 2026

  • defaultMode: "0555" is a YAML string but the Kubernetes API expects an integer for this field. This could cause the manifest to be rejected or the mode to be misinterpreted. Use defaultMode: 0555 (unquoted octal, = 365 decimal) or defaultMode: 365. Affects both oidc-proxy-prometheus.sls and oidc-proxy-alertmanager.sls.
    - Remove the quotes around 0555 in both deployment specs

    Review by Claude Code

- name: restart-script
configMap:
name: oidc-proxy-restart-script
defaultMode: "0555"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

defaultMode expects an integer, not a string. "0555" will be passed as the string "0555" to the Kubernetes API, which expects a decimal integer. Octal 0555 = decimal 365. The rest of the codebase uses unquoted decimal integers (e.g., defaultMode: 420 for 0644).

— Claude Code

- name: restart-script
configMap:
name: oidc-proxy-restart-script
defaultMode: "0555"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Same defaultMode issue — should be an unquoted decimal integer 365 instead of the string "0555".

— Claude Code

@claude
Copy link
Copy Markdown

claude bot commented Mar 24, 2026

  • defaultMode: "0555" in both oidc-proxy-prometheus.sls and oidc-proxy-alertmanager.sls passes a string instead of an integer to the Kubernetes API. The rest of the codebase uses unquoted decimal integers (e.g., 420 for octal 0644). Use defaultMode: 365 (decimal for octal 0555).
    • oidc-proxy-prometheus.sls:111
    • oidc-proxy-alertmanager.sls:112

Review by Claude Code

Copy link
Copy Markdown
Collaborator

@TeddyAndrieux TeddyAndrieux left a comment

Choose a reason for hiding this comment

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

LGTM

@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Mar 25, 2026

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

Peer approvals must include at least 1 approval from the following list:

@ChengYanJin
Copy link
Copy Markdown
Contributor Author

/approve

@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Mar 25, 2026

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

Peer approvals must include at least 1 approval from the following list:

The following options are set: approve

Copy link
Copy Markdown
Contributor

@MonPote MonPote left a comment

Choose a reason for hiding this comment

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

LGTM

@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Mar 25, 2026

In the queue

The changeset has received all authorizations and has been added to the
relevant queue(s). The queue(s) will be merged in the target development
branch(es) as soon as builds have passed.

The changeset will be merged in:

  • ✔️ development/133.0

The following branches will NOT be impacted:

  • development/123.0
  • development/124.0
  • development/124.1
  • development/125.0
  • development/126.0
  • development/127.0
  • development/128.0
  • development/129.0
  • development/130.0
  • development/131.0
  • development/132.0
  • development/2.0
  • development/2.1
  • development/2.10
  • development/2.11
  • development/2.2
  • development/2.3
  • development/2.4
  • development/2.5
  • development/2.6
  • development/2.7
  • development/2.8
  • development/2.9

There is no action required on your side. You will be notified here once
the changeset has been merged. In the unlikely event that the changeset
fails permanently on the queue, a member of the admin team will
contact you to help resolve the matter.

IMPORTANT

Please do not attempt to modify this pull request.

  • Any commit you add on the source branch will trigger a new cycle after the
    current queue is merged.
  • Any commit you add on one of the integration branches will be lost.

If you need this pull request to be removed from the queue, please contact a
member of the admin team now.

The following options are set: approve

@bert-e
Copy link
Copy Markdown
Contributor

bert-e commented Mar 25, 2026

I have successfully merged the changeset of this pull request
into targetted development branches:

  • ✔️ development/133.0

The following branches have NOT changed:

  • development/123.0
  • development/124.0
  • development/124.1
  • development/125.0
  • development/126.0
  • development/127.0
  • development/128.0
  • development/129.0
  • development/130.0
  • development/131.0
  • development/132.0
  • development/2.0
  • development/2.1
  • development/2.10
  • development/2.11
  • development/2.2
  • development/2.3
  • development/2.4
  • development/2.5
  • development/2.6
  • development/2.7
  • development/2.8
  • development/2.9

Please check the status of the associated issue MK8S-184.

Goodbye chengyanjin.

@bert-e bert-e merged commit 2ecf9ec into development/133.0 Mar 25, 2026
31 checks passed
@bert-e bert-e deleted the feature/MK8S-184-restart-script branch March 25, 2026 16:02
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.

4 participants