]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix unable to create ingress unmanaged
authorNizamudeen A <nia@redhat.com>
Wed, 24 Aug 2022 07:47:50 +0000 (13:17 +0530)
committerNizamudeen A <nia@redhat.com>
Tue, 13 Sep 2022 07:19:00 +0000 (12:49 +0530)
the following snipped is the error from backend

```
 File "/lib/python3.6/site-packages/ceph/deployment/service_spec.py", line 698, in _from_json_impl
                                                  _cls.validate()
                                                File "/lib/python3.6/site-packages/ceph/deployment/service_spec.py", line 1058, in validate
                                                  'Cannot add ingress: No frontend_port specified')
                                              ceph.deployment.hostspec.SpecValidationError: Cannot add ingress: No frontend_port specified
```

It looks like even if we set unmanaged flag, we need to input the
backend_service, frontend_port, monitor_port and virtual_ip, because there is a
validation going for that in the backend.

https://github.com/ceph/ceph/blob/main/src/python-common/ceph/deployment/service_spec.py#L1050

Resolves: rhbz#2080316

Fixes: https://tracker.ceph.com/issues/57284
Signed-off-by: Nizamudeen A <nia@redhat.com>
(cherry picked from commit ea68560e148cf46dd69982120605519aba3a8955)
(cherry picked from commit 4ab2047e380a0813bd739d26f179340775e0e520)

src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/services.po.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/orchestrator/workflow/09-services.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts

index a7959c7b355f3115051ece6c3cfacc64cc84b347..481d6bc9b4d3a66d7a0df5b9c3a3fd25e5e45954 100644 (file)
@@ -41,17 +41,21 @@ export class ServicesPageHelper extends PageHelper {
     exist?: boolean,
     count = '1',
     snmpVersion?: string,
-    snmpPrivProtocol?: boolean
+    snmpPrivProtocol?: boolean,
+    unmanaged = false
   ) {
     cy.get(`${this.pages.create.id}`).within(() => {
       this.selectServiceType(serviceType);
       switch (serviceType) {
         case 'rgw':
           cy.get('#service_id').type('foo');
-          cy.get('#count').type(count);
+          unmanaged ? cy.get('label[for=unmanaged]').click() : cy.get('#count').type(count);
           break;
 
         case 'ingress':
+          if (unmanaged) {
+            cy.get('label[for=unmanaged]').click();
+          }
           this.selectOption('backend_service', 'rgw.foo');
           cy.get('#service_id').should('have.value', 'rgw.foo');
           cy.get('#virtual_ip').type('192.168.100.1/24');
@@ -61,7 +65,7 @@ export class ServicesPageHelper extends PageHelper {
 
         case 'nfs':
           cy.get('#service_id').type('testnfs');
-          cy.get('#count').type(count);
+          unmanaged ? cy.get('label[for=unmanaged]').click() : cy.get('#count').type(count);
           break;
 
         case 'snmp-gateway':
@@ -85,7 +89,7 @@ export class ServicesPageHelper extends PageHelper {
 
         default:
           cy.get('#service_id').type('test');
-          cy.get('#count').type(count);
+          unmanaged ? cy.get('label[for=unmanaged]').click() : cy.get('#count').type(count);
           break;
       }
       if (serviceType === 'snmp-gateway') {
@@ -159,6 +163,18 @@ export class ServicesPageHelper extends PageHelper {
     });
   }
 
+  isUnmanaged(serviceName: string, unmanaged: boolean) {
+    this.getTableCell(this.columnIndex.service_name, serviceName)
+      .parent()
+      .find(`datatable-body-cell:nth-child(${this.columnIndex.placement})`)
+      .should(($ele) => {
+        const placement = $ele.text().split(';');
+        unmanaged
+          ? expect(placement).to.include('unmanaged')
+          : expect(placement).to.not.include('unmanaged');
+      });
+  }
+
   deleteService(serviceName: string) {
     const getRow = this.getTableCell.bind(this, this.columnIndex.service_name);
     getRow(serviceName).click();
index 4349b1ecffb23cae20fcc7e43ae4ced83d0cbd17..d103bb03b89335638438f611b91f83d6f1300011 100644 (file)
@@ -101,4 +101,12 @@ describe('Services page', () => {
 
     services.deleteService('snmp-gateway');
   });
+
+  it('should create ingress as unmanaged', () => {
+    services.navigateTo('create');
+    services.addService('ingress', false, undefined, undefined, undefined, true);
+    services.checkExist('ingress.rgw.foo', true);
+    services.isUnmanaged('ingress.rgw.foo', true);
+    services.deleteService('ingress.rgw.foo');
+  });
 });
index c9cdc70b0ccec4296e4c2129549b0fdfe257773f..986d8d3aa85c76c352824944a8e673c986df1a1f 100644 (file)
         </ng-container>
 
         <!-- Ingress -->
-        <ng-container *ngIf="!serviceForm.controls.unmanaged.value && serviceForm.controls.service_type.value === 'ingress'">
+        <ng-container *ngIf="serviceForm.controls.service_type.value === 'ingress'">
           <!-- virtual_ip -->
           <div class="form-group row">
             <label class="cd-col-form-label"
             </div>
           </div>
           <!-- virtual_interface_networks -->
-          <div class="form-group row">
+          <div class="form-group row"
+               *ngIf="!serviceForm.controls.unmanaged.value">
             <label class="cd-col-form-label"
                    for="virtual_interface_networks">
               <span i18n>CIDR Networks</span>
index cfe2bb5b28dcbe82400705660152d049092dd650..b9954e384ab71ecabb94f76440a6811c368939e7 100644 (file)
@@ -168,8 +168,7 @@ export class ServiceFormComponent extends CdForm implements OnInit {
         null,
         [
           CdValidators.requiredIf({
-            service_type: 'ingress',
-            unmanaged: false
+            service_type: 'ingress'
           })
         ]
       ],
@@ -177,8 +176,7 @@ export class ServiceFormComponent extends CdForm implements OnInit {
         null,
         [
           CdValidators.requiredIf({
-            service_type: 'ingress',
-            unmanaged: false
+            service_type: 'ingress'
           })
         ]
       ],
@@ -187,8 +185,7 @@ export class ServiceFormComponent extends CdForm implements OnInit {
         [
           CdValidators.number(false),
           CdValidators.requiredIf({
-            service_type: 'ingress',
-            unmanaged: false
+            service_type: 'ingress'
           })
         ]
       ],
@@ -197,8 +194,7 @@ export class ServiceFormComponent extends CdForm implements OnInit {
         [
           CdValidators.number(false),
           CdValidators.requiredIf({
-            service_type: 'ingress',
-            unmanaged: false
+            service_type: 'ingress'
           })
         ]
       ],
@@ -552,6 +548,23 @@ export class ServiceFormComponent extends CdForm implements OnInit {
       serviceName = `${serviceType}.${serviceId}`;
       serviceSpec['service_id'] = serviceId;
     }
+
+    switch (serviceType) {
+      case 'ingress':
+        serviceSpec['backend_service'] = values['backend_service'];
+        serviceSpec['service_id'] = values['backend_service'];
+        if (_.isNumber(values['frontend_port']) && values['frontend_port'] > 0) {
+          serviceSpec['frontend_port'] = values['frontend_port'];
+        }
+        if (_.isString(values['virtual_ip']) && !_.isEmpty(values['virtual_ip'])) {
+          serviceSpec['virtual_ip'] = values['virtual_ip'].trim();
+        }
+        if (_.isNumber(values['monitor_port']) && values['monitor_port'] > 0) {
+          serviceSpec['monitor_port'] = values['monitor_port'];
+        }
+        break;
+    }
+
     if (!values['unmanaged']) {
       switch (values['placement']) {
         case 'hosts':
@@ -593,17 +606,6 @@ export class ServiceFormComponent extends CdForm implements OnInit {
           }
           break;
         case 'ingress':
-          serviceSpec['backend_service'] = values['backend_service'];
-          serviceSpec['service_id'] = values['backend_service'];
-          if (_.isString(values['virtual_ip']) && !_.isEmpty(values['virtual_ip'])) {
-            serviceSpec['virtual_ip'] = values['virtual_ip'].trim();
-          }
-          if (_.isNumber(values['frontend_port']) && values['frontend_port'] > 0) {
-            serviceSpec['frontend_port'] = values['frontend_port'];
-          }
-          if (_.isNumber(values['monitor_port']) && values['monitor_port'] > 0) {
-            serviceSpec['monitor_port'] = values['monitor_port'];
-          }
           serviceSpec['ssl'] = values['ssl'];
           if (values['ssl']) {
             serviceSpec['ssl_cert'] = values['ssl_cert']?.trim();