michelin / kafkactl

Kafkactl is the CLI linked with Ns4Kafka. It lets you deploy your Kafka resources using YAML descriptors.
Apache License 2.0
10 stars 5 forks source link

kafkactl delete schemas: allow to delete only one version of the schema. #106

Closed Herbacha closed 1 month ago

Herbacha commented 7 months ago

Problem

After applying several version of a schema in the same subject, sometimes I'd wish to erase the last one or an intermediary one (for example, one that is totally unused, or a new schema added to the subject that contains error and is not being used by a producer or consumer yet).

The current command kafkactl delete schema MyTopic-value deletes all the existing schemas from a subject

Suggestion

I'd like the possibility to delete one specific schema, similar to how the Schema Registry API works:

Alternatively, the command could be more "command-line" like:

Additional context

Like how the delete schema command works right now, if many subjects share the same schema, the schema should be deleted from the registry only if the latest existing subject is deleted, to avoid losing existing compatibility.

loicgreffier commented 7 months ago

Hi @Herbacha,

I like the command-like approach, so this could definitely be implemented. Would you like to contribute ?

Not sure to understand your point in the additional context tho. Schemas are actually duplicated across subjects so there should not be dependencies between subjects.

Herbacha commented 7 months ago

Hello @loicgreffier, I think I heard of a case were all subjects referencing the same schema are erased, and the schema itself was also erased from the registry. So creating a new subject re-creates the schema in the registry with a new ID. But I'm not 100% sure about this, and it may depend on cluster-side or ns4kafka-side configuration?

I may contribute, but not sure I'll have the time nowadays. Maybe in a few months, if the issue is still open!

ThomasCAI-mlv commented 1 month ago

Hello, with the feature developped in server-side ns4kafka and the linked PR in kafkactl, you should now be able to delete a specific version of a schema with the command lines:

kafkactl delete schema MyTopic-value -V latest kafkactl delete schema MyTopic-value -V 1 kafkactl delete schema MyTopic-value --version latest kafkactl delete schema MyTopic-value --version 1

The delete command kafkactl delete schema MyTopic-value should behave like before: deleting all versions of the schema Mytopic-value.

You can also delete schema version using "By file" deletion kafkactl delete schema -f mySchema.yml if the version is specified in the field spec.version. If it is not specified, that deletion will delete all versions of the schema.

FYI, in server-side, I added a version query parameter in the endpoint like this: DELETE /api/namespaces/<namespace>/schemas/<subject>?version=<version> Only numbers or latest work for the parameter, like the Confluent Schema Registry endpoint.