← Back to Pull requests

kmip: fix destroy key #1875

Merged
gadididi merged 1 files (18 lines) on Apr 20, 2026 13:05 UTC
View on GitHub
gadididi gadididi commented on Apr 20, 2026 07:34 UTC
Author

There was little bug, the key could not be destroyed because it was active. need to revoke first.

Diff: 18 lines (+18 / -0) across 1 files Reviewer: Hezko Review duration: 330m
All Vouch review confidence checks passed
Residual risk 0.03 = Change Risk (0.21) × (1 − Review Confidence (0.87)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.21 · 18 lines diff across 1 files
0.21
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.83 · 4 substantive comment(s)
0.83
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
87%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.176
Real PR Conversation Timeline
8 items
Copilot Copilot commented on code on Apr 20, 2026 07:37 UTC
Code Review
tests/kmip/kmip_cli.py:1
@@ -153,6 +153,17 @@ def get_passphrase(self, passphrase_uuid: str) -> None:
     def destroy_passphrase(self, passphrase_uuid: str) -> None:
         """Destroy a passphrase"""
         try:
+            # Try to revoke first (in case it's active)
+            try:
+                self.client.revoke(
+                    revocation_reason=enums.RevocationReasonCode.CESSATION_OF_OPERATION,
+                    uid=passphrase_uuid
+                )
+            except Exception:
+                # If revoke fails (maybe already revoked), continue to destroy
+                pass

The inner except Exception: pass will silently swallow programming errors (e.g., a TypeError from an incorrect revoke argument name) as well as unexpected server/transport failures, making destroy failures harder to diagnose. Please catch the specific KMIP/pykmip exception(s) that indicate "already revoked"/"invalid state", and for anything else either log the revoke failure (at least in JSON output) or re-raise so the user gets a clear error.

copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Apr 20, 2026 07:37 UTC
Reviewer

Pull request overview

Fixes KMIP passphrase destruction in the test KMIP CLI by attempting to revoke an object before destroying it (objects may need to be revoked when active).

Changes:

  • Add a pre-destroy revoke attempt in destroy_passphrase to handle active objects.

  • Continue to destroy even if revoke fails (e.g., already revoked).
  • ---

    💡 <a href="/ceph/ceph-nvmeof/new/devel?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.

    gadididi gadididi commented on code on Apr 20, 2026 08:27 UTC
    Code Review
    tests/kmip/kmip_cli.py:1
    @@ -153,6 +153,17 @@ def get_passphrase(self, passphrase_uuid: str) -> None:
         def destroy_passphrase(self, passphrase_uuid: str) -> None:
             """Destroy a passphrase"""
             try:
    +            # Try to revoke first (in case it's active)
    +            try:
    +                self.client.revoke(
    +                    revocation_reason=enums.RevocationReasonCode.CESSATION_OF_OPERATION,
    +                    uid=passphrase_uuid
    +                )
    +            except Exception:
    +                # If revoke fails (maybe already revoked), continue to destroy
    +                pass

    done

    Hezko Hezko approved these changes on Apr 20, 2026 08:51 UTC
    Approved Reviewer

    Approved these changes.

    Copilot Copilot commented on code on Apr 20, 2026 09:01 UTC
    Code Review
    tests/kmip/kmip_cli.py:1
    @@ -153,6 +154,23 @@ def get_passphrase(self, passphrase_uuid: str) -> None:
         def destroy_passphrase(self, passphrase_uuid: str) -> None:
             """Destroy a passphrase"""
             try:
    +            # Revoke first (required before destroy)
    +            try:
    +                self.client.revoke(
    +                    revocation_reason=enums.RevocationReasonCode.CESSATION_OF_OPERATION,
    +                    uid=passphrase_uuid
    +                )
    +            except kmip_exceptions.KmipOperationFailure as e:
    +                # Object already revoked
    +                if "ILLEGAL_OPERATION" in str(e) and "not active" in str(e):
    +                    # Object already revoked - this is expected, continue to destroy
    +                    pass
    +                else:
    +                    # Unexpected operation failure - re-raise
    +                    raise

    The handling of the "already revoked" case is currently based on matching substrings in str(e) ("ILLEGAL_OPERATION" and "not active"). This is brittle (message wording/casing can differ across KMIP server implementations and pykmip versions) and could cause destroy to fail intermittently. Prefer checking structured fields on the exception/response (e.g., result reason/status) or at least normalize casing and match on a single stable indicator rather than free-form message text.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Apr 20, 2026 09:01 UTC
    Reviewer

    Pull request overview

    Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

    ---

    💡 <a href="/ceph/ceph-nvmeof/new/devel?filename=.github/instructions/*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.

    gadididi gadididi commented on code on Apr 20, 2026 11:30 UTC
    Code Review
    tests/kmip/kmip_cli.py:1
    @@ -153,6 +154,23 @@ def get_passphrase(self, passphrase_uuid: str) -> None:
         def destroy_passphrase(self, passphrase_uuid: str) -> None:
             """Destroy a passphrase"""
             try:
    +            # Revoke first (required before destroy)
    +            try:
    +                self.client.revoke(
    +                    revocation_reason=enums.RevocationReasonCode.CESSATION_OF_OPERATION,
    +                    uid=passphrase_uuid
    +                )
    +            except kmip_exceptions.KmipOperationFailure as e:
    +                # Object already revoked
    +                if "ILLEGAL_OPERATION" in str(e) and "not active" in str(e):
    +                    # Object already revoked - this is expected, continue to destroy
    +                    pass
    +                else:
    +                    # Unexpected operation failure - re-raise
    +                    raise

    it is ok because the cli works just with the dummy kmip server

    Reviewers
    Assignees
    gadididi gadididi
    Labels
    risk: low confidence: 87.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 20.6% (LOW) · Higher = larger blast radius
    20.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 87.3% · Lower = rushed or shallow review
    87.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 2.6% · Safe to merge
    2.6%