Skip to content

Add deletion_protection support for kafka cluster#3318

Draft
Quang N. Vu (hydradon) wants to merge 1 commit intomainfrom
ORC-9983
Draft

Add deletion_protection support for kafka cluster#3318
Quang N. Vu (hydradon) wants to merge 1 commit intomainfrom
ORC-9983

Conversation

@hydradon
Copy link
Copy Markdown

Release Notes

New Features

  • Add --deletion-protection flag to kafka cluster create, update command
  • Add --deletion-protection bool filter flag to kafka cluster list command (omitted means no filter)

Checklist

  • I have successfully built and used a custom CLI binary, without linter issues from this PR.
  • I have clearly specified in the What section below whether this PR applies to Confluent Cloud, Confluent Platform, or both.
  • I have verified this PR in Confluent Cloud pre-prod or production environment, if applicable.
  • I have verified this PR in Confluent Platform on-premises environment, if applicable.
  • I have attached manual CLI verification results or screenshots in the Test & Review section below.
  • I have added appropriate CLI integration or unit tests for any new or updated commands and functionality.
  • I confirm that this PR introduces no breaking changes or backward compatibility issues.
  • I have indicated the potential customer impact if something goes wrong in the Blast Radius section below.
  • I have put checkmarks below confirming that the feature associated with this PR is enabled in:
    • Confluent Cloud prod
    • Confluent Cloud stag
    • Confluent Platform
    • Check this box if the feature is enabled for certain organizations only

What

Blast Radius

References

Test & Review

… list

- Add --deletion-protection bool flag to kafka cluster create command
- Add --deletion-protection bool flag to kafka cluster update command (supports =false to disable)
- Add --deletion-protection bool filter flag to kafka cluster list command (omitted means no filter)
- Display Deletion Protection field in describe/create/update/list output
- Upgrade ccloud-sdk-go-v2/cmk from v0.25.0 to v0.26.0
Copilot AI review requested due to automatic review settings April 13, 2026 22:41
@confluent-cla-assistant
Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Kafka cluster deletion protection support to the CLI by exposing it in create/update/list, surfacing the value in outputs, and improving delete error handling when deletion protection blocks deletion.

Changes:

  • Add --deletion-protection flag to kafka cluster create and kafka cluster update.
  • Add --deletion-protection optional filter to kafka cluster list and include deletion protection in list/describe output rendering.
  • Enhance kafka cluster delete to detect deletion-protection conflict responses and show an actionable suggestion; update SDK + test server + fixtures accordingly.

Reviewed changes

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

Show a summary per file
File Description
test/test-server/cmk_handlers.go Test server support for deletion protection in create/describe/list-filter/delete-conflict scenarios.
test/kafka_test.go Adds end-to-end CLI test cases for deletion protection behaviors.
test/fixtures/output/kafka/describe-unknown-cluster-type.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/create-basic-max-ecku.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/create-basic-max-ecku-error.golden Golden help output updated to include deletion protection flag.
test/fixtures/output/kafka/cluster/update-type-success.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/update-type-max-ecku-success.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/update-type-empty-error.golden Golden help output updated to include deletion protection flag.
test/fixtures/output/kafka/cluster/update-standard-max-ecku.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/update-max-ecku.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/update-help.golden Golden help output updated to include deletion protection flag.
test/fixtures/output/kafka/cluster/update-freight-max-ecku.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/update-freight-max-ecku-with-name.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/update-freight-max-ecku-json.golden Golden output updated to include deletion protection field (JSON).
test/fixtures/output/kafka/cluster/update-enterprise-max-ecku.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/update-enterprise-max-ecku-yaml.golden Golden output updated to include deletion protection field (YAML).
test/fixtures/output/kafka/cluster/update-enterprise-max-ecku-with-name.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/update-enterprise-max-ecku-json.golden Golden output updated to include deletion protection field (JSON).
test/fixtures/output/kafka/cluster/update-deletion-protection-unsupported-basic.golden New golden for update failure when enabling deletion protection on unsupported clusters.
test/fixtures/output/kafka/cluster/update-deletion-protection-enable.golden New golden for enabling deletion protection on an enterprise cluster.
test/fixtures/output/kafka/cluster/update-deletion-protection-disable.golden New golden for disabling deletion protection.
test/fixtures/output/kafka/cluster/update-basic-with-ecku-limits.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/list-help.golden Golden help output updated to include deletion protection filter flag.
test/fixtures/output/kafka/cluster/list-deletion-protection-enabled.golden New golden for listing only deletion-protected clusters.
test/fixtures/output/kafka/cluster/list-deletion-protection-disabled.golden New golden for listing only non-protected clusters.
test/fixtures/output/kafka/cluster/list-deletion-protection-all.golden New golden for listing clusters including deletion protection column.
test/fixtures/output/kafka/cluster/describe-with-usage-limits-error.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/describe-deletion-protected.golden New golden for describing a deletion-protected cluster.
test/fixtures/output/kafka/cluster/describe-basic-with-ecku-limits.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/describe-basic-with-default-v2-limits.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/delete-deletion-protected.golden New golden for delete failing due to deletion protection with suggestion.
test/fixtures/output/kafka/cluster/create-standard-with-ecku-limits.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/create-help.golden Golden help output updated to include deletion protection flag.
test/fixtures/output/kafka/cluster/create-freight.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/create-freight-max-ecku.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/create-freight-low.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/create-flag-error.golden Golden output updated for “one required flag” set to include deletion protection.
test/fixtures/output/kafka/cluster/create-enterprise.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/create-enterprise-max-ecku.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/create-deletion-protection.golden New golden for creating a cluster with deletion protection enabled.
test/fixtures/output/kafka/cluster/create-deletion-protection-unsupported-standard.golden New golden for create failure on unsupported STANDARD cluster type.
test/fixtures/output/kafka/cluster/create-deletion-protection-unsupported-basic.golden New golden for create failure on unsupported BASIC cluster type.
test/fixtures/output/kafka/cluster/create-deletion-protection-false.golden New golden for creating a cluster with deletion protection explicitly disabled.
test/fixtures/output/kafka/cluster/create-basic-with-ecku-limits.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/cck-network.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster/cck-byok.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/cluster-describe-dedicated-provisioning.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/8.golden Golden output updated to include deletion protection field (YAML list).
test/fixtures/output/kafka/7.golden Golden output updated to include deletion protection field (JSON list).
test/fixtures/output/kafka/6.golden Golden output updated to include deletion protection column (human list).
test/fixtures/output/kafka/47.golden Golden output updated to include deletion protection column (human list).
test/fixtures/output/kafka/45.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/44.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/43.golden Golden output updated to include deletion protection field (YAML).
test/fixtures/output/kafka/42.golden Golden output updated to include deletion protection field (JSON).
test/fixtures/output/kafka/41.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/39.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/38.golden Golden output updated to include deletion protection field (YAML).
test/fixtures/output/kafka/37.golden Golden output updated to include deletion protection field (JSON).
test/fixtures/output/kafka/36.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/35.golden Golden output updated to include deletion protection field (YAML).
test/fixtures/output/kafka/34.golden Golden output updated to include deletion protection field (JSON).
test/fixtures/output/kafka/33.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/32.golden Golden output updated to include deletion protection field (YAML).
test/fixtures/output/kafka/31.golden Golden output updated to include deletion protection field (JSON).
test/fixtures/output/kafka/30.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/29.golden Golden output updated to include deletion protection field (YAML).
test/fixtures/output/kafka/28.golden Golden output updated to include deletion protection field (JSON).
test/fixtures/output/kafka/27.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/26.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/24.golden Golden output updated to include deletion protection field (YAML).
test/fixtures/output/kafka/23.golden Golden output updated to include deletion protection field (JSON).
test/fixtures/output/kafka/22.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/2.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/19.golden Golden output updated to include deletion protection field (YAML).
test/fixtures/output/kafka/18.golden Golden output updated to include deletion protection field (JSON).
test/fixtures/output/kafka/17.golden Golden output updated to include deletion protection field.
test/fixtures/output/kafka/1.golden Golden help output updated to include deletion protection flag.
pkg/ccloudv2/cmk.go Adds list API support for deletion protection filtering via SDK query param.
internal/kafka/command_cluster_update.go Adds update flag + request field population; updates required-flag group.
internal/kafka/command_cluster_list.go Adds list filter flag and passes it through to ccloudv2 list calls.
internal/kafka/command_cluster_describe.go Adds deletion protection to describe/list rendering struct and field set.
internal/kafka/command_cluster_delete_test.go Adds unit tests for parsing deletion-protection delete conflicts and suggestion mapping.
internal/kafka/command_cluster_delete.go Parses deletion-protection conflict responses and surfaces better delete suggestions.
internal/kafka/command_cluster_create.go Adds create flag + request field population for deletion protection.
go.sum Updates cmk SDK dependency checksums.
go.mod Bumps cmk SDK dependency to a version supporting deletion protection query param/fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 70 to +80
errs := multierror.Append(err, c.removeKafkaClusterConfigs(deletedIds))
if errs.ErrorOrNil() != nil {
if suggestion := deletionProtectionErrorToSuggestion(deletionProtectionDetail); suggestion != "" {
return errors.NewErrorWithSuggestions(errs.Error(), suggestion)
}
if len(args)-len(deletedIds) > 1 {
return errors.NewErrorWithSuggestions(err.Error(), "Ensure the clusters are not associated with any active Connect clusters.")
return errors.NewErrorWithSuggestions(err.Error(),
"Ensure the clusters are not associated with any active Connect clusters.")
} else {
return errors.NewErrorWithSuggestions(err.Error(), "Ensure the cluster is not associated with any active Connect clusters.")
return errors.NewErrorWithSuggestions(err.Error(),
"Ensure the cluster is not associated with any active Connect clusters.")
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

errs aggregates both the delete error and the error from removeKafkaClusterConfigs, but the Connect-cluster suggestion branches still use err.Error(). If deletion.Delete succeeds (err == nil) but removeKafkaClusterConfigs fails, this will panic on err.Error() and also drops the config-removal error message. Use errs.Error() (or errs.ErrorOrNil().Error()) for both branches so the function is safe and reports the full aggregated error.

Copilot uses AI. Check for mistakes.
@sonarqube-confluent
Copy link
Copy Markdown

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.

2 participants