Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1265,11 +1265,17 @@ spec:
- ICEBERG
storage:
kind: Managed
snapshotRetentionMs: 604800000
```

- `metadata.name` must be an existing topic owned by your namespace.
- `spec.tableFormats` can be `ICEBERG` and/or `DELTA`.
- `spec.storage.kind` can only be `Managed`.
- `spec.snapshotRetentionMs` is the maximum age of table snapshots or versions in milliseconds. It is optional
and must be at least 86400000 (one day). Confluent defaults to seven days if omitted at creation.

To update retention on an existing Tableflow topic, edit `spec.snapshotRetentionMs` in its manifest.
Keep the existing table formats and storage kind. Omitting retention on a later apply preserves the stored value.

### Administrator

Expand Down Expand Up @@ -1360,6 +1366,11 @@ spec:
validation-type: ValidString
validStrings:
- Managed
snapshotRetentionMs:
validation-type: Range
optional: true
min: 86400000
max: 604800000
```

- `metadata.cluster` is the name of the Kafka cluster. It should refer to a cluster defined in the Ns4Kafka
Expand Down Expand Up @@ -1447,6 +1458,7 @@ The `property` field can be:
- `name` for the Tableflow topic name
- `tableFormats` for the table formats
- `storage.kind` for the storage kind
- `snapshotRetentionMs` for the snapshot retention in milliseconds

##### Validation Constraint Types

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ kafkactl:
- "TOPIC:/metadata/name"
- "FORMATS:/spec/tableFormats"
- "STORAGE:/spec/storage/kind"
- "SNAPSHOT RETENTION:/spec/snapshotRetentionMs%PERIOD"
- "PHASE:/status/state/phase"
- "ERROR:/status/state/errorMessage"
- "AGE:/metadata/creationTimestamp%AGO"
Expand Down
25 changes: 20 additions & 5 deletions src/test/java/com/michelin/kafkactl/service/FormatServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,29 @@ void shouldDisplayListTable() {
.spec(Map.of("configs", Map.of("retention.ms", "60000", "cleanup.policy", "delete")))
.build();

String output = displayTable(resource);
assertTrue(output.contains("TOPIC RETENTION POLICY AGE"));
assertTrue(output.contains("prefix.topic 1m delete"));
}

@Test
void shouldDisplayTableflowSnapshotRetention() {
Resource resource = Resource.builder()
.kind("TableflowTopic")
.spec(Map.of("snapshotRetentionMs", 172_800_000L))
.metadata(Resource.Metadata.builder().name("orders").build())
.build();
String output = displayTable(resource);
assertTrue(output.contains("SNAPSHOT RETENTION"));
assertTrue(output.contains("2d"));
}

private String displayTable(Resource resource) {
CommandLine cmd = new CommandLine(new Kafkactl());
StringWriter sw = new StringWriter();
cmd.setOut(new PrintWriter(sw));

formatService.displayList("Topic", Collections.singletonList(resource), TABLE, cmd.getCommandSpec());

assertTrue(sw.toString().contains("TOPIC RETENTION POLICY AGE"));
assertTrue(sw.toString().contains("prefix.topic 1m delete"));
formatService.displayList(resource.getKind(), List.of(resource), TABLE, cmd.getCommandSpec());
return sw.toString();
}

@Test
Expand Down
Loading