Skip to content
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

chore : Remove storageClass related fields from VolumePermissionEnricher #3194

Merged
merged 1 commit into from
Jun 25, 2024
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Usage:
./scripts/extract-changelog-for-version.sh 1.3.37 5
```
### 1.17-SNAPSHOT
* Fix #1989: Remove storageClass related fields from VolumePermissionEnricher
* Fix #3161: JavaExecGenerator should honor %t setting and not unconditionally add `latest` tag
* Fix #2098: Add support for multi-platform container image builds in jib build strategy
* Fix #2335: Add support for configuring nodeSelector spec for controller via xml/groovy DSL configuration
Expand All @@ -39,6 +40,10 @@ Usage:
* Fix #2110: Add new helm dependency update goal task (`k8s:helm-dependency-update` for maven and `k8sHelmDependencyUpdate` for gradle)
* Fix #3122: JKube should also pass project directory in `buildpacks` build strategy
* Fix #2467: Add support for specifying imagePullSecrets via resource configuration

_**Note**_:
- `defaultStorageClass` and `useStorageClassAnnotation` fields have been removed from VolumePermissionEnricher (`jkube-volume-permission`). Users are advised to use these fields from PersistentVolumeClaimStorageClassEnricher (`jkube-persistentvolumeclaim-storageclass`) instead.

### 1.16.2 (2024-03-27)
* Fix #2461: `k8s:watch`/`k8sWatch` should throw error in `buildpacks` build strategy
* Fix #2852: Bump version.kubernetes-client from 6.10.0 to 6.11.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class VolumePermissionIT {
static Stream<Arguments> data() {
return Stream.of(
arguments("default", new String[] {}),
arguments("custom-storageclass-annotation", new String[] {"-Pjkube.enricher.jkube-volume-permission.defaultStorageClass=cheese", "-Pjkube.enricher.jkube-volume-permission.useStorageClassAnnotation=true"}),
arguments("custom-storageclass", new String[] {"-Pjkube.enricher.jkube-volume-permission.defaultStorageClass=cheese"})
arguments("custom-storageclass-annotation", new String[] {"-Pjkube.enricher.jkube-persistentvolumeclaim-storageclass.defaultStorageClass=cheese", "-Pjkube.enricher.jkube-persistentvolumeclaim-storageclass.useStorageClassAnnotation=true"}),
arguments("custom-storageclass", new String[] {"-Pjkube.enricher.jkube-persistentvolumeclaim-storageclass.defaultStorageClass=cheese"})
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,6 @@ Enricher which fixes the permission of persistent volume mount with the help of
Defaults to `777`.
| `jkube.enricher.jkube-volume-permission.permission`

| *defaultStorageClass*
| _Deprecated: Use <<jkube-persistentvolumeclaim-storageclass, PersistentVolumeClaimStorageClassEnricher>>'s defaultStorageClass field_

PersistentVolume storage class.
| `jkube.enricher.jkube-volume-permission.defaultStorageClass`

| *useStorageClassAnnotation*
| _Deprecated: Use <<jkube-persistentvolumeclaim-storageclass, PersistentVolumeClaimStorageClassEnricher>>'s defaultStorageClass field_

If enabled, storage class would be added to PersistentVolumeClaim metadata as `volume.beta.kubernetes.io/storage-class=<storageClassName>` annotation rather than `.spec.storageClassName`

Defaults to `false`
| `jkube.enricher.jkube-volume-permission.useStorageClassAnnotation`

| *cpuLimit*
| Set PersistentVolume *initContainer*'s `.resources` CPU limit
| `jkube.enricher.jkube-volume-permission.cpuLimit`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,14 @@ public void visit(PersistentVolumeClaimBuilder pvcBuilder) {
}

private boolean shouldUseAnnotation() {
if (Boolean.TRUE.equals(Boolean.parseBoolean(getConfig(Config.USE_ANNOTATION)))) {
return true;
}
VolumePermissionEnricher volumePermissionEnricher = new VolumePermissionEnricher((JKubeEnricherContext) getContext());
return Boolean.TRUE.equals(volumePermissionEnricher.shouldUseAnnotation());
return Boolean.parseBoolean(getConfig(Config.USE_ANNOTATION));
}

private String getStorageClass() {
String storageClassConfig = getConfig(Config.DEFAULT_STORAGE_CLASS);
if (StringUtils.isNotBlank(storageClassConfig)) {
return storageClassConfig;
}
VolumePermissionEnricher volumePermissionEnricher = new VolumePermissionEnricher((JKubeEnricherContext) getContext());
return volumePermissionEnricher.getDefaultStorageClass();
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@ public class VolumePermissionEnricher extends BaseEnricher {
enum Config implements Configs.Config {
IMAGE_NAME("imageName", "quay.io/quay/busybox"),
PERMISSION("permission", "777"),
/**
* @deprecated Use configuration field in PersistentVolumeClaimStorageClassEnricher
*/
@Deprecated
DEFAULT_STORAGE_CLASS("defaultStorageClass", null),
/**
* @deprecated Use configuration field in PersistentVolumeClaimStorageClassEnricher
*/
@Deprecated
USE_ANNOTATION("useStorageClassAnnotation", "false"),
CPU_LIMIT("cpuLimit", null),
CPU_REQUEST("cpuRequest", null),
MEMORY_LIMIT("memoryLimit", null),
Expand Down Expand Up @@ -206,26 +196,4 @@ private Map<String, Quantity> createResourcesMap(Configs.Config cpu, Configs.Con
}
});
}

/**
* Get useAnnotation from enricher configuration
* TODO: This method is kept only for backward compatibility. This should
* be removed in future. See <a href="https://github.com/eclipse-jkube/jkube/issues/1989">GitHub Issue</a> for more details
*
* @return boolean value indicating whether StorageClass annotation should be used or not
*/
public boolean shouldUseAnnotation() {
return Boolean.parseBoolean(getConfig(Config.USE_ANNOTATION));
}

/**
* Get Default StorageClass from enricher configuration
*
* TODO: This method is kept only for backward compatibility. This should
* be removed in future. See <a href="https://github.com/eclipse-jkube/jkube/issues/1989">GitHub Issue</a> for more details
* @return default storage class
*/
public String getDefaultStorageClass() {
return getConfig(Config.DEFAULT_STORAGE_CLASS);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void setUp() {
}

@ParameterizedTest
@ValueSource(strings = {"jkube-persistentvolumeclaim-storageclass", "jkube-volume-permission"})
@ValueSource(strings = {"jkube-persistentvolumeclaim-storageclass"})
void enrich_withPersistentVolumeClaim_shouldAddStorageClassToSpec(String enricher) {
// Given
Properties properties = new Properties();
Expand All @@ -63,7 +63,7 @@ void enrich_withPersistentVolumeClaim_shouldAddStorageClassToSpec(String enriche
}

@ParameterizedTest
@ValueSource(strings = {"jkube-persistentvolumeclaim-storageclass", "jkube-volume-permission"})
@ValueSource(strings = {"jkube-persistentvolumeclaim-storageclass"})
void enrich_withPersistentVolumeClaimAndUseAnnotationEnabled_shouldAddStorageClassAnnotation(String enricher) {
// Given
Properties properties = new Properties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
<configuration>
<enricher>
<config>
<jkube-volume-permission>
<jkube-persistentvolumeclaim-storageclass>
<defaultStorageClass>cheese</defaultStorageClass>
</jkube-persistentvolumeclaim-storageclass>
<jkube-volume-permission>
<cpuRequest>250m</cpuRequest>
<memoryRequest>64Mi</memoryRequest>
<cpuLimit>500m</cpuLimit>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
<configuration>
<enricher>
<config>
<jkube-volume-permission>
<defaultStorageClass>cheese</defaultStorageClass>
</jkube-volume-permission>
<jkube-persistentvolumeclaim-storageclass>
<defaultStorageClass>cheese</defaultStorageClass>
</jkube-persistentvolumeclaim-storageclass>
</config>
</enricher>
</configuration>
Expand Down