Skip to content

CNTRLPLANE-3237: test/library/encryption/kms: add mock KMS plugin wrapper binary#2173

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
p0lyn0mial:kms-upstream-plugin-wrapper
Apr 27, 2026
Merged

CNTRLPLANE-3237: test/library/encryption/kms: add mock KMS plugin wrapper binary#2173
openshift-merge-bot[bot] merged 1 commit into
openshift:masterfrom
p0lyn0mial:kms-upstream-plugin-wrapper

Conversation

@p0lyn0mial
Copy link
Copy Markdown
Contributor

@p0lyn0mial p0lyn0mial commented Apr 23, 2026

Summary by CodeRabbit

  • New Features

    • Adds a lightweight wrapper executable in the mock KMS image that initializes SoftHSM, validates required flags, and launches the upstream plugin.
  • Documentation

    • README updated to document both binaries, wrapper behavior, and a sample invocation.
  • Chores

    • Image build split into upstream and wrapper stages; build script and deploy tooling updated to produce and reference both images and to load embedded test assets.

@openshift-ci openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 23, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 23, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a Go wrapper CLI and multi-stage Docker build producing a wrapper image layered on the upstream mock KMS plugin, updates the build script to build upstream then wrapper, adds an embedded-asset reader helper, and documents the wrapper in the README.

Changes

Cohort / File(s) Summary
Dockerfile & build script
test/library/encryption/kms/k8s-mock-plugin/Dockerfile, test/library/encryption/kms/k8s-mock-plugin/build-from-k8s.sh
New multi-stage Dockerfile: builds the Go wrapper in a golang:1.25 builder (CGO disabled, GOOS=linux, GOARCH from TARGETARCH) and copies the binary into a runtime image via --build-arg UPSTREAM_IMAGE. Build script updated to first build/tag upstream (UPSTREAM_IMAGE_TAG) then build the wrapper image with UPSTREAM_IMAGE arg; messaging and tagging adjusted.
Wrapper executable
test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go
New Go CLI entrypoint: parses/validates flags (requires --listen-addr, --vault-address; restricts --log-level), logs flags, initializes SoftHSM from embedded ConfigMap assets (writes /etc/softhsm-config.json, ensures token dir, decodes+extracts base64 token tarball), then execs upstream /usr/local/bin/mock-kms-plugin with constructed args.
Docs
test/library/encryption/kms/k8s-mock-plugin/README.md
README updated to document the wrapper binary layered onto the upstream executable, list upstream binary path, describe wrapper responsibilities (SoftHSM init, flag validation) and show example invocation.
Deployer & assets helper
test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go
Replaced upstream image digest reference with a new sha256; added exported ReadAsset(assetName string) ([]byte, error) to load an embedded YAML asset and render it with templating (provides Namespace: "default").

Sequence Diagram(s)

sequenceDiagram
    participant Wrapper as Wrapper\n(mock-kms-plugin-wrapper)
    participant Assets as Embedded\nAssets (ConfigMap + b64 tar)
    participant FS as Filesystem\n(/etc, /var/lib/softhsm)
    participant Shell as Shell\n(base64 | tar)
    participant Upstream as Upstream\n/usr/local/bin/mock-kms-plugin

    Wrapper->>Assets: Read and template asset (k8s_mock_kms_plugin_configmap.yaml)
    Wrapper->>FS: Write /etc/softhsm-config.json\nEnsure /var/lib/softhsm/tokens exists
    Wrapper->>Shell: Pipe base64 token string to "base64 -d | tar xzf -" in tokens dir
    Shell-->>FS: Extract token files into /var/lib/softhsm/tokens
    Wrapper->>Upstream: Construct args (-listen-addr, -config-file-path) and syscall.Exec
    Wrapper-->>Upstream: Replace process (exec)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

🚥 Pre-merge checks | ✅ 10 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Topology-Aware Scheduling Compatibility ⚠️ Warning DaemonSet manifest lacks topology awareness for HyperShift and Two-Node Arbiter clusters, causing scheduling failures and arbiter node contamination. Add topology awareness checks in deployer code, handle External topologies separately, use specific tolerations for control-plane taints, and exclude arbiter nodes with nodeAffinity.
✅ Passed checks (10 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding a mock KMS plugin wrapper binary to the test library's encryption/kms package.
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.
Stable And Deterministic Test Names ✅ Passed PR contains no Ginkgo test files with test definitions; only build infrastructure, documentation, and utility code.
Test Structure And Quality ✅ Passed This PR does not add or modify any Ginkgo test files. Changes consist of build infrastructure and supporting Go code utilities, not test suites.
Microshift Test Compatibility ✅ Passed PR adds KMS plugin infrastructure but contains no new Ginkgo e2e test files (no It(), Describe(), Context(), When() patterns found).
Single Node Openshift (Sno) Test Compatibility ✅ Passed This pull request does not add any new Ginkgo e2e tests. The changes include a command-line wrapper executable, library helper functions for deploying KMS plugins, a Dockerfile, documentation, and build scripts. No Ginkgo test blocks are present in any modified or new files.
Ote Binary Stdout Contract ✅ Passed The wrapper binary complies with the OTE Binary Stdout Contract. All logging uses Go's log package writing to stderr, not stdout, with no non-JSON stdout writes.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed This PR does not introduce new Ginkgo e2e tests; it only adds deployment helper code and documentation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 23, 2026
@p0lyn0mial p0lyn0mial force-pushed the kms-upstream-plugin-wrapper branch 2 times, most recently from 3e0f592 to eb8901b Compare April 23, 2026 08:09
}
}

func (o *options) addFlags(fs *pflag.FlagSet) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is where we would add more flags in the future.

return syscall.Exec(upstreamBinary, argv, os.Environ())
}

func initSoftHSM() error {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we embed the required assets to configure the plugin.

-f "${SCRIPT_DIR}/Dockerfile" \
"${SCRIPT_DIR}/../../../../.."

echo "Done. Image built: ${IMAGE_TAG}"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we will have one image that will have two binaries.

existing tests will work without any changes - they use the existing binary.

once we have the plugin lifecycle code we will stop deploying the upstream plugin from e2e tests.
the plugin lifecycle will call the wrapper (could be that we will have to rename the new binary) which doesn't require any extra configuration (the assets are embedded)

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go (1)

58-66: Return an error from ReadAsset instead of panicking.

This helper is now part of the wrapper startup path, so an asset lookup/render failure will crash the process with a stack trace and bypass run()'s normal error handling.

♻️ Proposed fix
-func ReadAsset(assetName string) []byte {
+func ReadAsset(assetName string) ([]byte, error) {
 	assetFunc := wrapAssetWithTemplateDataFunc(yamlTemplateData{Namespace: "default"})
-	raw, err := assetFunc(assetName)
-	if err != nil {
-		panic(err)
-	}
-	return raw
+	return assetFunc(assetName)
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go` around lines 58
- 66, The ReadAsset function currently panics on template/render failures;
change its signature to return ([]byte, error) instead of []byte, call
wrapAssetWithTemplateDataFunc(yamlTemplateData{Namespace: "default"}) as before,
and propagate the error from assetFunc(assetName) by returning nil, err on
failure (or raw, nil on success) so callers can handle the error instead of the
process crashing; update all callers of ReadAsset to handle the returned error
accordingly (e.g., check error and pass it up to run()'s error handling).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/library/encryption/kms/k8s-mock-plugin/Dockerfile`:
- Around line 11-12: The DaemonSet is invoking the upstream binary
"mock-kms-plugin" while the image copies a wrapper "mock-kms-plugin-wrapper";
either change the DaemonSet exec to call /usr/local/bin/mock-kms-plugin-wrapper
with the same flags (-listen-addr=unix:///var/run/kmsplugin/kms-{{ .Index
}}.sock -config-file-path=/etc/softhsm-config.json) so the wrapper is used, or
remove the COPY of /usr/local/bin/mock-kms-plugin-wrapper from the Dockerfile if
the wrapper is not needed; also ensure the wrapper binary is present and
executable in the image if you choose to call it.

In `@test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go`:
- Around line 40-42: The current logging in cmd.Flags().VisitAll prints raw flag
values (via pflag.Flag) which may expose secrets like --vault-address; update
the VisitAll handler to redact values by default and only print actual values
for a tiny allowlist of safe flags (e.g., define a safeFlags set and check
f.Name against it), otherwise log the flag name with a constant placeholder such
as "<redacted>" (e.g., use cmd.Flags().VisitAll with pflag.Flag f and
log.Printf("FLAG: --%s=%q", f.Name, "<redacted>") unless f.Name is in
safeFlags).
- Around line 95-99: The current token unpacking uses exec.Command to run "sh -c
'base64 -d | tar xzf -'" which shells out; replace that with in-process decoding
and extraction: in the function where tokensB64 and defaultTokensDir are used,
base64-decode tokensB64 using encoding/base64, then create a gzip.Reader and an
archive/tar.Reader to iterate entries and write files into defaultTokensDir
(creating directories as needed and preserving file modes), returning any errors
instead of relying on external stdout/stderr. Ensure to trim whitespace from
tokensB64 (strings.Fields or strings.TrimSpace) before decoding, check for
decode/gzip/tar errors, and set appropriate file permissions when writing files.

---

Nitpick comments:
In `@test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go`:
- Around line 58-66: The ReadAsset function currently panics on template/render
failures; change its signature to return ([]byte, error) instead of []byte, call
wrapAssetWithTemplateDataFunc(yamlTemplateData{Namespace: "default"}) as before,
and propagate the error from assetFunc(assetName) by returning nil, err on
failure (or raw, nil on success) so callers can handle the error instead of the
process crashing; update all callers of ReadAsset to handle the returned error
accordingly (e.g., check error and pass it up to run()'s error handling).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 9b33970f-242f-41da-8d1e-3d2d5d587390

📥 Commits

Reviewing files that changed from the base of the PR and between 18e7937 and eb8901b.

📒 Files selected for processing (5)
  • test/library/encryption/kms/k8s-mock-plugin/Dockerfile
  • test/library/encryption/kms/k8s-mock-plugin/README.md
  • test/library/encryption/kms/k8s-mock-plugin/build-from-k8s.sh
  • test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go
  • test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go

Comment thread test/library/encryption/kms/k8s-mock-plugin/Dockerfile Outdated
Comment thread test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go Outdated
Comment thread test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go
@p0lyn0mial p0lyn0mial marked this pull request as ready for review April 23, 2026 08:26
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 23, 2026
@p0lyn0mial
Copy link
Copy Markdown
Contributor Author

/hold

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 23, 2026
@openshift-ci openshift-ci Bot requested review from bertinatto and dgrisonnet April 23, 2026 08:27
@p0lyn0mial p0lyn0mial force-pushed the kms-upstream-plugin-wrapper branch 2 times, most recently from 74a6c42 to 7f5ef4f Compare April 23, 2026 08:42
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go`:
- Around line 25-28: The options.vaultAddress field is validated as required but
never used in run(); either pass it into the upstream binary invocation or stop
requiring it. Fix by updating run() (or the code that builds the upstream exec
args in main/run) to include "--vault-address", options.vaultAddress among the
command-line args passed to the upstream process (e.g., when constructing args
for exec.Command), or if the upstream does not need it yet, remove the required
validation and the related flag requirement that checks options.vaultAddress so
the flag is optional; refer to the options struct, the vaultAddress field, and
the run() function to locate where to add the arg or remove the validation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 57b77e3a-3212-4993-a144-c1df92a9f384

📥 Commits

Reviewing files that changed from the base of the PR and between eb8901b and 7f5ef4f.

📒 Files selected for processing (5)
  • test/library/encryption/kms/k8s-mock-plugin/Dockerfile
  • test/library/encryption/kms/k8s-mock-plugin/README.md
  • test/library/encryption/kms/k8s-mock-plugin/build-from-k8s.sh
  • test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go
  • test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/library/encryption/kms/k8s-mock-plugin/README.md

Comment on lines +25 to +28
type options struct {
vaultAddress string
listenAddr string
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

--vault-address is required but never used.

The vaultAddress field is validated as required (line 60-62) but never referenced in run(). The upstream binary is only invoked with --listen-addr and --config-file-path. Either:

  1. Pass --vault-address to the upstream binary if it needs it, or
  2. Remove the flag requirement if it's not needed yet.
Option A: If vault-address should be passed to upstream
 	upstreamArgs := []string{
 		"-listen-addr=" + o.listenAddr,
 		"-config-file-path=" + defaultConfigPath,
+		"-vault-address=" + o.vaultAddress,
 	}
Option B: If vault-address is for future use, don't require it yet
 func (o *options) validate() error {
-	if o.vaultAddress == "" {
-		return fmt.Errorf("--vault-address must be set")
-	}
 	if o.listenAddr == "" {
 		return fmt.Errorf("--listen-addr must be set")
 	}
 	return nil
 }

Also applies to: 54-57, 59-67

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go` around lines 25
- 28, The options.vaultAddress field is validated as required but never used in
run(); either pass it into the upstream binary invocation or stop requiring it.
Fix by updating run() (or the code that builds the upstream exec args in
main/run) to include "--vault-address", options.vaultAddress among the
command-line args passed to the upstream process (e.g., when constructing args
for exec.Command), or if the upstream does not need it yet, remove the required
validation and the related flag requirement that checks options.vaultAddress so
the flag is optional; refer to the options struct, the vaultAddress field, and
the run() function to locate where to add the arg or remove the validation.

Comment thread test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go Outdated
Comment thread test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go Outdated
@p0lyn0mial p0lyn0mial force-pushed the kms-upstream-plugin-wrapper branch from 7f5ef4f to b262d27 Compare April 23, 2026 09:59
@p0lyn0mial p0lyn0mial changed the title test/library/encryption/kms: add mock KMS plugin wrapper binary CNTRLPLANE-3237: test/library/encryption/kms: add mock KMS plugin wrapper binary Apr 23, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 23, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 23, 2026

@p0lyn0mial: This pull request references CNTRLPLANE-3237 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary by CodeRabbit

  • New Features

  • Adds a thin wrapper executable for the Mock KMS plugin that validates required flags, initializes SoftHSM with embedded tokens, and launches the upstream plugin.

  • Documentation

  • Clarifies build output as two binaries (upstream + wrapper) and adds a "Wrapper" section with usage examples and sample commands.

  • Chores

  • Build process now produces separate upstream and wrapper images via a two-step build pipeline.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
test/library/encryption/kms/k8s-mock-plugin/Dockerfile (2)

11-12: Harden final image runtime user (currently implicit root).

Final stage does not declare USER, so runtime is root by default. The wrapper writes to /etc/softhsm-config.json and /var/lib/softhsm/tokens, which require non-root ownership. Consider running as non-root after preparing these writable paths.

Example hardening direction
 FROM ${UPSTREAM_IMAGE}
 COPY --from=builder /workspace/mock-kms-plugin-wrapper /usr/local/bin/
+RUN mkdir -p /var/lib/softhsm/tokens /etc \
+    && chown -R 65532:65532 /var/lib/softhsm /etc /usr/local/bin/mock-kms-plugin-wrapper
+USER 65532:65532
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/library/encryption/kms/k8s-mock-plugin/Dockerfile` around lines 11 - 12,
Final Docker stage runs as root by default and the wrapper binary
mock-kms-plugin-wrapper writes to /etc/softhsm-config.json and
/var/lib/softhsm/tokens; update the final stage to create a non-root user/group
(e.g., kmsuser), mkdir and chown the required writable paths
(/etc/softhsm-config.json parent and /var/lib/softhsm/tokens) to that user, and
set USER to that non-root account before entry so the wrapper runs unprivileged;
ensure any files copied from the builder are also owned by the non-root account.

6-7: Set a safe default for TARGETARCH to avoid brittle builds.

The documented build method (./build-from-k8s.sh) uses plain docker build without --platform, which does not set the TARGETARCH variable. This causes GOARCH=${TARGETARCH} to expand to an empty string, breaking the go build command. Add a default value (amd64) to ensure builds succeed.

Proposed patch
-ARG TARGETARCH
-RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -mod=vendor \
+ARG TARGETARCH=amd64
+RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH:-amd64} go build -mod=vendor \
     -o mock-kms-plugin-wrapper \
     ./test/library/encryption/kms/k8s-mock-plugin/wrapper/
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/library/encryption/kms/k8s-mock-plugin/Dockerfile` around lines 6 - 7,
The build breaks when TARGETARCH is empty; update the Dockerfile to provide a
safe default so GOARCH isn't empty: change the ARG TARGETARCH declaration to
include a default (e.g., ARG TARGETARCH=amd64) and ensure the RUN that invokes
go build (the line using CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH}) will
therefore always have a valid GOARCH; locate the ARG TARGETARCH and the RUN line
in the Dockerfile and set the default as described.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/library/encryption/kms/k8s-mock-plugin/Dockerfile`:
- Around line 11-12: Final Docker stage runs as root by default and the wrapper
binary mock-kms-plugin-wrapper writes to /etc/softhsm-config.json and
/var/lib/softhsm/tokens; update the final stage to create a non-root user/group
(e.g., kmsuser), mkdir and chown the required writable paths
(/etc/softhsm-config.json parent and /var/lib/softhsm/tokens) to that user, and
set USER to that non-root account before entry so the wrapper runs unprivileged;
ensure any files copied from the builder are also owned by the non-root account.
- Around line 6-7: The build breaks when TARGETARCH is empty; update the
Dockerfile to provide a safe default so GOARCH isn't empty: change the ARG
TARGETARCH declaration to include a default (e.g., ARG TARGETARCH=amd64) and
ensure the RUN that invokes go build (the line using CGO_ENABLED=0 GOOS=linux
GOARCH=${TARGETARCH}) will therefore always have a valid GOARCH; locate the ARG
TARGETARCH and the RUN line in the Dockerfile and set the default as described.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a78bf77c-cfa3-4d5f-abf7-a136076e7bc6

📥 Commits

Reviewing files that changed from the base of the PR and between 7f5ef4f and b262d27.

📒 Files selected for processing (5)
  • test/library/encryption/kms/k8s-mock-plugin/Dockerfile
  • test/library/encryption/kms/k8s-mock-plugin/README.md
  • test/library/encryption/kms/k8s-mock-plugin/build-from-k8s.sh
  • test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go
  • test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go
✅ Files skipped from review due to trivial changes (1)
  • test/library/encryption/kms/k8s-mock-plugin/README.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • test/library/encryption/kms/k8s-mock-plugin/build-from-k8s.sh
  • test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go
  • test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go

Comment thread test/library/encryption/kms/k8s-mock-plugin/build-from-k8s.sh
@gangwgr
Copy link
Copy Markdown
Contributor

gangwgr commented Apr 23, 2026

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 23, 2026
Comment thread test/library/encryption/kms/k8s-mock-plugin/Dockerfile
Comment thread test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go Outdated
Comment thread test/library/encryption/kms/k8s-mock-plugin/Dockerfile Outdated
Comment thread test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go
Comment thread test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go Outdated
Comment thread test/library/encryption/kms/k8s-mock-plugin/Dockerfile Outdated
@p0lyn0mial p0lyn0mial force-pushed the kms-upstream-plugin-wrapper branch from b262d27 to fdcd93c Compare April 27, 2026 08:32
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 27, 2026
@p0lyn0mial p0lyn0mial force-pushed the kms-upstream-plugin-wrapper branch from fdcd93c to 51ae953 Compare April 27, 2026 08:38
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go (1)

58-62: Avoid hardcoded namespace literal in ReadAsset.

At Line 60, "default" can drift from WellKnownUpstreamMockKMSPluginNamespace and makes this exported helper less predictable.

💡 Suggested tweak
 func ReadAsset(assetName string) ([]byte, error) {
-	assetFunc := wrapAssetWithTemplateDataFunc(yamlTemplateData{Namespace: "default"})
+	assetFunc := wrapAssetWithTemplateDataFunc(yamlTemplateData{
+		Namespace: WellKnownUpstreamMockKMSPluginNamespace,
+	})
 	return assetFunc(assetName)
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go` around lines 58
- 62, The ReadAsset helper currently hardcodes the namespace string "default";
replace that literal with the canonical constant
WellKnownUpstreamMockKMSPluginNamespace so the helper stays in sync with the
project-wide namespace. Update the call that constructs assetFunc
(wrapAssetWithTemplateDataFunc) to pass yamlTemplateData{Namespace:
WellKnownUpstreamMockKMSPluginNamespace} and ensure any imports or references
resolve to the defined constant.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go`:
- Around line 58-62: The ReadAsset helper currently hardcodes the namespace
string "default"; replace that literal with the canonical constant
WellKnownUpstreamMockKMSPluginNamespace so the helper stays in sync with the
project-wide namespace. Update the call that constructs assetFunc
(wrapAssetWithTemplateDataFunc) to pass yamlTemplateData{Namespace:
WellKnownUpstreamMockKMSPluginNamespace} and ensure any imports or references
resolve to the defined constant.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 20aa2e3d-01c6-4932-abd1-dbe47d3bb8d2

📥 Commits

Reviewing files that changed from the base of the PR and between b262d27 and fdcd93c.

📒 Files selected for processing (5)
  • test/library/encryption/kms/k8s-mock-plugin/Dockerfile
  • test/library/encryption/kms/k8s-mock-plugin/README.md
  • test/library/encryption/kms/k8s-mock-plugin/build-from-k8s.sh
  • test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go
  • test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go
✅ Files skipped from review due to trivial changes (1)
  • test/library/encryption/kms/k8s-mock-plugin/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go

@ardaguclu
Copy link
Copy Markdown
Member

Changes look good to me.
/lgtm
/retest
/hold
for @bertinatto

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 27, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go (1)

60-86: ⚠️ Potential issue | 🟡 Minor

Multiple required flags are validated but never used.

The following flags are validated as required but are never passed to the upstream binary in run():

  • vaultAddress
  • vaultNamespace
  • transitMount
  • transitKey
  • approleRoleID
  • approleSecretIDPath

The upstream mock KMS plugin only receives --listen-addr and --config-file-path. Either pass these flags to the upstream binary, remove the required validation if they're for future use, or document why they're validated but unused (e.g., to match the real Vault KMS plugin interface for compatibility testing).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go` around lines 60
- 86, The options.validate() enforces required flags (vaultAddress,
vaultNamespace, transitMount, transitKey, approleRoleID, approleSecretIDPath)
but run() only forwards --listen-addr and --config-file-path to the upstream
mock KMS; fix by either removing the required checks or by forwarding these
flags: update run() to append arguments like "--vault-address", o.vaultAddress,
"--vault-namespace", o.vaultNamespace, "--transit-mount", o.transitMount,
"--transit-key", o.transitKey, "--approle-role-id", o.approleRoleID and
"--approle-secret-id-path", o.approleSecretIDPath (if the upstream expects a
path, ensure the file exists or read/validate it beforehand); locate the options
struct, validate() and run() functions in main.go to implement the change
consistently and adjust tests/documentation accordingly.
🧹 Nitpick comments (1)
test/library/encryption/kms/k8s-mock-plugin/Dockerfile (1)

1-13: Consider: Running as non-root user (test infrastructure context).

Static analysis flags that the image runs as root (DS-0002). While this is test infrastructure and not production code, adding a non-root user could align with defense-in-depth practices. This is optional given the test-only scope.

♻️ Optional: Add non-root user
 FROM ${UPSTREAM_IMAGE}
 COPY --from=builder /workspace/mock-kms-plugin-wrapper /usr/local/bin/vault-kube-kms
+USER 65532:65532
 ENTRYPOINT ["/usr/local/bin/vault-kube-kms"]

Note: This depends on the upstream image having appropriate permissions and user setup.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/library/encryption/kms/k8s-mock-plugin/Dockerfile` around lines 1 - 13,
The image runs as root; add a non-root user and switch to it in the final stage
to follow defense-in-depth: in the Dockerfile ensure the built binary
mock-kms-plugin-wrapper (copied to /usr/local/bin/vault-kube-kms) is owned by a
non-root user (create a user/group, chown the binary) and then set USER to that
non-root account before ENTRYPOINT; you can create the user either in the final
stage (referencing the FROM ${UPSTREAM_IMAGE} stage) or ensure the upstream
image supports the UID/GID used, and keep ARG/TARGETARCH and builder steps
unchanged (symbols to edit: mock-kms-plugin-wrapper, vault-kube-kms, ENTRYPOINT,
FROM ${UPSTREAM_IMAGE}).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go`:
- Around line 60-86: The options.validate() enforces required flags
(vaultAddress, vaultNamespace, transitMount, transitKey, approleRoleID,
approleSecretIDPath) but run() only forwards --listen-addr and
--config-file-path to the upstream mock KMS; fix by either removing the required
checks or by forwarding these flags: update run() to append arguments like
"--vault-address", o.vaultAddress, "--vault-namespace", o.vaultNamespace,
"--transit-mount", o.transitMount, "--transit-key", o.transitKey,
"--approle-role-id", o.approleRoleID and "--approle-secret-id-path",
o.approleSecretIDPath (if the upstream expects a path, ensure the file exists or
read/validate it beforehand); locate the options struct, validate() and run()
functions in main.go to implement the change consistently and adjust
tests/documentation accordingly.

---

Nitpick comments:
In `@test/library/encryption/kms/k8s-mock-plugin/Dockerfile`:
- Around line 1-13: The image runs as root; add a non-root user and switch to it
in the final stage to follow defense-in-depth: in the Dockerfile ensure the
built binary mock-kms-plugin-wrapper (copied to /usr/local/bin/vault-kube-kms)
is owned by a non-root user (create a user/group, chown the binary) and then set
USER to that non-root account before ENTRYPOINT; you can create the user either
in the final stage (referencing the FROM ${UPSTREAM_IMAGE} stage) or ensure the
upstream image supports the UID/GID used, and keep ARG/TARGETARCH and builder
steps unchanged (symbols to edit: mock-kms-plugin-wrapper, vault-kube-kms,
ENTRYPOINT, FROM ${UPSTREAM_IMAGE}).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 4fbc97d4-2df2-4db2-aa64-b07016ef7ddc

📥 Commits

Reviewing files that changed from the base of the PR and between fdcd93c and 51ae953.

📒 Files selected for processing (5)
  • test/library/encryption/kms/k8s-mock-plugin/Dockerfile
  • test/library/encryption/kms/k8s-mock-plugin/README.md
  • test/library/encryption/kms/k8s-mock-plugin/build-from-k8s.sh
  • test/library/encryption/kms/k8s-mock-plugin/wrapper/main.go
  • test/library/encryption/kms/k8s_mock_kms_plugin_deployer.go
✅ Files skipped from review due to trivial changes (1)
  • test/library/encryption/kms/k8s-mock-plugin/README.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/library/encryption/kms/k8s-mock-plugin/build-from-k8s.sh

@p0lyn0mial p0lyn0mial force-pushed the kms-upstream-plugin-wrapper branch from 51ae953 to bff854c Compare April 27, 2026 09:06
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 27, 2026

// WellKnownUpstreamMockKMSPluginImage is the pre-built mock KMS plugin image.
WellKnownUpstreamMockKMSPluginImage = "quay.io/openshifttest/mock-kms-plugin@sha256:998e1d48eba257f589ab86c30abd5043f662213e9aeff253e1c308301879d48a"
WellKnownUpstreamMockKMSPluginImage = "quay.io/openshifttest/mock-kms-plugin@sha256:ab7a28ca60966753256db2d5d7df54e4fb7f4d9cf2cb6612056baf62eb997e37"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i'd like build an image and then update this line so that the test could use it.

Co-Authored-By: Lukasz Szaszkiewicz <lszaszki@redhat.com>
Co-Authored-By: gangwgr <rgangwar@redhat.com>
@ardaguclu
Copy link
Copy Markdown
Member

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 27, 2026
Copy link
Copy Markdown
Member

@bertinatto bertinatto left a comment

Choose a reason for hiding this comment

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

/hold cancel
/lgtm

All the parameters I need for the lifecycle code are working.

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 27, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 27, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, bertinatto, gangwgr, p0lyn0mial

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 27, 2026

@p0lyn0mial: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot Bot merged commit 8c0fa2b into openshift:master Apr 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants