From: Melissa Li Date: Tue, 19 Jul 2022 21:05:14 +0000 (-0400) Subject: mgr/dashboard: validate mds service_id and helper text for service_id X-Git-Tag: v17.2.6~284^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9297b288752f7aa8aa33888699e6e5dddee6d3fb;p=ceph.git mgr/dashboard: validate mds service_id and helper text for service_id Validate mds service_id to avoid mds daemon from being created and going into error state due to invalid id. Also add helper text to describe the role of service_id. Fixes: https://tracker.ceph.com/issues/56077 Signed-off-by: Melissa Li (cherry picked from commit 1d6cb2882d5b9c2a058631a2c189706bcdc73e68) --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html index dcd898d88537..7db0abfcaaf1 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html @@ -66,10 +66,12 @@
- + for="service_id"> + Id + Used in the service name which is <service_type.service_id> +
The value does not match the pattern <service_id>[.<realm_name>.<zone_name>]. + MDS service id must start with a letter and contain alphanumeric characters or '.', '-', and '_'
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts index b2fbe9c890cd..0effaaef3f66 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts @@ -29,6 +29,7 @@ import { TaskWrapperService } from '~/app/shared/services/task-wrapper.service'; }) export class ServiceFormComponent extends CdForm implements OnInit { readonly RGW_SVC_ID_PATTERN = /^([^.]+)(\.([^.]+)\.([^.]+))?$/; + readonly MDS_SVC_ID_PATTERN = /^[a-zA-Z_.-][a-zA-Z0-9_.-]*$/; readonly SNMP_DESTINATION_PATTERN = /^[^\:]+:[0-9]/; readonly SNMP_ENGINE_ID_PATTERN = /^[0-9A-Fa-f]{10,64}/g; readonly INGRESS_SUPPORTED_SERVICE_TYPES = ['rgw', 'nfs']; @@ -87,9 +88,20 @@ export class ServiceFormComponent extends CdForm implements OnInit { service_id: [ null, [ - CdValidators.requiredIf({ - service_type: 'mds' - }), + CdValidators.composeIf( + { + service_type: 'mds' + }, + [ + Validators.required, + CdValidators.custom('mdsPattern', (value: string) => { + if (_.isEmpty(value)) { + return false; + } + return !this.MDS_SVC_ID_PATTERN.test(value); + }) + ] + ), CdValidators.requiredIf({ service_type: 'nfs' }),