]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Explicit returns in pool form
authorStephan Müller <smueller@suse.com>
Mon, 2 Mar 2020 11:16:32 +0000 (12:16 +0100)
committerStephan Müller <smueller@suse.com>
Mon, 9 Mar 2020 11:35:58 +0000 (12:35 +0100)
Fixes: https://tracker.ceph.com/issues/44371
Signed-off-by: Stephan Müller <smueller@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/pool/pool-form/pool-form.component.ts

index 30dbcb7db0692ee17df3044ac4d728800682683b..5ff1418c94cbe1f5e7ca6209640ace0ed9a15346 100644 (file)
@@ -534,16 +534,16 @@ describe('PoolFormComponent', () => {
       });
     };
 
-    it('returns nothing if osd count is 0', () => {
+    it('returns 0 if osd count is 0', () => {
       component.info.osd_count = 0;
-      expect(component.getMinSize()).toBe(undefined);
-      expect(component.getMaxSize()).toBe(undefined);
+      expect(component.getMinSize()).toBe(0);
+      expect(component.getMaxSize()).toBe(0);
     });
 
-    it('returns nothing if info is not there', () => {
+    it('returns 0 if info is not there', () => {
       delete component.info;
-      expect(component.getMinSize()).toBe(undefined);
-      expect(component.getMaxSize()).toBe(undefined);
+      expect(component.getMinSize()).toBe(0);
+      expect(component.getMaxSize()).toBe(0);
     });
 
     it('returns minimum and maximum of rule', () => {
index cfc81ba829f0c167c89ebb772a4d93d1cdf73599..f67adba02b8fe76dc306e59b6814c0e34d5cb227 100644 (file)
@@ -382,7 +382,7 @@ export class PoolFormComponent implements OnInit {
 
   getMinSize(): number {
     if (!this.info || this.info.osd_count < 1) {
-      return undefined;
+      return 0;
     }
     const rule = this.form.getValue('crushRule');
     if (rule) {
@@ -393,7 +393,7 @@ export class PoolFormComponent implements OnInit {
 
   getMaxSize(): number {
     if (!this.info || this.info.osd_count < 1) {
-      return undefined;
+      return 0;
     }
     const osds: number = this.info.osd_count;
     if (this.form.getValue('crushRule')) {
@@ -426,21 +426,13 @@ export class PoolFormComponent implements OnInit {
   private replicatedPgCalc(pgs: number): number {
     const sizeControl = this.form.get('size');
     const size = sizeControl.value;
-    if (sizeControl.valid && size > 0) {
-      return pgs / size;
-    }
-
-    return undefined;
+    return sizeControl.valid && size > 0 ? pgs / size : 0;
   }
 
   private erasurePgCalc(pgs: number): number {
     const ecpControl = this.form.get('erasureProfile');
     const ecp = ecpControl.value;
-    if ((ecpControl.valid || ecpControl.disabled) && ecp) {
-      return pgs / (ecp.k + ecp.m);
-    }
-
-    return undefined;
+    return (ecpControl.valid || ecpControl.disabled) && ecp ? pgs / (ecp.k + ecp.m) : 0;
   }
 
   private alignPgs(pgs = this.form.getValue('pgNum')) {