Skip to content
Open
Show file tree
Hide file tree
Changes from 10 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
editableEnabled = false,
builderPackage = Constants.FABRIC8_KUBERNETES_API
)
@JsonPropertyOrder({"id", "type", "size", "kraftMetadata", "class", "selector", "deleteClaim", "overrides"})
@JsonPropertyOrder({"id", "type", "size", "kraftMetadata", "class", "volumeAttributesClass", "selector", "deleteClaim", "overrides"})
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
Expand All @@ -36,6 +36,7 @@ public class PersistentClaimStorage extends SingleVolumeStorage {
private Map<String, String> selector;
private boolean deleteClaim;
private List<PersistentClaimStorageOverride> overrides;
private String volumeAttributesClass;

@Description("Must be `" + TYPE_PERSISTENT_CLAIM + "`")
@Override
Expand Down Expand Up @@ -125,4 +126,13 @@ public List<PersistentClaimStorageOverride> getOverrides() {
public void setOverrides(List<PersistentClaimStorageOverride> overrides) {
this.overrides = overrides;
}

@Description("Specifies `VolumeAttributeClass` name for dynamic volume allocation.")
public String getVolumeAttributesClass() {
return this.volumeAttributesClass;
}

public void setVolumeAttributesClass(String volumeAttributesClass) {
this.volumeAttributesClass = volumeAttributesClass;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ private static PersistentVolumeClaim createPersistentVolumeClaim(
.withRequests(requests)
.endResources()
.withStorageClassName(storage.getStorageClass())
.withVolumeAttributesClassName(storage.getVolumeAttributesClass())
.withSelector(storageSelector)
.withVolumeMode("Filesystem")
.endSpec()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class StorageDiff extends AbstractJsonDiff {
private static final ReconciliationLogger LOGGER = ReconciliationLogger.create(StorageDiff.class.getName());

private static final Pattern IGNORABLE_PATHS = Pattern.compile(
"^(/deleteClaim|/kraftMetadata|/overrides.*|/)$");
"^(/deleteClaim|/kraftMetadata|/overrides.*|/volumeAttributesClass|/)$");

private final boolean isEmpty;
private final boolean changesType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class PersistentVolumeClaimUtilsTest {
.build();
private final static PersistentClaimStorage PERSISTENT_CLAIM_STORAGE = new PersistentClaimStorageBuilder()
.withStorageClass("my-storage-class")
.withVolumeAttributesClass("my-volume-attributes-class")
.withSize("100Gi")
.build();
private final static Set<NodeRef> SINGLE_NODE = Set.of(new NodeRef(NAME + "-" + 0, 0, null, false, true));
Expand Down Expand Up @@ -95,6 +96,7 @@ public void testPersistentClaimStorage() {
assertThat(pvcs.get(0).getSpec().getSelector(), is(nullValue()));
assertThat(pvcs.get(0).getSpec().getResources().getRequests(), is(Map.of("storage", new Quantity("100Gi", null))));
assertThat(pvcs.get(0).getSpec().getStorageClassName(), is("my-storage-class"));
assertThat(pvcs.get(0).getSpec().getVolumeAttributesClassName(), is("my-volume-attributes-class"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,42 @@ public void testDuplicateVolumeIds() {
assertThat(diff.isDuplicateVolumeIds(), is(true));
assertThat(diff.issuesDetected(), is(true));
}

@Test
public void testVolumeAttributesChanges() {
Storage persistent = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").build();
Storage persistent2 = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withVolumeAttributesClass("vac-example").build();
Storage persistent3 = new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withDeleteClaim(false).withId(0).withSize("100Gi").withVolumeAttributesClass("vac-example-2").build();

StorageDiff diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent, Set.of(0, 1, 2), Set.of(0, 1, 2));
assertThat(diff.issuesDetected(), is(false));

diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent, persistent2, Set.of(0, 1, 2), Set.of(0, 1, 2));
assertThat(diff.issuesDetected(), is(false));

diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, persistent2, persistent3, Set.of(0, 1, 2), Set.of(0, 1, 2));
assertThat(diff.issuesDetected(), is(false));

Storage jbod = new JbodStorageBuilder().withVolumes(
new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withId(0).withVolumeAttributesClass("vac-example-1").build(),
new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withId(1).withVolumeAttributesClass("vac-example-2").build()
).build();
Storage jbod2 = new JbodStorageBuilder().withVolumes(
new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withId(0).build(),
new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withId(1).withVolumeAttributesClass("vac-example-2").build()
).build();
Storage jbod3 = new JbodStorageBuilder().withVolumes(
new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withId(0).withVolumeAttributesClass("vac-example-2").build(),
new PersistentClaimStorageBuilder().withStorageClass("gp2-ssd").withId(1).withVolumeAttributesClass("vac-example-2").build()
).build();

diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod, jbod, Set.of(0, 1, 2), Set.of(0, 1, 2));
assertThat(diff.issuesDetected(), is(false));

diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod, jbod2, Set.of(0, 1, 2), Set.of(0, 1, 2));
assertThat(diff.issuesDetected(), is(false));

diff = new StorageDiff(Reconciliation.DUMMY_RECONCILIATION, jbod, jbod3, Set.of(0, 1, 2), Set.of(0, 1, 2));
assertThat(diff.issuesDetected(), is(false));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,13 @@ public static Iterable<Params> data() {
.withSize("123")
.withStorageClass("foo")
.withDeleteClaim(true)
.build()
.build(),
new PersistentClaimStorageBuilder()
.withSize("123")
.withStorageClass("foo")
.withVolumeAttributesClass("fooVac")
.withDeleteClaim(true)
.build(),
};

List<Map<String, Object>> configs = asList(
Expand Down
3 changes: 3 additions & 0 deletions documentation/modules/appendix_crds.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,9 @@ It must have the value `persistent-claim` for the type `PersistentClaimStorage`.
|class
|string
|The storage class to use for dynamic volume allocation.
|volumeAttributesClass
|string
|Specifies `VolumeAttributeClass` name for dynamic volume allocation.
|selector
|map
|Specifies a specific persistent volume to use. It contains key:value pairs representing labels for selecting such a volume.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5397,6 +5397,8 @@ spec:
- ephemeral
- persistent-claim
- jbod
volumeAttributesClass:
type: string
volumes:
type: array
items:
Expand Down Expand Up @@ -5436,6 +5438,8 @@ spec:
enum:
- ephemeral
- persistent-claim
volumeAttributesClass:
type: string
required:
- type
required:
Expand Down Expand Up @@ -6945,6 +6949,8 @@ spec:
enum:
- ephemeral
- persistent-claim
volumeAttributesClass:
type: string
required:
- type
config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ spec:
- persistent-claim
- jbod
description: "Storage type, must be either 'ephemeral', 'persistent-claim', or 'jbod'."
volumeAttributesClass:
type: string
description: Specifies `VolumeAttributeClass` name for dynamic volume allocation.
volumes:
type: array
items:
Expand Down Expand Up @@ -137,6 +140,9 @@ spec:
- ephemeral
- persistent-claim
description: "Storage type, must be either 'ephemeral' or 'persistent-claim'."
volumeAttributesClass:
type: string
description: Specifies `VolumeAttributeClass` name for dynamic volume allocation.
required:
- type
description: List of volumes as Storage objects representing the JBOD disks array.
Expand Down Expand Up @@ -1386,6 +1392,9 @@ spec:
- persistent-claim
- jbod
description: "Storage type, must be either 'ephemeral', 'persistent-claim', or 'jbod'."
volumeAttributesClass:
type: string
description: Specifies `VolumeAttributeClass` name for dynamic volume allocation.
volumes:
type: array
items:
Expand Down Expand Up @@ -1436,6 +1445,9 @@ spec:
- ephemeral
- persistent-claim
description: "Storage type, must be either 'ephemeral' or 'persistent-claim'."
volumeAttributesClass:
type: string
description: Specifies `VolumeAttributeClass` name for dynamic volume allocation.
required:
- type
description: List of volumes as Storage objects representing the JBOD disks array.
Expand Down
6 changes: 6 additions & 0 deletions packaging/install/cluster-operator/040-Crd-kafka.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5396,6 +5396,8 @@ spec:
- ephemeral
- persistent-claim
- jbod
volumeAttributesClass:
type: string
volumes:
type: array
items:
Expand Down Expand Up @@ -5435,6 +5437,8 @@ spec:
enum:
- ephemeral
- persistent-claim
volumeAttributesClass:
type: string
required:
- type
required:
Expand Down Expand Up @@ -6944,6 +6948,8 @@ spec:
enum:
- ephemeral
- persistent-claim
volumeAttributesClass:
type: string
required:
- type
config:
Expand Down
12 changes: 12 additions & 0 deletions packaging/install/cluster-operator/045-Crd-kafkanodepool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ spec:
- persistent-claim
- jbod
description: "Storage type, must be either 'ephemeral', 'persistent-claim', or 'jbod'."
volumeAttributesClass:
type: string
description: Specifies `VolumeAttributeClass` name for dynamic volume allocation.
volumes:
type: array
items:
Expand Down Expand Up @@ -136,6 +139,9 @@ spec:
- ephemeral
- persistent-claim
description: "Storage type, must be either 'ephemeral' or 'persistent-claim'."
volumeAttributesClass:
type: string
description: Specifies `VolumeAttributeClass` name for dynamic volume allocation.
required:
- type
description: List of volumes as Storage objects representing the JBOD disks array.
Expand Down Expand Up @@ -1385,6 +1391,9 @@ spec:
- persistent-claim
- jbod
description: "Storage type, must be either 'ephemeral', 'persistent-claim', or 'jbod'."
volumeAttributesClass:
type: string
description: Specifies `VolumeAttributeClass` name for dynamic volume allocation.
volumes:
type: array
items:
Expand Down Expand Up @@ -1435,6 +1444,9 @@ spec:
- ephemeral
- persistent-claim
description: "Storage type, must be either 'ephemeral' or 'persistent-claim'."
volumeAttributesClass:
type: string
description: Specifies `VolumeAttributeClass` name for dynamic volume allocation.
required:
- type
description: List of volumes as Storage objects representing the JBOD disks array.
Expand Down