1 import { Component, OnInit } from '@angular/core';
2 import { UntypedFormGroup } from '@angular/forms';
4 import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
5 import _ from 'lodash';
7 import { OsdService } from '~/app/shared/api/osd.service';
8 import { ActionLabelsI18n } from '~/app/shared/constants/app.constants';
9 import { NotificationType } from '~/app/shared/enum/notification-type.enum';
10 import { Permissions } from '~/app/shared/models/permissions';
11 import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
12 import { NotificationService } from '~/app/shared/services/notification.service';
15 selector: 'cd-osd-flags-modal',
16 templateUrl: './osd-flags-modal.component.html',
17 styleUrls: ['./osd-flags-modal.component.scss']
19 export class OsdFlagsModalComponent implements OnInit {
20 permissions: Permissions;
22 osdFlagsForm = new UntypedFormGroup({});
27 name: $localize`No In`,
29 description: $localize`OSDs that were previously marked out will not be marked back in when they start`
33 name: $localize`No Out`,
35 description: $localize`OSDs will not automatically be marked out after the configured interval`
39 name: $localize`No Up`,
41 description: $localize`OSDs are not allowed to start`
45 name: $localize`No Down`,
47 description: $localize`OSD failure reports are being ignored, such that the monitors will not mark OSDs down`
51 name: $localize`Pause`,
53 description: $localize`Pauses reads and writes`
57 name: $localize`No Scrub`,
59 description: $localize`Scrubbing is disabled`
63 name: $localize`No Deep Scrub`,
65 description: $localize`Deep Scrubbing is disabled`
69 name: $localize`No Backfill`,
71 description: $localize`Backfilling of PGs is suspended`
75 name: $localize`No Rebalance`,
77 description: $localize`OSD will choose not to backfill unless PG is also degraded`
81 name: $localize`No Recover`,
83 description: $localize`Recovery of PGs is suspended`
87 name: $localize`Bitwise Sort`,
89 description: $localize`Use bitwise sort`,
93 code: 'purged_snapdirs',
94 name: $localize`Purged Snapdirs`,
96 description: $localize`OSDs have converted snapsets`,
100 code: 'recovery_deletes',
101 name: $localize`Recovery Deletes`,
103 description: $localize`Deletes performed during recovery instead of peering`,
107 code: 'pglog_hardlimit',
108 name: $localize`PG Log Hard Limit`,
110 description: $localize`Puts a hard limit on pg log length`,
115 unknownFlags: string[] = [];
118 public activeModal: NgbActiveModal,
119 public actionLabels: ActionLabelsI18n,
120 private authStorageService: AuthStorageService,
121 private osdService: OsdService,
122 private notificationService: NotificationService
124 this.permissions = this.authStorageService.getPermissions();
128 this.osdService.getFlags().subscribe((res: string[]) => {
129 res.forEach((value) => {
130 if (this.allFlags[value]) {
131 this.allFlags[value].value = true;
133 this.unknownFlags.push(value);
136 this.flags = _.toArray(this.allFlags);
141 const newFlags = this.flags
142 .filter((flag) => flag.value)
143 .map((flag) => flag.code)
144 .concat(this.unknownFlags);
146 this.osdService.updateFlags(newFlags).subscribe(
148 this.notificationService.show(NotificationType.success, $localize`Updated OSD Flags`);
149 this.activeModal.close();
152 this.activeModal.close();