]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard : Fixes EC profile used pool empty 68648/head
authorAbhishek Desai <abhishek.desai1@ibm.com>
Tue, 28 Apr 2026 07:15:16 +0000 (12:45 +0530)
committerAbhishek Desai <abhishek.desai1@ibm.com>
Tue, 28 Apr 2026 07:35:01 +0000 (13:05 +0530)
fixes : https://tracker.ceph.com/issues/76288
Signed-off-by: Abhishek Desai <abhishek.desai1@ibm.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts

index f4d207d0bf8f09f3b1307c73c6a9bbb2f7758d7a..10e17674ec439fcaae8a1566bf99313dce18e8e1 100644 (file)
           >
             <cds-select
               formControlName="erasureProfile"
-              (change)="erasureProfileChange()"
               label="Erasure code profile"
               i18n-label
               [helperText]="'Policy used for compression algorithm'"
index 56c182123f75aac99e4d4310a45b1ec6af792ad4..1fcfb35991ff66d685ee1d32e1882a4a16c868af 100644 (file)
@@ -4,6 +4,7 @@ import { ActivatedRoute, Router } from '@angular/router';
 
 import { NgbNav } from '@ng-bootstrap/ng-bootstrap';
 import _ from 'lodash';
+import { startWith } from 'rxjs/operators';
 import { Observable, ReplaySubject, Subscription } from 'rxjs';
 
 import { DashboardNotFoundError } from '~/app/core/error/error';
@@ -459,16 +460,14 @@ export class PoolFormComponent extends CdForm implements OnInit {
       this.pgCalc();
     });
 
-    this.form.get('erasureProfile').valueChanges.subscribe((profile) => {
-      // The ec profile can only be changed if type 'erasure' is set.
-      if (!profile) {
-        return;
-      }
-      this.data.erasureInfo = false;
-      this.erasureProfileChange();
-      this.ecpIsUsedBy(profile);
-      this.pgCalc();
-    });
+    this.form
+      .get('erasureProfile')
+      .valueChanges.pipe(startWith(this.form.getValue('erasureProfile')))
+      .subscribe((profile) => {
+        // The ec profile can only be changed if type 'erasure' is set.
+        this.erasureProfileChange(profile);
+        this.pgCalc();
+      });
     this.form.get('mode').valueChanges.subscribe(() => {
       ['minBlobSize', 'maxBlobSize', 'ratio'].forEach((name) => {
         this.form.get(name).updateValueAndValidity({ emitEvent: false });
@@ -1093,16 +1092,27 @@ export class PoolFormComponent extends CdForm implements OnInit {
     this.form.get('name').updateValueAndValidity({ emitEvent: false, onlySelf: true });
   }
 
-  erasureProfileChange() {
+  erasureProfileChange(selectedName?: string) {
     if (!this.ecProfiles || this.ecProfiles.length === 0) {
       return;
     }
-    const selectedName = this.form.get('erasureProfile').value;
-    this.selectedEcp = this.ecProfiles.find((ecp: ErasureCodeProfile) => ecp.name === selectedName);
-    if (this.selectedEcp) {
+    const formSelectedName = this.form.get('erasureProfile')?.value;
+    const resolvedName = selectedName ?? formSelectedName ?? this.ecProfiles[0]?.name;
+    const selectedEcp = this.ecProfiles.find(
+      (ecp: ErasureCodeProfile) => ecp.name === resolvedName
+    );
+    this.ecpIsUsedBy(resolvedName);
+    if (resolvedName) {
+      this.data.erasureInfo = false;
+    }
+    if (selectedEcp) {
+      this.selectedEcp = selectedEcp;
       this.msrCrush =
-        this.selectedEcp['crush-num-failure-domains'] > 0 ||
-        this.selectedEcp['crush-osds-per-failure-domain'] > 0;
+        (selectedEcp['crush-num-failure-domains'] ?? 0) > 0 ||
+        (selectedEcp['crush-osds-per-failure-domain'] ?? 0) > 0;
+    } else {
+      this.selectedEcp = undefined as any;
+      this.msrCrush = false;
     }
   }
 }