canonical / maas-ui

The UI for MAAS (metal-as-a-service)
https://maas.io
Other
51 stars 50 forks source link

MAAS OpenAPI docs are not available in air-gapped mode #4648

Closed webteam-app closed 1 year ago

webteam-app commented 1 year ago

Bug originally filed by billwear at https://bugs.launchpad.net/bugs/1999579

To reproduce:

  1. Install MAAS 3.3 RC1 or greater.

  2. Take the MAAS server into air-gapped mode (i.e., "localhost" still working, but no ext. N/W).

  3. Access the "local documentation" from the link in the bottom fringe of MAAS.

  4. Click on "API documentation" OR replace the "maas-documentation-25.html" with "../api/docs"

  5. A partial page will come up with some circles and boxes, but no text and no OpenAPI output.

Have confirmed with Peter M. that the OpenAPI docs require swagger components that are not stored locally and must be fetched online. The spec gave no indication that the OpenAPI docs had to work in air-gapped mode.

amylily1011 commented 1 year ago

Can we fix this before rc2? (expected Thursday Dec 15, 2022 - US central timezone). @anthonydillon @ndv99 (Otherwise, we will doc this as a known issue for RC2)

ndv99 commented 1 year ago

So from my understanding, I think Jack wrote the page for our OpenAPI docs, which is served by the backend, and if I'm not mistaken that relies on being able to connect to https://unpkg.com/ in order to get the SwaggerUI library. To fix this I think I'd need to create a new page in the UI that uses the SwaggerUI lib through an NPM install so it will work offline. This would change the route from /MAAS/api/docs to /MAAS/r/some-new-page-name

If this sounds like an acceptable solution I should be able to get that together fairly quick, what time is RC2 releasing?

ndv99 commented 1 year ago

Actually I've had another thought/concern - the YAML output is generated serverside, so we'd need some kind of new endpoint to get that to the frontend, @SK1Y101 what do you think?

anthonydillon commented 1 year ago

I'm under the impression that air-gapped environments have no public internet access but should have full access to the maas instance and API. Sorry if I'm late to this but why would expect the docs to work locally without dynamic dependencies?

SK1Y101 commented 1 year ago

Hi, commenting late on this because I only just read my emails. Unless I misunderstand, this isn't actually a UI issue: MAAS Offline docs has included a local version of the OpenAPI spec built from the local MAAS at http://$(MAAS_ip):5240/MAAS/api/docs/, which uses the Django template view at maas/src/maasserver/templates/openapi.html.

There was a note pinned to switch this over to locally storing the dependencies rather than relying on unpkg at some pointâ„¢, but that was considered very low priority at the time.

SK1Y101 commented 1 year ago

Fix in progress, should work as expected now

ndv99 commented 1 year ago

Fix merged, closing as completed