Skip to content

OCPEDGE-2998: Add certificate status command - #7397

Open
eggfoobar wants to merge 1 commit into
openshift:mainfrom
eggfoobar:ocpstrat-2899-certs-status
Open

eggfoobar wants to merge 1 commit into
openshift:mainfrom
eggfoobar:ocpstrat-2899-certs-status

Conversation

@eggfoobar

@eggfoobar eggfoobar commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Add read-only certificate inventory loading with service ownership and rotation policy metadata. Report deterministic human-readable and JSON certificate status using the enhancement's zone thresholds.

Example Output:

$ sudo ./_output/bin/microshift certs status
SERVICE                    CERTIFICATE                             STATUS  EXPIRY                REASON       MESSAGE
authentication             admin-kubeconfig-client                 Green   2036-09-15T00:00:01Z  NotExpiring  Valid for 3651 days
authentication             admin-kubeconfig-signer                 Green   2036-09-15T00:00:00Z  NotExpiring  Valid for 3651 days
cluster-policy-controller  cluster-policy-controller               Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
control-plane              kube-control-plane-signer               Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
etcd                       etcd-peer                               Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
etcd                       etcd-serving                            Green   2036-09-15T00:00:03Z  NotExpiring  Valid for 3651 days
etcd                       etcd-signer                             Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
ingress                    ingress-ca                              Green   2036-09-15T00:00:01Z  NotExpiring  Valid for 3651 days
ingress                    router-default-serving                  Green   2027-09-18T00:00:02Z  NotExpiring  Valid for 366 days
kube-apiserver             aggregator-client                       Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
kube-apiserver             aggregator-signer                       Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
kube-apiserver             apiserver-etcd-client                   Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
kube-apiserver             kube-apiserver-external-signer          Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
kube-apiserver             kube-apiserver-localhost-serving        Green   2027-09-18T00:00:02Z  NotExpiring  Valid for 366 days
kube-apiserver             kube-apiserver-localhost-signer         Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
kube-apiserver             kube-apiserver-service-network-serving  Green   2027-09-18T00:00:02Z  NotExpiring  Valid for 366 days
kube-apiserver             kube-apiserver-service-network-signer   Green   2036-09-15T00:00:02Z  NotExpiring  Valid for 3651 days
kube-apiserver             kube-apiserver-to-kubelet-client        Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
kube-apiserver             kube-apiserver-to-kubelet-signer        Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
kube-apiserver             kube-external-serving                   Green   2027-09-18T00:00:02Z  NotExpiring  Valid for 366 days
kube-controller-manager    kube-controller-manager                 Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
kube-scheduler             kube-scheduler                          Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
kubelet                    kube-csr-signer                         Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
kubelet                    kubelet-client                          Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
kubelet                    kubelet-server                          Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
kubelet                    kubelet-signer                          Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
metrics-server             metrics-server-kubelet-client           Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
observability              openshift-observability-client          Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
route-controller-manager   route-controller-manager                Green   2027-09-18T00:00:00Z  NotExpiring  Valid for 366 days
route-controller-manager   route-controller-manager-serving        Green   2027-09-18T00:00:01Z  NotExpiring  Valid for 366 days
service-ca                 service-ca                              Green   2036-09-15T00:00:01Z  NotExpiring  Valid for 3651 days

Example Output JSON:

$ sudo ./_output/bin/microshift certs status -ojson
{
  "apiVersion": "microshift.openshift.io/v1alpha1",
  "kind": "CertificateStatusList",
  "generatedAt": "2026-09-17T18:43:13Z",
  "config": {
    "forceRestartOnRedZone": true,
    "servingValidity": "8760h",
    "caValidity": "87600h"
  },
  "items": [
    {
      "service": "authentication",
      "name": "admin-kubeconfig-client",
      "role": "client",
      "rotationPolicy": "extended",
      "zone": "green",
      "notBefore": "2026-09-17T18:33:20Z",
      "notAfter": "2036-09-15T00:00:01Z",
      "remainingSeconds": 315379008
    },
    {
      "service": "authentication",
      "name": "admin-kubeconfig-signer",
      "role": "ca",
      "rotationPolicy": "extended",
      "zone": "green",
      "notBefore": "2026-09-17T18:33:20Z",
      "notAfter": "2036-09-15T00:00:00Z",
      "remainingSeconds": 315379007
    },
    {
      "service": "cluster-policy-controller",
      "name": "cluster-policy-controller",
      "role": "client",
      "rotationPolicy": "standard",
      "zone": "green",
      "notBefore": "2026-09-17T18:33:20Z",
      "notAfter": "2027-09-18T00:00:00Z",
      "remainingSeconds": 31555007
    },
....

Add read-only certificate inventory loading with service ownership and rotation policy metadata. Report deterministic human-readable and JSON certificate status using the enhancement's zone thresholds.

Co-Authored-By: GPT-5 <noreply@openai.com>
Signed-off-by: ehila <ehila@redhat.com>
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Sep 17, 2026
@openshift-ci-robot

openshift-ci-robot commented Sep 17, 2026

Copy link
Copy Markdown

@eggfoobar: This pull request references OCPEDGE-2998 which is a valid jira issue.

Details

In response to this:

Add read-only certificate inventory loading with service ownership and rotation policy metadata. Report deterministic human-readable and JSON certificate status using the enhancement's zone thresholds.

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.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: e3d83419-2b51-4edf-9b80-831a2cb68303

📥 Commits

Reviewing files that changed from the base of the PR and between 0b16ecc and aa31215.

📒 Files selected for processing (9)
  • cmd/microshift/main.go
  • pkg/cmd/certs.go
  • pkg/cmd/certs_test.go
  • pkg/cmd/init.go
  • pkg/util/cryptomaterial/certchains/chainsbuilder.go
  • pkg/util/cryptomaterial/certchains/inventory.go
  • pkg/util/cryptomaterial/certchains/inventory_test.go
  • pkg/util/cryptomaterial/certchains/signerbuilder.go
  • pkg/util/cryptomaterial/certchains/signers.go

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


Walkthrough

The change adds certificate service and rotation metadata, disk-backed inventory loading, and a privileged certs status CLI command. The command validates and sorts certificate data, reports validity zones, and supports JSON or table output.

Changes

Certificate status administration

Layer / File(s) Summary
Signer metadata and certificate setup
pkg/cmd/init.go, pkg/util/cryptomaterial/certchains/signerbuilder.go, pkg/util/cryptomaterial/certchains/signers.go
Certificate signers now preserve service and rotation-policy metadata. Certificate initialization assigns this metadata across control-plane, kubelet, serving, aggregator, and etcd certificates.
Inventory metadata and loading
pkg/util/cryptomaterial/certchains/chainsbuilder.go, pkg/util/cryptomaterial/certchains/inventory.go, pkg/util/cryptomaterial/certchains/inventory_test.go
Inventory entries now include names, services, parent CAs, and rotation policies. Inventory loading reads and sorts certificates from disk. ZoneAt classifies validity periods using standard or extended thresholds.
Certificate status command and validation
cmd/microshift/main.go, pkg/cmd/certs.go, pkg/cmd/certs_test.go
The main command registers certs status. The command loads configuration and inventory, validates status data, and writes JSON or table output. Tests cover ordering, warnings, formats, privileges, flags, and validity reporting.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Operator
  participant CertsStatus
  participant CertificateInventory
  participant Output
  Operator->>CertsStatus: Run certs status
  CertsStatus->>CertificateInventory: Load inventory
  CertificateInventory-->>CertsStatus: Return certificate entries and zones
  CertsStatus->>Output: Render JSON or table
  Output-->>Operator: Display status and warnings
Loading

Suggested reviewers: copejon

Merge Risk: ⚪ Minimal · up to aa312

No actionable correctness or availability risk remains for this read-only certificate status command.

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 30 functions across 9 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
Check name Status Explanation
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 The changed tests use Go's testing package, not Ginkgo. All Test... names and t.Run case names are static strings such as standard green and unknown policy; none contain timestamps, generate…
Test Structure And Quality ✅ Passed PASS — the pull request does not add or modify Ginkgo tests. The changed test files use Go's testing.T with testify/require, and the repository search found no direct Ginkgo/Gomega usage in these …
Microshift Test Compatibility ✅ Passed The pull request adds only ordinary Go unit tests (func Test...) in pkg/cmd/certs_test.go and pkg/util/cryptomaterial/certchains/inventory_test.go. The diff adds no Ginkgo tests (It, `Describe…
Single Node Openshift (Sno) Test Compatibility ✅ Passed The pull request adds Go unit tests in pkg/cmd/certs_test.go and pkg/util/cryptomaterial/certchains/inventory_test.go. The authoritative diff contains no Ginkgo e2e constructs such as It, `Descr…
Topology-Aware Scheduling Compatibility ✅ Passed PASS: The pull request changes certificate commands, certificate initialization, and certificate inventory metadata only. The authoritative diff contains no deployment manifests, operators, controller…
Ote Binary Stdout Contract ✅ Passed No explicit OTE stdout-contract failure is introduced. The only change in cmd/microshift/main.go registers NewCertsCommand; main() still only builds the Cobra command, runs it, and exits. The ne…
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PASS: The pull request adds standard Go testing unit tests only (Test..., t.Run) in pkg/cmd/certs_test.go and pkg/util/cryptomaterial/certchains/inventory_test.go. It adds no Ginkgo tests, I…
No-Weak-Crypto ✅ Passed The pull request adds certificate inventory parsing, status calculation, and metadata plumbing. The added code contains no MD5, SHA-1, DES, 3DES, RC4, Blowfish, or ECB usage. It adds no custom cryptog…
Container-Privileges ✅ Passed The pull request changes only Go source and tests. The authoritative diff contains no container or Kubernetes manifest, Dockerfile, or Containerfile changes. No added privileged: true, hostPID, `h…
No-Sensitive-Data-In-Logs ✅ Passed PASS: The pull request adds certificate status output, not sensitive-data logging. The table and JSON fields contain fixed service/certificate identifiers, roles, zones, validity timestamps, and remai…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the main change: adding the certificate status command.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR

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

@openshift-ci

openshift-ci Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: eggfoobar
Once this PR has been reviewed and has the lgtm label, please assign ggiguash for approval. For more information see the Code Review Process.

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

@eggfoobar

Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci

openshift-ci Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

@eggfoobar: 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.

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

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants