Add deletion_protection support for kafka cluster#3318
Add deletion_protection support for kafka cluster#3318Quang N. Vu (hydradon) wants to merge 1 commit intomainfrom
Conversation
… 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
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
There was a problem hiding this comment.
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-protectionflag tokafka cluster createandkafka cluster update. - Add
--deletion-protectionoptional filter tokafka cluster listand include deletion protection in list/describe output rendering. - Enhance
kafka cluster deleteto 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.
| 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.") |
There was a problem hiding this comment.
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.
|




Release Notes
New Features
--deletion-protectionflag tokafka cluster create,updatecommand--deletion-protectionbool filter flag tokafka cluster listcommand (omitted means no filter)Checklist
Whatsection below whether this PR applies to Confluent Cloud, Confluent Platform, or both.Test & Reviewsection below.Blast Radiussection below.What
Blast Radius
References
Test & Review