New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mgr/dashboard: Show error on creating service with duplicate service id #47261
mgr/dashboard: Show error on creating service with duplicate service id #47261
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aaSharma14 Can you add a unit-test for checking the duplicate service id creation behavior?
|
jenkins test make check |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created an nfs service with id test. then I tried to create an iscsi service with the same id test it failed with the validation.
IMO, we should not consider the service_id for the validation, instead we should focus on the service_name, and check for its occurence in the table?
You can see the nfs.test at the bottom of the list.

Also, would it make sense to introduce a service_name field in the form which autopopulates based on the above two inputs (service_type.service_id)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, what happens if you try to create the service from the REST API alone? We should ensure that we build our UI with leveraging the REST API capabilities, rather than working around it. For example, a POST with an existing service_type + service_id should fail. Is that what currently happens?
For this purpose the UI Endpoints can be very useful (and I don't just mean for async validation, but also for pre-fetching data for validation purposes).
In order not to fetch a list with all the service types + ids (which could be large), what about of (async) fetching the list of services ids for the currently selected service type (so when the service type drop down is selected)?
.../mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts
Outdated
Show resolved
Hide resolved
...gr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.html
Outdated
Show resolved
Hide resolved
841bc17
to
7e88117
Compare
Thanks @epuertat , I have updated the PR with some back-end changes as well. So as per the new implementation, I have created a new PUT endpoint for editing a service. So if a user tries to create a service with existing service_type + service_id from the POST endpoint, the service won't get updated but It won't give any error as well (as per the cephadm implementation, there is no error message returned when we add the --no-overwrite flag to the apply command) and if the user uses the PUT endpoint to edit the service, the service will get updated accordingly. |
Thanks @nizamial09 , I have updated the PR. Regarding adding a service name field to the form, I'l open an other PR for that by opening a related tracker. |
i wasn't going for an input field that user needs to input. I was asking for a read-only field which auto-populates based on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validation looks good to me! left some code reviews..
.../mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts
Outdated
Show resolved
Hide resolved
.../mgr/dashboard/frontend/src/app/ceph/cluster/services/service-form/service-form.component.ts
Show resolved
Hide resolved
5b44a29
to
910c669
Compare
910c669
to
28c0558
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work @aaSharma14 ! Left some ideas over there, but this is already really nice.
| { | ||
| service_name: serviceName, | ||
| service_spec: serviceSpec | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this would require a model or a new class definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Editing a service is pretty much similar to the service creation (both require service name and service spec as parameters), I don't think this would require a separate model to be introduced.
| description: "\n :param service_spec: The service specification as JSON.\n\ | ||
| \ :param service_name: The service name, e.g. 'alertmanager'.\n \ | ||
| \ :return: None\n " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should definitely improve the code that takes docstrings and print those as heredoc blocks:
| description: "\n :param service_spec: The service specification as JSON.\n\ | |
| \ :param service_name: The service name, e.g. 'alertmanager'.\n \ | |
| \ :return: None\n " | |
| description: | | |
| :param service_spec: The service specification as JSON. | |
| :param service_name: The service name, e.g. 'alertmanager'. | |
| :return: None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WIll create a tracker and do this imrpovement for the entire openapi.yaml file.
28c0558
to
2212623
Compare
2212623
to
659569e
Compare
a89470c
to
f9190ca
Compare
|
jenkins test dashboard |
Fixes: https://tracker.ceph.com/issues/56689 Signed-off-by: Aashish Sharma <aasharma@redhat.com>
f9190ca
to
07cfd44
Compare
Fixes: https://tracker.ceph.com/issues/56689
Signed-off-by: Aashish Sharma aasharma@redhat.com
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "pacific"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume toxjenkins test windows