Skip to content

Fixes on tests & kbs-cert#265

Open
Jakob-Naucke wants to merge 4 commits into
trusted-execution-clusters:mainfrom
Jakob-Naucke:kbs-cert-updates
Open

Fixes on tests & kbs-cert#265
Jakob-Naucke wants to merge 4 commits into
trusted-execution-clusters:mainfrom
Jakob-Naucke:kbs-cert-updates

Conversation

@Jakob-Naucke
Copy link
Copy Markdown
Contributor

@Jakob-Naucke Jakob-Naucke commented May 28, 2026

Sourcery comments were created upon already merged PR in testing.

  • Set SHELL in Makefile
  • Create Client just once in register servers
  • Print https when used
  • spelling

Drive-by:

  • attribution comment
  • allow longer creation for cert-manager in tests
  • forced server-side apply for RBACs in tests

Summary by Sourcery

Improve Kubernetes client handling for registration services and stabilize test and build configuration.

Bug Fixes:

  • Handle missing ca.crt data in register-server CA retrieval with proper error context.

Enhancements:

  • Instantiate the Kubernetes client once in the register and attestation key register servers and pass it via application state.
  • Log whether the registration servers are serving over HTTP or HTTPS.
  • Document the provenance of the status condition upsert helper function.

Build:

  • Set the Makefile SHELL to /bin/bash for more predictable script execution.

Documentation:

  • Fix a spelling error in the TLS usage documentation.

Tests:

  • Increase timeouts for test secret creation to reduce flakiness.
  • Force server-side apply for RBAC resources in tests to avoid client-side apply conflicts.

Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
have been seen to conflict

Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
@Jakob-Naucke Jakob-Naucke requested a review from alicefr May 28, 2026 17:00
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 28, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Jakob-Naucke

The full list of commands accepted by this bot can be found 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

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 28, 2026

Reviewer's Guide

Centralizes Kubernetes client creation for the register and attestation-key register servers, improves TLS-related logging, relaxes test timing and RBAC apply behavior, fixes Makefile shell and documentation typo, and tightens error handling and attribution comments.

Sequence diagram for centralized Kubernetes client usage in register server

sequenceDiagram
    participant RegisterServerMain as RegisterServerMain
    participant Client as Client
    participant Router as Router
    participant RegisterHandler as register_handler
    participant KubeAPI as KubernetesAPIServer

    RegisterServerMain->>Client: try_default()
    Client-->>RegisterServerMain: Client
    RegisterServerMain->>Router: new()
    RegisterServerMain->>Router: route(endpoint, get(register_handler))
    RegisterServerMain->>Router: with_state(Client)
    RegisterServerMain->>RegisterServerMain: axum_server::bind / bind_openssl

    RegisterHandler->>RegisterHandler: receives State(Client)
    RegisterHandler->>KubeAPI: get_trusted_execution_cluster(Client)
    KubeAPI-->>RegisterHandler: TrustedExecutionCluster
    RegisterHandler-->>RegisterServerMain: IntoResponse
Loading

File-Level Changes

Change Details Files
Reuse a single Kubernetes client instance in the register-server and improve CA retrieval error handling and TLS logging.
  • Inject a shared kube::Client via Axum state into the register handler instead of creating it per request
  • Create the Kubernetes client once in main, fail fast with a clear error message if it cannot be created
  • Log whether the register server is starting with HTTP or HTTPS based on TLS configuration
  • Replace an expect on missing ca.crt in the secret with anyhow::Context to produce better error messages
register-server/src/main.rs
Reuse a single Kubernetes client instance in the attestation-key-register server and adjust startup logging.
  • Inject a shared kube::Client via Axum state into the registration handler instead of creating it per request
  • Create the Kubernetes client once in main with a clear failure message if initialization fails
  • Log whether the attestation key registration server starts with HTTP or HTTPS depending on TLS usage
attestation-key-register/src/main.rs
Make e2e tests more robust by allowing more time for secrets and using server-side apply for RBAC manifests.
  • Increase wait time for key secrets (REG_SECRET, TRUSTEE_SECRET, ATT_REG_SECRET) from 15s to 60s when waiting for resource creation
  • Enable forced server-side apply (fssa) when applying RBAC manifests in tests
test_utils/src/lib.rs
Standardize build shell and fix documentation typo.
  • Set SHELL to /bin/bash in the Makefile to ensure consistent shell behavior for targets
  • Fix a spelling mistake in TLS usage docs from certifiate to certificate
Makefile
docs/usage/tls.md
Clarify origin of condition upsert logic in the operator.
  • Add an attribution comment to upsert_condition noting it is inspired by k8s.io/apimachinery/pkg/api/meta.SetStatusCondition
operator/src/lib.rs

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The Client::try_default().await.expect("failed to create Kubernetes client") pattern is duplicated in both binaries; consider extracting a small async helper that constructs and logs a richer error once so startup failure handling is consistent and easier to adjust later.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `Client::try_default().await.expect("failed to create Kubernetes client")` pattern is duplicated in both binaries; consider extracting a small async helper that constructs and logs a richer error once so startup failure handling is consistent and easier to adjust later.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Were created upon already merged PR in testing.

- Set SHELL in Makefile
- Create Client just once in register servers
- Print https when used
- spelling

Signed-off-by: Jakob Naucke <jnaucke@redhat.com>
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.

1 participant