Skip to content
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

Merged

Conversation

aaSharma14
Copy link
Contributor

Fixes: https://tracker.ceph.com/issues/56689
Signed-off-by: Aashish Sharma aasharma@redhat.com

Screenshot from 2022-07-25 16-26-57

Contribution Guidelines

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

@aaSharma14 aaSharma14 requested a review from a team as a code owner July 25, 2022 11:09
@aaSharma14 aaSharma14 requested review from bryanmontalvan and nizamial09 and removed request for a team July 25, 2022 11:09
@aaSharma14 aaSharma14 added this to In progress in Dashboard via automation Jul 25, 2022
Dashboard automation moved this from In progress to Reviewer approved Jul 25, 2022
Copy link
Contributor

@avanthakkar avanthakkar left a 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?

@avanthakkar
Copy link
Contributor

jenkins test make check

Copy link
Member

@nizamial09 nizamial09 left a 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.
Screenshot from 2022-07-26 13-55-34

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)?

Dashboard automation moved this from Reviewer approved to Review in progress Jul 26, 2022
Copy link
Member

@epuertat epuertat left a 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)?

@aaSharma14 aaSharma14 force-pushed the fix-duplicate-service-creation branch from 841bc17 to 7e88117 Compare July 28, 2022 06:26
@aaSharma14
Copy link
Contributor Author

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)?

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.

@aaSharma14
Copy link
Contributor Author

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. Screenshot from 2022-07-26 13-55-34

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)?

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.

@avanthakkar
Copy link
Contributor

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. Screenshot from 2022-07-26 13-55-34

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)?

I don't think we need a new service_name field here..bcz its anyways assigned as ${service_type}.${service_id} , thats how it done in cephadm, it doesnt ask for name as input as id & type are enough.

@nizamial09
Copy link
Member

I don't think we need a new service_name field here..bcz its anyways assigned as ${service_type}.${service_id} , thats how it done in cephadm, it doesnt ask for name as input as id & type are enough.

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 service_type and service_id, just to let the user know that this will be the service_name once you create it.

Copy link
Member

@nizamial09 nizamial09 left a 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..

Copy link
Member

@epuertat epuertat left a 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.

src/pybind/mgr/dashboard/controllers/service.py Outdated Show resolved Hide resolved
src/pybind/mgr/dashboard/controllers/service.py Outdated Show resolved Hide resolved
Comment on lines +48 to +51
{
service_name: serviceName,
service_spec: serviceSpec
},
Copy link
Member

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?

Copy link
Contributor Author

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.

Comment on lines +8902 to +8904
description: "\n :param service_spec: The service specification as JSON.\n\
\ :param service_name: The service name, e.g. 'alertmanager'.\n \
\ :return: None\n "
Copy link
Member

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:

Suggested change
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

Copy link
Contributor Author

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.

src/pybind/mgr/dashboard/services/orchestrator.py Outdated Show resolved Hide resolved
@aaSharma14 aaSharma14 force-pushed the fix-duplicate-service-creation branch from 28c0558 to 2212623 Compare August 1, 2022 05:55
@aaSharma14 aaSharma14 force-pushed the fix-duplicate-service-creation branch from 2212623 to 659569e Compare August 1, 2022 06:04
Dashboard automation moved this from Review in progress to Reviewer approved Aug 1, 2022
@aaSharma14 aaSharma14 force-pushed the fix-duplicate-service-creation branch from a89470c to f9190ca Compare August 1, 2022 08:37
@aaSharma14
Copy link
Contributor Author

jenkins test dashboard

@aaSharma14 aaSharma14 force-pushed the fix-duplicate-service-creation branch from f9190ca to 07cfd44 Compare August 2, 2022 05:44
@nizamial09 nizamial09 merged commit 7e12357 into ceph:main Aug 2, 2022
12 of 13 checks passed
Dashboard automation moved this from Reviewer approved to Done Aug 2, 2022
@nizamial09 nizamial09 deleted the fix-duplicate-service-creation branch August 2, 2022 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Dashboard
  
Done
4 participants