fix(pvc): show access modes [EE-5581] (#10554)

Co-authored-by: testa113 <testa113>
pull/10708/head
Ali 2023-11-30 09:48:55 +13:00 committed by GitHub
parent 87b486b798
commit e3a995d515
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 20 deletions

View File

@ -18,6 +18,7 @@ class KubernetesPersistentVolumeClaimConverter {
res.Namespace = data.metadata.namespace;
res.CreationDate = data.metadata.creationTimestamp;
res.Storage = `${data.spec.resources.requests.storage}B`;
res.AccessModes = data.spec.accessModes || [];
res.StorageClass = _.find(storageClasses, { Name: data.spec.storageClassName });
res.Yaml = yaml ? yaml.data : '';
res.ApplicationOwner = data.metadata.labels ? data.metadata.labels[KubernetesPortainerApplicationOwnerLabel] : '';

View File

@ -3,12 +3,12 @@
*/
const _KubernetesStorageClassAccessPolicies = Object.freeze([
{
Name: 'RWO',
Name: 'ReadWriteOnce',
Description: 'Allow read-write from a single pod only (RWO)',
selected: true,
},
{
Name: 'RWX',
Name: 'ReadWriteMany',
Description: 'Allow read-write access from one or more pods concurrently (RWX)',
selected: false,
},

View File

@ -11,6 +11,7 @@ const _KubernetesPersistentVolumeClaim = Object.freeze({
StorageClass: {}, // KubernetesStorageClass
CreationDate: '',
ApplicationOwner: '',
AccessModes: [],
ApplicationName: '',
MountPath: '', // used for Application creation from ApplicationFormValues | not used from API conversion
Yaml: '',

View File

@ -49,15 +49,22 @@
</td>
</tr>
<tr>
<td>Storage</td>
<td>Storage Class</td>
<td data-cy="k8sVolDetail-volStorageClassname">{{ ctrl.volume.PersistentVolumeClaim.StorageClass.Name }}</td>
</tr>
<tr>
<td>Shared Access Policy</td>
<td data-cy="k8sVolDetail-volAccessPolicy"
>{{ ctrl.state.volumeSharedAccessPolicy }}
<portainer-tooltip ng-if="ctrl.state.volumeSharedAccessPolicyTooltip" message="ctrl.state.volumeSharedAccessPolicyTooltip"></portainer-tooltip
></td>
<td>Access Modes</td>
<td data-cy="k8sVolDetail-volAccessPolicy">
<div ng-repeat="(index, accessPolicy) in ctrl.state.volumeSharedAccessPolicies" class="flex flex-col gap-y-1">
<div class="items-center flex gap-x-1">
{{ accessPolicy }}
<portainer-tooltip
ng-if="ctrl.state.volumeSharedAccessPolicyTooltips[index]"
message="ctrl.state.volumeSharedAccessPolicyTooltips[index]"
></portainer-tooltip>
</div>
</div>
</td>
</tr>
<tr>
<td>Provisioner</td>

View File

@ -174,8 +174,8 @@ class KubernetesVolumeController {
increaseSize: false,
volumeSize: 0,
volumeSizeUnit: 'GB',
volumeSharedAccessPolicy: '',
volumeSharedAccessPolicyTooltip: '',
volumeSharedAccessPolicies: [],
volumeSharedAccessPolicyTooltips: '',
errors: {
volumeSize: false,
},
@ -186,16 +186,12 @@ class KubernetesVolumeController {
try {
await this.getVolume();
await this.getEvents();
if (this.volume.PersistentVolumeClaim.StorageClass !== undefined) {
this.state.volumeSharedAccessPolicy = this.volume.PersistentVolumeClaim.StorageClass.AccessModes[this.volume.PersistentVolumeClaim.StorageClass.AccessModes.length - 1];
let policies = KubernetesStorageClassAccessPolicies();
policies.forEach((policy) => {
if (policy.Name == this.state.volumeSharedAccessPolicy) {
this.state.volumeSharedAccessPolicyTooltip = policy.Description;
}
});
}
this.state.volumeSharedAccessPolicies = this.volume.PersistentVolumeClaim.AccessModes;
let policies = KubernetesStorageClassAccessPolicies();
this.state.volumeSharedAccessPolicyTooltips = this.state.volumeSharedAccessPolicies.map((policy) => {
const matchingPolicy = policies.find((p) => p.Name === policy);
return matchingPolicy ? matchingPolicy.Description : undefined;
});
} catch (err) {
this.Notifications.error('Failure', err, 'Unable to load view data');
} finally {