Skip to content

fix(k8s): move the mattermost database off the control plane #3647

Closed

Description

@dan-petty

Problem

The volume of claim mattermost/mattermost-db-1 stays on the control-plane node after #2147 moves the volumes of Grafana, the Prometheus server and Loki. #1634 asks to move every local-path volume off that node. No check sees this volume, and no tool moves it:

  • kubectl get pv on 2026-11-05 shows this volume, class local-path, reclaim policy Retain, bound to the control-plane node.
  • k8s/mattermost/database.yaml has instances: 1, no node affinity and no backup. The live Cluster has backup unset, and affinity holds only podAntiAffinityType: preferred.
  • tests/core/test_k8s_local_path_placement.py has "cloudnative-pg": () in CHART_CLAIMS, and its manifest check does not read a postgresql.cnpg.io Cluster. So the placement test passes with this volume on that node.
  • devops k8s volume move mattermost/mattermost-db-1 --plan refuses: "Pod mattermost-db-1 belongs to Cluster mattermost-db. The move can stop and start only a Deployment or a StatefulSet."

Expected

The volume of the Mattermost database is on a worker node, the data is complete, and the placement test fails when a CloudNativePG Cluster on a claim can run on the control-plane node.

Acceptance criteria

  • kubectl get pv shows the volume of the database on a worker node, and Mattermost reads its data after the move.
  • k8s/mattermost/database.yaml sets the required node affinity with node-role.kubernetes.io/control-plane DoesNotExist under spec.affinity.nodeAffinity.
  • tests/core/test_k8s_local_path_placement.py reads the CloudNativePG Cluster manifests, and fails when such an affinity is missing.
  • The move has a backup of the database first, and a person runs the steps that change the cluster.

Existing tool considered

CloudNativePG can make a new instance on another node through a replica or a restore from a backup, with spec.affinity on the Cluster. Use this procedure of the operator. Do not extend devops k8s volume move for this, because the operator owns the pods and the claim of the Cluster.

Related

#1634, #2147

Proposed design

Problem statement

The claim mattermost/mattermost-db-1 stays on the control-plane node. tests/core/test_k8s_local_path_placement.py has "cloudnative-pg": () in CHART_CLAIMS and reads no postgresql.cnpg.io Cluster, so the placement test passes with this volume on that node. This change makes the placement test read CloudNativePG Cluster manifests and fail when a Cluster on a claim can run on the control-plane node. The live move of the database needs a backup and a person. The manifest affinity would make the pod unschedulable before the move. This issue defers both to a new issue.

Acceptance criteria

Requirement: The check reads a CloudNativePG Cluster

The placement check SHALL treat a postgresql.cnpg.io/v1 Cluster document that sets spec.storage as a pod on a claim, and read its affinity from spec.affinity.

Scenario: A Cluster without the control-plane term

  • WHEN a test passes a Cluster document with spec.storage and a spec.affinity that has no node-role.kubernetes.io/control-plane DoesNotExist term in every required term
  • THEN the check reports the Cluster as a pod on a claim that does not keep off the control-plane node

Requirement: A Cluster with the term passes the check

The placement check SHALL accept a CloudNativePG Cluster whose spec.affinity holds the DoesNotExist term in every term of nodeSelectorTerms.

Scenario: A Cluster with the required term

  • WHEN a test passes a Cluster document with spec.storage and spec.affinity.nodeAffinity.requiredDuringSchedulingIgnoredDuringExecution.nodeSelectorTerms that each hold the term
  • THEN the check reports the Cluster as a pod on a claim that keeps off the control-plane node

Requirement: The expected manifest pods name the Cluster

EXPECTED_MANIFEST_PODS MUST name k8s/mattermost/database.yaml:Cluster/mattermost-db, so that a wrong path cannot pass by finding nothing.

Scenario: The check runs on the repository tree

  • WHEN test_every_manifest_pod_on_a_claim_keeps_off_the_control_plane_node runs
  • THEN the test reports no missing expected manifest pod

Requirement: The Mattermost Cluster is exempt until the move

_CONTROL_PLANE_CLAIM_EXEMPTIONS SHALL hold k8s/mattermost/database.yaml:Cluster/mattermost-db with a reason that names the deferred issue, until the database moves.

Scenario: The exemption is valid and the test passes

  • WHEN test_every_exemption_names_a_pod_on_a_claim_that_stays_on_any_node and test_every_manifest_pod_on_a_claim_keeps_off_the_control_plane_node run
  • THEN the check finds the Cluster, its affinity does not keep off the control-plane node, and the placement test reports no failure

Existing Tool Considered

No alternatives check has run. CloudNativePG covers the need: the operator applies spec.affinity to the database pods, and it can make an instance on a worker node from a replica or a restore. It lacks a command that moves the claim of an existing single-instance Cluster to another node, so a person must run the move with a backup. devops k8s volume move does not cover the need: the operator owns the pods and the claim, and the tool refuses the move.

Key questions

  • Which manifest holds the claim of the Mattermost database?: k8s/mattermost/database.yaml holds Cluster mattermost-db in namespace mattermost, with spec.storage.storageClass: local-path, spec.storage.size: 10Gi and spec.instances: 1. [sources: k8s/mattermost/database.yaml]
  • Does the check need an entry in CHART_CLAIMS for the cloudnative-pg chart?: No. The cloudnative-pg chart installs the operator and mounts no claim. The claim of the database comes from Cluster mattermost-db, which is a manifest, so the check reads it as a manifest pod. [sources: tests/core/test_k8s_local_path_placement.py, k8s/mattermost/database.yaml]
  • How does the placement check read the node affinity of a CloudNativePG Cluster?: Read spec.affinity of each postgresql.cnpg.io/v1 Cluster that sets spec.storage, and pass it to keeps_off_the_control_plane. (best practice) [sources: tests/core/test_k8s_local_path_placement.py, k8s/mattermost/database.yaml, tests/support/k8s_tree.py]
    • Chosen: Read spec.affinity of the Cluster. The operator applies spec.affinity to the database pods, and the existing check reads an affinity object.
    • Rejected: Extend devops k8s volume move. The operator owns the pods and the claim, so the tool refuses the move.
    • Rejected: Render the CloudNativePG chart and read its pods. The check reads files only and renders no chart.
  • How does the placement test pass until the database moves?: Add k8s/mattermost/database.yaml:Cluster/mattermost-db to _CONTROL_PLANE_CLAIM_EXEMPTIONS with a reason that names the deferred issue. The exemption test fails when the entry goes stale, so the deferred issue removes it. (best practice) [sources: tests/core/test_k8s_local_path_placement.py, k8s/README.md:356]
    • Chosen: Exempt the Cluster with a reason. The check sees the Cluster, and the exemption test forces its removal after the move.
    • Rejected: Add the affinity to the manifest now. The claim is on the control-plane node, so the pod would stay Pending and Mattermost would stop.
    • Rejected: Leave CloudNativePG out of the check. No check would see this volume, which is the defect.
  • How does a test prove the Cluster reading without a render?: Pass a literal Cluster document to the manifest check, and assert the result for an affinity with and without the DoesNotExist term. (best practice) [sources: tests/core/test_k8s_local_path_placement.py]
    • Chosen: A literal Cluster document in a unit test. The test runs offline and pins the spec.storage and spec.affinity paths.
    • Rejected: A temporary k8s/ tree on disk. It writes files, and the helpers read the real tree only.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-07: in-use.
The item already names this tool.
Tool: cloudnative-pg/cloudnative-pg (https://github.com/cloudnative-pg/cloudnative-pg), Apache-2.0, last activity 2026-11-07, maintained.

Activity

  1. added
    source/agent
    type/bug
    scope/k8s
    status/new
    value/medium
    on Nov 5, 2026
  2. devops-cli-service commented on Nov 5, 2026

    @devops-cli-service
    Contributor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

  3. added
    priority/p2-medium
    status/ready
    and removed
    status/new
    on Nov 5, 2026
  4. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at 6d12548 (see proposed design in issue body).

    Moved to new items: dan-petty/homelab#333.

  5. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Alternatives check: in-use

    Reason: The web searches returned no provider answer, so the check rests on the facts read for cloudnative-pg/cloudnative-pg and on the issue's own account of the operator. CloudNativePG is already the tool the issue names and uses: the operator applies spec.affinity to the database pods and can make an instance on a worker node from a replica or a restore, but it has no command that moves the local-path claim of the existing single-instance Cluster, so a person must take a backup and run the move.

    The item already names this tool.

    Tool: cloudnative-pg/cloudnative-pg (https://github.com/cloudnative-pg/cloudnative-pg)

    • License: Apache-2.0
    • Last activity: 2026-11-07
    • Maintained: yes

    Covers:

    • Applies spec.affinity to the database pods, so a Cluster can require a worker node with node-role.kubernetes.io/control-plane DoesNotExist
    • Makes a new instance on another node from a replica or a restore from a backup, which puts the data of the database on a worker node
    • Reads the affinity from spec.affinity of the postgresql.cnpg.io/v1 Cluster, which the placement check can inspect

    Lacks:

    • No command moves the claim of an existing single-instance Cluster: the local-path claim with reclaim policy Retain stays on the control-plane node until a person runs the backup and the move
    • Nothing in the operator makes tests/core/test_k8s_local_path_placement.py read a Cluster manifest and fail on a missing control-plane term; that check is this repository's own work
    • The affinity alone leaves the pod unschedulable while the claim stays on the control-plane node, so the manifest change must wait for the move

    Tools considered:

    Searches run:

    • CloudNativePG move cluster instance to another node local-path volume, results: 0
    • CloudNativePG replica cluster promote new node nodeAffinity control-plane, results: 0
    • CloudNativePG documentation affinity backup restore, results: 0
    • cloudnative-pg volume move local-path PVC new node procedure, results: 0

    Sources:

    Checked on 2026-11-07. A person decides what this means for the item. The check changes no label and closes no issue.

  6. devops-cli-service commented on Nov 9, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/3647-move-the-mattermost-database-off-the, draft pull request #4268. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 64000 tokens:

    1. Read CloudNativePG Clusters in the placement test: 12735 tokens
    2. State the Cluster rule and the two exemptions in k8s/README.md: 18295 tokens

    The default branch changed these paths that the plan names, after the commit that the planner read. Read the commits before you judge the plan:

    A model review of the plan found these points. They stop no draft, and a person judges them:

    • other at group 2: Group 2 replaces the whole exemption paragraph of k8s/README.md with the two entries, so it drops the rule that tells a person to move the volume and then remove the entry and add the affinity. The plan says it keeps the move procedure, but that rule is not the move procedure and no task keeps it. Evidence: "Move the volume as below. Then remove its entry and add the affinity to its values in one pull request."
    • other at pull_request_body and group 2: The plan says the gateway Cluster's exemption reason names the item that moves it, but fix(k8s): the placement rule fits the NVMe and covers CNPG clusters #3782 is the placement rule and the CNPG coverage of the test; the plan's own feasibility says fix(k8s): the placement rule fits the NVMe and covers CNPG clusters #3782 reads Clusters in the test and the README, so the reason does not name a move of llm-gateway-db. Evidence: "fix(k8s): the placement rule fits the NVMe and covers CNPG clusters"

    The runs of the planner and the review made 70 model request(s), and used 6307049 input tokens and 122460 output tokens. The tool calls, in order:

    1. read_spec({"capability":"local-path-volume-placement"})
    2. read_issue({"number":1634})
    3. read_issue({"number":2147})
    4. find_issues({"terms":"mattermost-db control plane"})
    5. search_code({"text":"postgresql.cnpg.io"})
    6. read_issue({"number":3782})
    7. read_issue({"number":3803})
    8. read_file({"path":"tests/invariants/test_k8s_manifests.py","start_line":830,"end_line":910})
    9. read_file({"path":"k8s/mattermost/database.yaml"})
    10. read_file({"path":"k8s/llm/gateway-db.yaml","start_line":55,"end_line":100})
    11. read_file({"path":"k8s/README.md","start_line":365,"end_line":392})
    12. search_code({"text":"ci docs"})
    13. file_symbols({"path":"tests/core/test_k8s_local_path_placement.py"})
    14. search_code({"text":"_CONTROL_PLANE_CLAIM_EXEMPTIONS"})
    15. search_code({"text":"EXPECTED_MANIFEST_PODS"})
    16. read_file({"path":"tests/core/test_k8s_local_path_placement.py","start_line":26,"end_line":36})
    17. list_files({"directory":""})
    18. read_file({"path":"tests/core/test_k8s_local_path_placement.py"})
    19. read_file({"path":"tests/core/test_k8s_local_path_placement.py","start_line":158,"end_line":400})
    20. read_file({"path":"k8s/README.md","start_line":350,"end_line":420})
    21. read_spec({"capability":"local-path-volume-placement"})
    22. read_issue({"number":3803})
    23. read_issue({"number":3782})
    24. search_code({"text":"ci docs"})
    25. list_files({"directory":"src/devops_cli/commands/ci"})
    26. read_file({"path":"docs/commands/ci.md","start_line":1,"end_line":220})
    27. search_code({"text":"postgresql.cnpg.io"})
    28. search_code({"text":"cnpg"})
    29. read_spec({"capability":"local-path-volume-placement","requirement":"A pod that mounts a claim does not run on the control-plane node"})
    30. read_file({"path":"tests/invariants/test_k8s_manifests.py","start_line":830,"end_line":900})
    31. read_file({"path":"docs/roadmap/plan-recheck.md"})
    32. read_file({"path":"docs/roadmap/plan-check.md"})
    33. search_code({"text":"SPEC_DELTA"})
    34. search_code({"text":"spec_delta"})
    35. search_code({"text":"def check_spec_delta"})
    36. search_code({"text":"skip_specs"})
    37. search_code({"text":"def docs"})
    38. search_code({"text":"REGENERATE_DOCUMENTS"})
    39. read_file({"path":"src/devops_cli/commands/ci.py","start_line":2120,"end_line":2210})
    40. search_code({"text":"\"docs\":"})
    41. search_code({"text":"get_check_spec"})
    42. search_code({"text":"sync_readme"})
    43. search_code({"text":"def get_check_specs"})
    44. read_file({"path":"src/devops_cli/commands/ci.py","start_line":727,"end_line":860})
    45. search_code({"text":"k8s/README.md"})
    46. read_issue({"number":1634})
    47. read_issue({"number":2147})
    48. read_file({"path":"k8s/llm/gateway-db.yaml","start_line":60,"end_line":100})
    49. read_file({"path":"tests/gate/k8s_checks/gateway_database.py"})
    50. references({"name":"3782"})
    51. references({"name":"3803"})
    52. find_issues({"terms":"mattermost-db control plane"})
    53. find_issues({"terms":"local-path placement"})
    54. read_file({"path":"src/devops_cli/commands/docs.py","start_line":60,"end_line":140})
    55. read_file({"path":"src/devops_cli/docs/generator.py","start_line":1380,"end_line":1440})
    56. search_code({"text":"def spec_delta_problems"})
    57. search_code({"text":"SPEC_DELTA"})
    58. search_code({"text":"skip_specs"})
    59. search_code({"text":"ProposalGate"})
    60. search_code({"text":"def _spec_delta_problems"})
    61. search_code({"text":"stage_problem_spec"})
    62. read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":740,"end_line":860})
    63. search_code({"text":"def _verify_problems"})
    64. search_code({"text":"stage_problem_verify"})
    65. read_file({"path":"src/devops_cli/roadmap/stage/stage_form.py"})
    66. search_code({"text":"def verification_problem"})
    67. read_file({"path":"src/devops_cli/roadmap/implement/implement_shell_policy.py","start_line":440,"end_line":540})
    68. search_code({"text":"ci test"})
    69. search_code({"text":"class GroupKind"})
    70. read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":430,"end_line":520})
    71. search_code({"text":"def _other_problems"})
    72. read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":520,"end_line":600})
    73. read_issue({"number":3985})
    74. search_code({"text":"mattermost-db"})
    75. search_code({"text":"weakened_checks"})
    76. search_code({"text":"def criterion_problems"})
    77. read_file({"path":"src/devops_cli/roadmap/stage/stage_criteria.py","start_line":180,"end_line":290})
    78. search_code({"text":"class StageCriterion"})
    79. read_file({"path":"src/devops_cli/roadmap/stage/stage_criteria.py","start_line":40,"end_line":120})
    80. search_code({"text":"def select_tests_for_sources"})
    81. read_file({"path":"src/devops_cli/core/test_selection.py","start_line":440,"end_line":560})
    82. search_code({"text":"gateway-db.yaml"})
    83. list_files({"directory":"k8s/argocd/apps"})
    84. search_code({"text":"3647"})
    85. list_files({"directory":"k8s/llm"})
    86. read_file({"path":"k8s/mattermost/database.yaml"})
    87. search_code({"text":"citation"})
    88. search_code({"text":"stage_problem_citation"})
    89. read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1180,"end_line":1310})
    90. search_code({"text":"def _dependencies_problems"})
    91. search_code({"text":"stage_problem_dependencies"})
    92. read_file({"path":"src/devops_cli/roadmap/stage/stage_change.py","start_line":1920,"end_line":2010})
    93. find_issues({"terms":"test_k8s_local_path_placement"})
    94. find_issues({"terms":"CNPG"})
    95. search_code({"text":"NOT_IN_RUNNER"})
    96. read_file({"path":"src/devops_cli/roadmap/runner_tools.py","start_line":1,"end_line":160})
    97. read_file({"path":"src/devops_cli/roadmap/runner_tools.py","start_line":160,"end_line":260})
    98. search_code({"text":"_ISSUE_DEPENDENCY"})
    99. search_code({"text":"def code_span_paths"})
    100. read_file({"path":"src/devops_cli/roadmap/stage/stage_paths.py","start_line":160,"end_line":230})
    101. read_file({"path":"openspec/changes/archive/2026-11-06-2147-the-volumes-of-grafana-the-prometheus/proposal.md"})
    102. read_file({"path":"src/devops_cli/roadmap/stage/stage_paths.py","start_line":1,"end_line":80})

    Tool calls: file_symbols=1 (empty=0), find_issues=5 (empty=1), list_files=4 (empty=0), read_file=34 (empty=0), read_issue=9 (empty=0), read_spec=3 (empty=0), references=2 (empty=0), search_code=44 (empty=4)

    The stage job read the open pull requests and their files in 1 GraphQL request(s).

  7. added 2 commits that reference this issue on Nov 9, 2026
  8. 2 remaining items

  9. added
    status/planned
    owner/service
    status/in-progress
    and removed
    status/planned
    on Nov 9, 2026
  10. added
    status/in-review
    and removed
    status/in-progress
    on Nov 10, 2026
  11. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Pull request #4304 is ready for review. The checks passed.

    Spend: 51 model requests, 1884675 input tokens, 16953 output tokens.

  12. removed
    status/in-review
    owner/service
    on Nov 10, 2026
  13. devops-cli-service commented on Nov 10, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-10 01:00 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/k8ssource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions