Skip to content

Add support for volumeAttributesClassName on persistent storage #11210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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
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 @@ -56,6 +56,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 @@ -106,6 +107,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"));
}

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

@ParallelTest
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 @@ -249,7 +249,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 @@ -671,6 +671,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 @@ -599,6 +599,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 @@ -649,6 +652,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 @@ -2348,6 +2354,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: Storage configuration (disk). Cannot be updated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,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 @@ -161,6 +164,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
9 changes: 9 additions & 0 deletions packaging/install/cluster-operator/040-Crd-kafka.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,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 @@ -648,6 +651,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 @@ -2347,6 +2353,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: Storage configuration (disk). Cannot be updated.
Expand Down
6 changes: 6 additions & 0 deletions packaging/install/cluster-operator/045-Crd-kafkanodepool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,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 @@ -160,6 +163,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