Skip to content
This repository has been archived by the owner on Mar 25, 2023. It is now read-only.

Commit

Permalink
feat(volume): support data volume management limitations for VMs with…
Browse files Browse the repository at this point in the history
… snapshots (#1521)

PR close #934
  • Loading branch information
HeyRoach committed Jan 28, 2019
1 parent 0ba17bf commit 7d98118
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
21 changes: 19 additions & 2 deletions src/app/reducers/volumes/redux/volumes.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { MatDialog } from '@angular/material';
import { Router } from '@angular/router';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Action, select, Store } from '@ngrx/store';
const pickBy = require('lodash/pickBy');
import { Observable, of } from 'rxjs';
import {
catchError,
Expand Down Expand Up @@ -37,6 +36,8 @@ import * as snapshotActions from '../../snapshots/redux/snapshot.actions';
import * as volumeActions from './volumes.actions';
import * as fromVolumes from './volumes.reducers';

const pickBy = require('lodash/pickBy');

@Injectable()
export class VolumesEffects {
@Effect()
Expand Down Expand Up @@ -340,6 +341,17 @@ export class VolumesEffects {
map(() => {
const message = 'NOTIFICATIONS.VOLUME.DELETION_DONE';
this.showNotificationsOnFinish(message, notificationId);
if (removeVolume.snapshots && !!removeVolume.snapshots.length) {
this.dialogService
.confirm({ message: 'DIALOG_MESSAGES.SNAPSHOT.CONFIRM_ALL_DELETION' })
.pipe(
onErrorResumeNext(),
filter(Boolean),
)
.subscribe(() =>
this.store.dispatch(new snapshotActions.DeleteSnapshots(removeVolume.snapshots)),
);
}
return new volumeActions.DeleteSuccess(removeVolume);
}),
catchError((error: Error) => {
Expand All @@ -357,7 +369,12 @@ export class VolumesEffects {
}),
catchError((error: Error) => {
const message = 'NOTIFICATIONS.VOLUME.DETACHMENT_FAILED';
this.dialogService.showNotificationsOnFail(error, message, notificationId);
const detachError = 'ERRORS.VOLUME.VOLUME_DELETING_UNAVAILABLE';
this.dialogService.showNotificationsOnFail(
{ message: detachError },
message,
notificationId,
);
return of(new volumeActions.VolumeUpdateError(error));
}),
);
Expand Down
14 changes: 2 additions & 12 deletions src/app/shared/actions/volume-actions/volume-actions.container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import * as snapshotActions from '../../../reducers/snapshots/redux/snapshot.act
(volumeResized)="onVolumeResize($event)"
(volumeScheduled)="onVolumeSchedule($event)"
>
</cs-volume-actions>`,
</cs-volume-actions>
`,
})
export class VolumeActionsContainerComponent {
@Input()
Expand All @@ -44,17 +45,6 @@ export class VolumeActionsContainerComponent {
filter(Boolean),
)
.subscribe(() => {
if (volume.snapshots && !!volume.snapshots.length) {
this.dialogService
.confirm({ message: 'DIALOG_MESSAGES.SNAPSHOT.CONFIRM_ALL_DELETION' })
.pipe(
onErrorResumeNext(),
filter(Boolean),
)
.subscribe(() =>
this.store.dispatch(new snapshotActions.DeleteSnapshots(volume.snapshots)),
);
}
this.store.dispatch(new volumeActions.DeleteVolume(volume));
});
}
Expand Down
12 changes: 12 additions & 0 deletions src/app/shared/services/error.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,18 @@ export class ErrorService {
regex: /max must be between (\d+) and (\d+)/,
translation: 'ERRORS.RESOURCE_QUOTAS.MAX_MUST_BE_BETWEEN',
},
{
regex: /Unable to detach volume, please specify a VM that does not have VM snapshots/,
translation: 'ERRORS.VOLUME.VOLUME_DETACH_UNAVAILABLE',
},
{
regex: /Unable to attach volume, please specify a VM that does not have VM snapshots/,
translation: 'ERRORS.VOLUME.VOLUME_ATTACH_UNAVAILABLE',
},
{
regex: /A volume that is attached to a VM with any VM snapshots cannot be resized./,
translation: 'ERRORS.VOLUME.VOLUME_RESIZE_UNAVAILABLE',
},
];

public static parseError(error: any): any {
Expand Down
7 changes: 5 additions & 2 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@
"PRIMARY_STORAGE_EXCEEDED": "Primary storage capacity exceeded",
"UNABLE_TO_FIND_PRIMARY_STORAGE": "Unable to find suitable primary storage when creating volume {{ val1 }}",
"VOLUME_BUSY": "There is other active snapshot tasks on the instance to which the volume is attached. Please try again later.",
"VOLUME_RESOURCES_LIMIT_EXCEEDED": "The disk offering cannot be selected because it doesn't fit the account resources available"
"VOLUME_RESOURCES_LIMIT_EXCEEDED": "The disk offering cannot be selected because it doesn't fit the account resources available",
"VOLUME_DELETING_UNAVAILABLE": "Data disk deleting is unavailable for VMs with active snapshots",
"VOLUME_ATTACH_UNAVAILABLE": "Data disk attachment is unavailable for VMs with active snapshots",
"VOLUME_DETACH_UNAVAILABLE": "Data disk detachment is unavailable for VMs with active snapshots",
"VOLUME_RESIZE_UNAVAILABLE": "Data disk resize is unavailable for VMs with active snapshots"
},
"SNAPSHOT_POLICIES": {
"HOURLY_TURN_OFF": "Hourly schedule is turned off"
Expand Down Expand Up @@ -187,7 +191,6 @@
"TAKE_FAILED": "Failed to take a snapshot",
"DELETION_IN_PROGRESS": "Deleting a snapshot",
"DELETION_DONE": "Snapshot deleted",
"DELETION_FAILED": "Failed to delete a snapshot",
"REVERT_IN_PROGRESS": "Reverting a disk",
"REVERT_DONE": "Disk reverted",
"REVERT_FAILED": "Failed to revert a disk"
Expand Down
6 changes: 5 additions & 1 deletion src/i18n/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@
"PRIMARY_STORAGE_EXCEEDED": "Лимит основного хранилища превышен",
"UNABLE_TO_FIND_PRIMARY_STORAGE": "Не удалось найти подходящее основное хранилище при создании диска {{ val1 }}",
"VOLUME_BUSY": "На виртуальной машине, к которой прикреплен этот диск, уже выполняется другое действие над снимками. Повторите попытку позже.",
"VOLUME_RESOURCES_LIMIT_EXCEEDED": "Диск не может быть выбран. Размер выбранного диска превышает доступные ресурсы аккаунта."
"VOLUME_RESOURCES_LIMIT_EXCEEDED": "Диск не может быть выбран. Размер выбранного диска превышает доступные ресурсы аккаунта.",
"VOLUME_DELETING_UNAVAILABLE": "Удаление дополнительных дисков не доступно для ВМ с активными снимками",
"VOLUME_ATTACH_UNAVAILABLE": "Прикрепление дополнительных дисков не доступно для ВМ с активными снимками",
"VOLUME_DETACH_UNAVAILABLE": "Открепление дополнительных дисков не доступно для ВМ с активными снимками",
"VOLUME_RESIZE_UNAVAILABLE": "Изменение размера диска недоступно для ВМ с активными снимками"
},
"SNAPSHOT_POLICIES": {
"HOURLY_TURN_OFF": "Почасовое расписание отключено"
Expand Down

0 comments on commit 7d98118

Please sign in to comment.