Skip to content

Control cluster-admin HTTP route with API - #82

Merged
DavidePrincipi merged 8 commits into
mainfrom
feat-7312
Feb 21, 2025
Merged

DavidePrincipi merged 8 commits into
mainfrom
feat-7312

Conversation

@DavidePrincipi

Copy link
Copy Markdown
Member

Manage cluster-admin/ with set-route action, like routes created by modules. With this approach, cluster-admin becomes as configurable as any other HTTP route through the standard API.

This PR adds to set-route (and get-route) two new (optional) attributes:

  • priority, required by cluster-admin to override any other rule
  • slash_redirect, required by cluster-admin to fix the URL path if the trailing slash is missing. E.g. http://myns8.example.org/cluster-admin is redirected to /cluster-admin/. This new feature would be useful also to other web applications (e.g. Rspamd web UI).

It also fixes write-hosts helper to wait for complete Traefik startup, retrying if the API response is 404, which is a transitory condition during Traefik startup.

Refs NethServer/dev#7312


Note: I tried to call the set-route action from the Traefik instance itself during create-module, but at that time roles and permissions are still unconfigured and I got a 403.

Redirect to path with trailing slash. This new behavior is required by
/cluster-admin and /rspamd paths.
Override the automatic priority assignment rule with a custom value.
Required for cluster-admin/ route.

@gsanchietti gsanchietti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems good, but needs real testing to see if something is really missing

@DavidePrincipi

Copy link
Copy Markdown
Member Author

Thank you for you reviews, I'm squashing the fixup commits.

- Treat a 404 status code as still worth a retry. When Traefik is
  started the API endpoint is not immediately accessible.
- Wait Traefik full startup with the write-hosts helper.
Implement cluster-admin/ HTTP route with set-route action as other
routes.
Generate and store API_PATH near _api.yml creation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants