]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Set RO as the default access_type for RGW NFS exports 30516/head
authorTiago Melo <tmelo@suse.com>
Tue, 3 Sep 2019 15:34:21 +0000 (15:34 +0000)
committerTiago Melo <tmelo@suse.com>
Thu, 7 Nov 2019 14:52:21 +0000 (13:52 -0100)
It will also show an warning if the user selects RW access_type.

Fixes: https://tracker.ceph.com/issues/40186
Signed-off-by: Tiago Melo <tmelo@suse.com>
(cherry picked from commit b40b510a7730d62a717c2d8609bb5eacd5cc3272)

Conflicts:
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts

src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.html
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/nfs/nfs-form/nfs-form.component.ts

index d1300cb3d4174152130262bd2a774fd0cb3796e6..dea05634ebcf043df45e55590eef19d5514a7803 100644 (file)
             <select class="form-control"
                     formControlName="access_type"
                     name="access_type"
-                    id="access_type">
+                    id="access_type"
+                    (change)="accessTypeChangeHandler()">
               <option *ngIf="nfsAccessType === null"
                       value=""
                       i18n>Loading...</option>
                   *ngIf="nfsForm.getValue('access_type')">
               {{ getAccessTypeHelp(nfsForm.getValue('access_type')) }}
             </span>
+            <span class="text-warning"
+                  *ngIf="nfsForm.getValue('access_type') === 'RW' && nfsForm.getValue('name') === 'RGW'"
+                  i18n>The Object Gateway NFS backend has a number of
+              limitations which will seriously affect applications writing to
+              the share. Please consult the
+              <a href="{{docsUrl}}"
+                 target="_blank"> documentation</a> for details before enabling write access.</span>
             <span class="help-block"
                   *ngIf="nfsForm.showError('access_type', formDir, 'required')"
                   i18n>Required field</span>
index cd9f3299caee9d21f6fb67631223d67c465d467d..bcc51a84de0a2bf30b70d004bec9c7ecacc51e21 100644 (file)
@@ -9,6 +9,7 @@ import { ToastrModule } from 'ngx-toastr';
 
 import { ActivatedRouteStub } from '../../../../testing/activated-route-stub';
 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
+import { CephReleaseNamePipe } from '../../../shared/pipes/ceph-release-name.pipe';
 import { SummaryService } from '../../../shared/services/summary.service';
 import { SharedModule } from '../../../shared/shared.module';
 import { NfsFormClientComponent } from '../nfs-form-client/nfs-form-client.component';
@@ -36,7 +37,9 @@ describe('NfsFormComponent', () => {
           provide: ActivatedRoute,
           useValue: new ActivatedRouteStub({ cluster_id: undefined, export_id: undefined })
         },
-        i18nProviders
+        i18nProviders,
+        SummaryService,
+        CephReleaseNamePipe
       ]
     },
     true
@@ -45,6 +48,11 @@ describe('NfsFormComponent', () => {
   beforeEach(() => {
     const summaryService = TestBed.get(SummaryService);
     spyOn(summaryService, 'refresh').and.callFake(() => true);
+    spyOn(summaryService, 'getCurrentSummary').and.callFake(() => {
+      return {
+        version: 'master'
+      };
+    });
 
     fixture = TestBed.createComponent(NfsFormComponent);
     component = fixture.componentInstance;
index 8916d1b7da00331101fefc0cad0199a4c500e964..0beec9fc3bef69c96ea549226458e9dc46bb28de 100644 (file)
@@ -17,7 +17,9 @@ import { CdFormGroup } from '../../../shared/forms/cd-form-group';
 import { CdValidators } from '../../../shared/forms/cd-validators';
 import { FinishedTask } from '../../../shared/models/finished-task';
 import { Permission } from '../../../shared/models/permissions';
+import { CephReleaseNamePipe } from '../../../shared/pipes/ceph-release-name.pipe';
 import { AuthStorageService } from '../../../shared/services/auth-storage.service';
+import { SummaryService } from '../../../shared/services/summary.service';
 import { TaskWrapperService } from '../../../shared/services/task-wrapper.service';
 import { NfsFormClientComponent } from '../nfs-form-client/nfs-form-client.component';
 
@@ -49,11 +51,13 @@ export class NfsFormComponent implements OnInit {
   allCephxClients: any[] = null;
   allFsNames: any[] = null;
 
+  defaultAccessType = { RGW: 'RO' };
   nfsAccessType: any[] = this.nfsService.nfsAccessType;
   nfsSquash: any[] = this.nfsService.nfsSquash;
 
   action: string;
   resource: string;
+  docsUrl: string;
 
   daemonsSelections: SelectOption[] = [];
   daemonsMessages = new SelectMessages(
@@ -79,6 +83,8 @@ export class NfsFormComponent implements OnInit {
     private router: Router,
     private rgwUserService: RgwUserService,
     private formBuilder: CdFormBuilder,
+    private summaryservice: SummaryService,
+    private cephReleaseNamePipe: CephReleaseNamePipe,
     private taskWrapper: TaskWrapperService,
     private cdRef: ChangeDetectorRef,
     private i18n: I18n,
@@ -114,6 +120,10 @@ export class NfsFormComponent implements OnInit {
       this.action = this.actionLabels.CREATE;
       this.getData(promises);
     }
+
+    const summary = this.summaryservice.getCurrentSummary();
+    const releaseName = this.cephReleaseNamePipe.transform(summary.version);
+    this.docsUrl = `http://docs.ceph.com/docs/${releaseName}/radosgw/nfs/`;
   }
 
   getData(promises) {
@@ -317,7 +327,8 @@ export class NfsFormComponent implements OnInit {
   fsalChangeHandler() {
     this.nfsForm.patchValue({
       tag: this._generateTag(),
-      pseudo: this._generatePseudo()
+      pseudo: this._generatePseudo(),
+      access_type: this._updateAccessType()
     });
 
     this.setPathValidation();
@@ -325,6 +336,12 @@ export class NfsFormComponent implements OnInit {
     this.cdRef.detectChanges();
   }
 
+  accessTypeChangeHandler() {
+    const name = this.nfsForm.getValue('name');
+    const accessType = this.nfsForm.getValue('access_type');
+    this.defaultAccessType[name] = accessType;
+  }
+
   setPathValidation() {
     if (this.nfsForm.getValue('name') === 'RGW') {
       this.nfsForm
@@ -435,6 +452,17 @@ export class NfsFormComponent implements OnInit {
     return newPseudo;
   }
 
+  _updateAccessType() {
+    const name = this.nfsForm.getValue('name');
+    let accessType = this.defaultAccessType[name];
+
+    if (!accessType) {
+      accessType = 'RW';
+    }
+
+    return accessType;
+  }
+
   onClusterChange() {
     const cluster_id = this.nfsForm.getValue('cluster_id');
     this.daemonsSelections = _.map(