Skip to content

fix(foundationdb): let tenant roles read the connection ConfigMap - #4148

Merged
Aleksei Sviridkin (lexfrei) merged 1 commit into
cozystack:mainfrom
yankawai:fix/foundationdb-tenant-config
Sep 18, 2026
Merged

Aleksei Sviridkin (lexfrei) merged 1 commit into
cozystack:mainfrom
yankawai:fix/foundationdb-tenant-config

Conversation

@yankawai

@yankawai europrinter (yankawai) commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

A tenant cannot connect to its own FoundationDB: the fdb-kubernetes-operator writes the cluster file into the <release>-config ConfigMap, but tenant subjects have no RBAC to read it and the dashboard resource map does not expose it, so there is no way to obtain the connection string without cluster-admin access.

This PR:

  • adds <release>-config to the dashboard resource map;
  • adds a Role/RoleBinding granting get/list/watch on exactly that ConfigMap to the tenant use access level (via the existing cozy-lib helper);
  • adds helm unittest coverage (make test, 6 tests).

Out of scope: FoundationDB currently exposes no Service, so clients still need in-cluster reachability to the coordinator pod IPs from the cluster file — that is a separate topic.

Summary by CodeRabbit

  • New Features
    • Added the FoundationDB configuration resource to the dashboard resource map.
    • Added read-only access for authorized tenant users and service accounts to view the configuration resource.
  • Bug Fixes
    • Ensured configuration access and resource visibility remain available when monitoring is disabled.
  • Tests
    • Added coverage to verify resource mapping, access permissions, and rendered chart output.

@github-actions github-actions Bot added size/L This PR changes 100-499 lines, ignoring generated files area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review kind/bug Categorizes issue or PR as related to a bug labels Sep 7, 2026
@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: cb4b8e1a-5157-4ad7-8168-011da929379c

📥 Commits

Reviewing files that changed from the base of the PR and between d3559d4 and 746dd97.

📒 Files selected for processing (3)
  • packages/apps/foundationdb/Makefile
  • packages/apps/foundationdb/templates/dashboard-resourcemap.yaml
  • packages/apps/foundationdb/tests/dashboard-resourcemap_test.yaml

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The FoundationDB dashboard resourcemap now includes the release ConfigMap and tenant read-only RBAC resources. A Helm test suite validates the rendered resources, RBAC subjects, monitoring behavior, and document counts.

Changes

FoundationDB dashboard access

Layer / File(s) Summary
Dashboard resource and RBAC
packages/apps/foundationdb/templates/dashboard-resourcemap.yaml
The resourcemap includes the release ConfigMap. A Role grants get, list, and watch access. A RoleBinding assigns access to tenant subjects with the "use" access level.
Dashboard resource validation
packages/apps/foundationdb/Makefile, packages/apps/foundationdb/tests/dashboard-resourcemap_test.yaml
The Makefile adds a helm unittest . target. Tests validate the ConfigMap resource, RBAC subjects, monitoring behavior, and rendered document counts.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 746dd

This change lets tenant users discover and read the release FoundationDB connection ConfigMap with narrowly scoped read-only access. The rendered RBAC and resource-map behavior are covered by Helm tests, with no remaining actionable merge risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: granting tenant roles read access to the FoundationDB connection ConfigMap.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yankawai
europrinter (yankawai) force-pushed the fix/foundationdb-tenant-config branch from 746dd97 to f72f2d0 Compare September 9, 2026 14:53

@scooby87 scooby87 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM (independent cozy-review pass).

RBAC scope is correct and minimal: namespace-scoped Role, resourceNames pinned to {{ .Release.Name }}-config, verbs limited to get/list/watch, bound at the use access level via the standard tenant helper. No wildcards, no cross-tenant leak. It is a 1:1 copy of the established postgres/clickhouse dashboard-resources pattern.

Verified: helm unittest 6/6; Role and RoleBinding render unconditionally (outside the monitoring guard), which is right since connection config must not depend on monitoring. Phase 5b clean — additive RBAC only, no name collisions on upgrade.

The operator stores the cluster file in the <release>-config ConfigMap,
but the dashboard resource map did not list it and no RBAC granted
tenant subjects access to it, so a tenant could not retrieve the
connection string for its own FoundationDB at all.

Add the ConfigMap to the dashboard resource map and create a
Role/RoleBinding scoped to exactly that ConfigMap (get/list/watch)
for the tenant use-level subjects. Add helm unittest coverage.

Signed-off-by: Yan Bondarenko <[email protected]>
@github-actions github-actions Bot added the area/database Issues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse) label Sep 18, 2026
@lexfrei
Aleksei Sviridkin (lexfrei) merged commit 5713b97 into cozystack:main Sep 18, 2026
16 checks passed
@lexfrei Aleksei Sviridkin (lexfrei) added the kind/backport Categorizes issue or PR as requiring a backport to the current release line label Sep 18, 2026
@github-actions

Copy link
Copy Markdown

Successfully created backport PR for release-1.6:

myasnikovdaniil added a commit that referenced this pull request Sep 23, 2026
…onnection ConfigMap (#4315)

# Description
Backport of #4148 to `release-1.6`.
Aleksei Sviridkin (lexfrei) added a commit that referenced this pull request Sep 30, 2026
#4612)

## What this PR does

Fixes #4611.

Since #4148 a tenant may read the `<release>-config` ConfigMap that
holds the FoundationDB cluster file, but the console has no view for
ConfigMaps, so the connection string was still reachable only with
kubectl.

Chart:

- `<release>-resourcemap` is rendered regardless of
`monitoring.enabled`, because the console now reads it;
- the tenant Role grants `get`, `list` and `watch` on
`<release>-resourcemap` next to `<release>-config`, still by
`resourceNames`, with no wider ConfigMap access.

Console:

- the application page gets a ConfigMaps tab when the application's
resource map lists at least one ConfigMap in the same namespace;
- each listed ConfigMap is read and watched with a `metadata.name` field
selector, which RBAC checks against `resourceNames`, so a tenant never
needs `list` on all ConfigMaps;
- values are shown as plain text with a copy button, the cluster file
needs no decoding;
- a resource map that is missing or forbidden hides the tab, a listed
ConfigMap that cannot be read shows the API error instead of looking
empty, and a malformed map or an invalid name is reported.

The tab is generic, but today only FoundationDB ships a resource map, so
it is the only application that gets it.

#3490 keeps `monitoring.enabled` as the switch for the resource map and
asks whether the map should render unconditionally. This PR answers that
for FoundationDB by rendering it always, so the wording in #3490 would
need to follow if both land.

Tests: `helm unittest` for the chart (6 tests), `tsc --noEmit`, `vitest
run` (438 tests in 60 files) and `eslint` on the changed files pass. The
new tests cover reading only the listed names in the active namespace,
the watch, copying, a clipboard failure, a read denial, and malformed
maps. The chart renders with `monitoring.enabled` true and false.

### Screenshots

The ConfigMaps tab of a FoundationDB application, rendered by the
console from this branch against a local stub API with synthetic data:

![ConfigMaps
tab](https://raw.githubusercontent.com/yankawai/cozystack/29ae3c94e539edc05b29700788a9b875b5a13d54/foundationdb-configmaps-tab.png)

### Downstream repositories

Walked the trigger map against the diff: it changes a FoundationDB chart
template and its test, and the console. No `values.yaml`,
`values.schema.json`, README, CRD or `hack/` file is touched. The
website FoundationDB page is generated from the chart README and says
nothing about connecting, and the Terraform provider does not read these
ConfigMaps. The console is vendored in this repository.

- [x] No downstream repository is affected by this change
- [ ] [cozystack/website](https://github.com/cozystack/website) -
follow-up:
- [ ]
[cozystack/terraform-provider-cozystack](https://github.com/cozystack/terraform-provider-cozystack)
- follow-up:
- [ ]
[cozystack/ansible-cozystack](https://github.com/cozystack/ansible-cozystack)
- follow-up:
- [ ] [cozystack/ccp](https://github.com/cozystack/ccp) - follow-up:
- [ ] [cozystack/talm](https://github.com/cozystack/talm) - follow-up:
- [ ] [cozystack/cozyhr](https://github.com/cozystack/cozyhr) -
follow-up:
- [ ] [cozystack/cozy-proxy](https://github.com/cozystack/cozy-proxy) -
follow-up:
- [ ]
[cozystack/cozystack-telemetry-server](https://github.com/cozystack/cozystack-telemetry-server)
- follow-up:
- [ ]
[cozystack/external-apps-example](https://github.com/cozystack/external-apps-example)
- follow-up:
- [ ] [cozystack/examples](https://github.com/cozystack/examples) -
follow-up:
- [ ] [cozystack/community](https://github.com/cozystack/community) -
follow-up:

### Release note

```release-note
fix(dashboard, foundationdb): the application page shows the FoundationDB connection ConfigMap with the cluster file to tenants who may read it
```


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **New Features**
* Application details now include a ConfigMaps tab when configuration
maps are available. View their values and copy them to the clipboard.
  * The tab displays loading, empty, unavailable, and error states.
* **Bug Fixes**
* The resource map remains available when monitoring is disabled, and
its access permissions are included.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/database Issues or PRs related to managed databases (postgres, mariadb, redis, etcd, kafka, clickhouse) area/uncategorized PR auto-labeler could not map title scope to a known area/*; please review kind/backport Categorizes issue or PR as requiring a backport to the current release line kind/bug Categorizes issue or PR as related to a bug size/L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants