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

Add the ability to refresh the templates #2088

Closed
xvlcwk opened this issue Jul 28, 2018 · 12 comments
Closed

Add the ability to refresh the templates #2088

xvlcwk opened this issue Jul 28, 2018 · 12 comments
Labels
area/templates kind/enhancement Applied to Feature Requests
Projects
Milestone

Comments

@xvlcwk
Copy link

xvlcwk commented Jul 28, 2018

First off: Kudos and thank you very much for the excellent work with portainer.

I just realized that #2017 removes the possibility to host your own template files.

We used to have our templates.json in a git repo to ensure that everyone can edit them, but noone messes with them.

So I wondered what's the new recommended way to do something like that without having to add the template files by hand.

Can I mount it somewhere, where portainer will read it regularly or can I trigger a reimport of the --template paramater somehow?

I'm sorry if I'm missing something obvious.

Thanks in advance.

@Codelica
Copy link

At this point Portainer will load external template definitions on first run, and then they are "managed" within Portainer's UI as you are seeing. I think the only way to "flush and reload" your templates definitions is to remove all the templates loaded into Portainer (via API calls) and then restart your Portainer container with --templates.

I'm in a similar situation (just want templates loaded from our vetted templates.json URL). For now I'm just contemplating a nightly delete (via API) and container re-create. Would be nice if there was an option for pre 1.19 style template hosting, but not sure if that will come. So for now I think that's the route. As for editing templates that have been loaded, it looks like all "admin" users are allowed. I don't think there is a way to disable that (which would be nice also :) ).

Regards..

@ncresswell
Copy link
Member

ncresswell commented Jul 30, 2018 via email

@deviantony deviantony added kind/enhancement Applied to Feature Requests area/templates labels Jul 31, 2018
@deviantony deviantony changed the title Template managment with removal of templateurl Add the ability to refresh the templates Jul 31, 2018
@deviantony
Copy link
Member

deviantony commented Jul 31, 2018

As @Codelica stated, external templates declared via --templates or --template-file (I need to update the docs about this one, it allows you to read templates from a path on disk) are loaded only once and then persisted inside the database.

The way to go then would be to use the HTTP API or the UI directly to update these templates. We'll definitely add a way to refresh the template list as well as an API operation.

Note, the sync process will probably be based on the title and type field. There is no way to ensure uniqueness via the template file so the first entry matching one in the database based on the title and type will be synced, other entries with the same title and type will be ignored.

UI-wise, I'm thinking about adding a "Refresh" button to the templates view available for administrators only.

@deviantony deviantony modified the milestones: 1.19.x, 1.19.2 Jul 31, 2018
@deviantony
Copy link
Member

Update on this topic:

We're going to revert the behavior of the --templates to what it was prior to 1.19.0. Meaning that when you specify the --templates flag, each time you access the templates view, we'll poll the templates from the specified URL and display them. We'll also disable template management when the --templates flag is specified.

If the --templates flag is not specified, we'll keep the current behavior of loading the Portainer database with the templates available at /templates.json with template management enabled in-app.

@deviantony
Copy link
Member

@xvlcwk @Codelica keen to give a try to portainer/portainer:pr2119 and give us some feedback? It re-introduces the ability to use external templates.

@Codelica
Copy link

Codelica commented Aug 3, 2018

Sounds good. I’m traveling for a few days, but will give it a try Monday when I’m back at work. Thanks!

@xvlcwk
Copy link
Author

xvlcwk commented Aug 6, 2018

I'm sorry for the late response.

I deployed and played around with it over the weekend and it works really good.
The only thing, that confused me, is that one can start to edit/create templates and only get warned about it not working at the end. However this is not really a problem.

I'm going to deploy it on our live station and will respond if there is something else going wrong, but so far it's working great!

Thank you very much.

@deviantony
Copy link
Member

Hey @xvlcwk

Thanks for the feedback, you should not be able to edit/create a template when using external templates, it should be disabled. I'll review it.

@deviantony
Copy link
Member

I'm not able to reproduce your problem @xvlcwk

When using external templates, template management (creation, edition, deletion) is disabled.

External templates declared in settings:

portainer 9

Templates view:

portainer 10

Can you tell me how I can reproduce your problem?

@Codelica
Copy link

Codelica commented Aug 6, 2018

This seems to be working fine for me. It pulls our templates from our URL, doesn't show any edit options, and refreshes the template info from the URL.

@xvlcwk
Copy link
Author

xvlcwk commented Aug 6, 2018

I'm very sorry. I couldn't reproduce the issue on our live instance. I'm not sure how that happened before.

When portainer is unable to parse the template, it will show the "add template" button and let you put in all the variables, before telling you, that it's unable to create It. However I don't think this is a problem at all, especially cause this means someone is already ignoring a big red warning.

I have no Idea how I managed to get the edit button since portainer doesn't show the templates in that case. My best guess is that I had something broken in my or portainers cache.

So I'm very sorry for wasting your time.

@deviantony
Copy link
Member

No worries, thanks for the feedback @xvlcwk @Codelica 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/templates kind/enhancement Applied to Feature Requests
Projects
No open projects
Roadmap
Portainer Release 1.19.2
Development

No branches or pull requests

4 participants