这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@Flink
Copy link
Contributor

@Flink Flink commented Aug 26, 2015

As discussed in #1205, I tried a way to manage plugins and be able to do a dokku plugins-install only on core ones.

This PR is here to discuss the features and the details of the implementation.

It’s pretty basic for now but it works as intended :)
So we have three subdirectories in /var/lib/dokku/plugins, core, custom and enabled. Plugins are now divided in two categories: core ones and other ones.
The enabled directory only links to plugins (either in core or enabled directories). The core plugins are enabled automatically when installing dokku and cannot be disabled.

There are two new commands:

  • dokku plugins:enable <name> to enable a third party plugin.
  • dokku plugins:disable <name> to disable a third party plugin. Core plugins cannot be disabled by this command.

plugins-install and plugins-install-dependencies now take an optional argument --core which when set will instruct those commands to only refer to the core plugins. This should resolve the issue #1205.
This happens by setting PLUGIN_PATH to /var/lib/dokku/plugins/core instead of the default /var/lib/dokku/plugins/enabled when --core is set.

/cc @josegonzalez @michaelshobbs @jimeh

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here I did this since I think outputting only the name of the plugins is more useful than the complete path. I might be wrong 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

Copy link
Member

Choose a reason for hiding this comment

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

This probably will need to change with plugn, right @michaelshobbs ?

@Flink
Copy link
Contributor Author

Flink commented Aug 26, 2015

I did not look at the tests at all since I don’t know where we’re going exactly 😁

@jimeh
Copy link
Contributor

jimeh commented Aug 26, 2015

Looks like a good start to my dokku-n00b eyes :)

And not that you've gotten there yet, but just so it's mentioned here, the upgrade process would obviously need to delete existing core plugins in the old plugins path, and probably move any non-core plugins into the new custom path.

@josegonzalez
Copy link
Member

@michaelshobbs how much of this would be affected by the plugn pr?

@michaelshobbs
Copy link
Member

There is significant overlap. One of you guys should really take a look at plugn and that branch before going too far down this path. I'd hate for you to waste your time.

@Flink
Copy link
Contributor Author

Flink commented Aug 27, 2015

@jimeh 👍

@michaelshobbs I looked at your PR and I don’t think there’s a real problem here. I’m pretty sure (but I didn’t check) that we could replicate what I do here with plugn instead of pluginhook. Plugn seems to take an env variable for its plugins directory so the mechanism is pretty similar to the one used here.

Also the goal of this PR isn’t the same than yours. Here we try to give a solution (that seems pretty clean to me) to the problem in issue #1205. Another important point I think is that plugin compatibility is not affected at all by this PR.

@Flink
Copy link
Contributor Author

Flink commented Aug 27, 2015

Just found a bug: source "$(dirname "$0")/../common/functions" won’t work with symlinks 😕
Anyone knows why source "$PLUGIN_PATH/common/functions" isn’t used instead?

@jimeh
Copy link
Contributor

jimeh commented Aug 27, 2015

Really? Shouldn't source follow symlinks? Or does dirname $0 return the real path rather than the symlinked one?

@Flink
Copy link
Contributor Author

Flink commented Aug 27, 2015

well it won’t work with ls too. The thing that works is when you move around with cd because your shell keeps an history from where you’ve “entered” the symlinked directory. And since here there is no context, .. refers to the “real” parent directory.

@Flink
Copy link
Contributor Author

Flink commented Aug 27, 2015

So we’ll need to use $PLUGIN_PATH instead in all plugins (but compatibility will be broken 😕) or we’ll have to drop symlinks and copy the plugins between directories. Other ideas?

@jimeh
Copy link
Contributor

jimeh commented Aug 28, 2015

Ah, yeah you're right. The .. does indeed screw it up. Sorry, seemed weird while I was guessing off the top of my head.

Seems symlinks for custom plugins isn't going to work then. But I just did some basic testing and seems custom plugins will work if they simply live in the folder relative to the common symlink, rather than being symlinked in themselves.

I tested a folder structure like this locally with some mock plugins:

/var
 └── lib
     └── dokku
         ├── core-plugins
         |   ├── common
         |   ├── checks
         |   └── domains
         ├── disabled-plugins
         |   └── mongodb
         └── plugins
             ├── common -> /var/lib/dokku/core-plugins/common
             ├── checks -> /var/lib/dokku/core-plugins/checks
             ├── domains -> /var/lib/dokku/core-plugins/domains
             ├── forego
             └── redis

It's mostly just the enable and disable commands that need to simply move the custom plugin folder back and forth, while refusing to operate on symlinks. It might not be the absolutely cleanest solution, but probably the most decent one to avoid breaking backwards compatibility.

And on a side-note, the example I have above would mean even less backwards compatibility issues, as even installation instructions in existing plugins would still be correct when they instruct you to copy/clone/extract the plugin to /var/lib/dokku/plugins.

As for why dirname "$0" is used, seems silly, but I guess someone started the convention and others followed... lol

@josegonzalez
Copy link
Member

Just convention. If you guys want to make a separate pr that uses $PLUGIN_PATH, that would work.

@Flink
Copy link
Contributor Author

Flink commented Aug 28, 2015

@jimeh yes I think your solution will work and if we want to keep plugin compatibility we don’t really have a choice.

@josegonzalez we could then we’ll have to update (almost) all community plugins too 😁 I’m not sure it’s worth the effort.

@jimeh
Copy link
Contributor

jimeh commented Aug 28, 2015

I think it's worth to change core plugins to use $PLUGIN_PATH in an effort to start setting a new and better convention :)... I'd be happy to submit such a PR.

jimeh added a commit to jimeh/dokku that referenced this pull request Aug 28, 2015
As briefly discussed in dokku#1425, source the `common/functions` file via an
absolute path, rather than determining the relative path by using
`dirname`. 3rd-party plugins should follow suit and use the new
`$PLUGIN_PATH` convention too.
@Flink
Copy link
Contributor Author

Flink commented Aug 28, 2015

Ok since you seem to be motivated, I’ll wait for you PR. Meanwhile, I’ll patch my plugins and forks 😉

@jimeh
Copy link
Contributor

jimeh commented Aug 28, 2015

PR is in, but I don't think we can rely on or assume all 3rd party plugins will be updated any time soon. So plugin management is still probably best done via moving them back and forth. But at least new plugins will hopefully follow the new convention and make life easier for everyone in the future.

@Flink
Copy link
Contributor Author

Flink commented Aug 28, 2015

Yes but it’s sad.

We can update and submit PR to a lot of them. There’s also a lot of plugins which aren’t active/maintained anymore 😕

Since we’ll need an upgrade script with the new plugins management, we could check for source $(dirname $0)/../common/functions in installed ones and print a warning (and not enable them).

@Flink
Copy link
Contributor Author

Flink commented Aug 28, 2015

or better yet, replace automatically the line with the new one but still print a warning message to update plugin (or report the error to the author).

@jimeh
Copy link
Contributor

jimeh commented Aug 28, 2015

That's one solution, although when/how would that check be executed? I'm assuming as part of plugins:enable right?

And come to think of it, the enable/disable thing is nice, but if we use the move solution the benefit is that there's ZERO difference in how things work now. Plugins are enabled by default, they don't run as part of dokku installation, and you can disable plugins via a simple command instead of manually deleting or moving the directory on the server.

The symlink solution feels nicer to me from a architectural point of view, but does alter how the end user installs plugins. An extra step isn't much, but it's still different.

Don't know which one you prefer @Flink, nor am I fully sure which one I prefer, just wanted to point things out for clarity's sake :)

P.S. As a nod towards moving plugins around, OSX actually handles user-installed fonts that way. User fonts live in ~/Library/Fonts, and if you disable one, it's moved to ~/Library/Fonts (Disabled).

@Flink
Copy link
Contributor Author

Flink commented Aug 28, 2015

Well I think I’m like you on this one, the symlink solution seems “better” but what you say is also very true. Moving plugins instead of symlinking them and changing the directory structure will be better from a user point of view.

We had an issue with third party plugins installing things via apt while
already installing dokku itself via apt.

To resolve this, `plugins-install` and `plugins-install-dependencies`
now can take a `--core` flag allowing to execute the install hook only
on core plugins and not on third party plugins.

Another feature with this modification is the ability to disable/enable
plugins. Two new commands now exist:

* `plugins:enable <name>` to enable a previously disabled plugin
* `plugins:disable <name>` to disable an installed plugin. This won’t
  work on core plugins.
@Flink Flink changed the title [WIP] Plugins management Plugins management Sep 9, 2015
@Flink
Copy link
Contributor Author

Flink commented Sep 9, 2015

Ok I think this PR is done now and should work as expected. I used the approach suggested by @jimeh with directories and mv instead of symlinks. So we don’t need an upgrade script or something like that, it will work out of the box with an existing installation. You just have to upgrade dokku normally 😄

/cc @josegonzalez @michaelshobbs

@michaelshobbs
Copy link
Member

If we're good with this I'd like to merge it into the plugn branch and merge them both into master via that PR; unless we want this in before 0.4.0. Though I didn't think we were releasing another 0.3.x.

@Flink
Copy link
Contributor Author

Flink commented Sep 9, 2015

Well it fixes the issue with debian installation so it can be merged in a 0.3.x branch. But I personally don’t have a preference :)

@jimeh
Copy link
Contributor

jimeh commented Sep 9, 2015

I don't mind either :)... Personally I worked around the installation issue by having the chef cookbook disable/enable plugins itself before installation/upgrade, so I don't mind waiting till 0.4.x for a fix.

@josegonzalez
Copy link
Member

We are not doing another 0.3.x release.

@Flink
Copy link
Contributor Author

Flink commented Sep 9, 2015

Ok so it settled ;) @michaelshobbs Why not merge this in master and then rebase your PR?

@josegonzalez
Copy link
Member

We're not rebasing plugn anymore.

@michaelshobbs
Copy link
Member

@Flink 6 of one have a dozen of the other. Hence me saying I'd like to do it this way. Just a preference.

@Flink
Copy link
Contributor Author

Flink commented Sep 9, 2015

Ok I was just asking 😅 If it’s easier for you like that then there’s no problem (I don’t really mind 😁)

Copy link
Member

Choose a reason for hiding this comment

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

Pretty sure this should all be done via plugn, right?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah but if we're going to have two enabled places then we'll need to manage the plugin path ourselves somehow.

Copy link
Member

Choose a reason for hiding this comment

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

There are still some unknowns for me about how this plays along with plugn. Another reason I'd like to pull it into the plugn branch and play around with it. Anyone opposed to this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nope

@michaelshobbs
Copy link
Member

Yeah no worries at all. It's probably all the same but my thinking was just that if we're going to overhaul plugins then let's just do it in one go.

Copy link
Member

Choose a reason for hiding this comment

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

This is never changed in the debian packaging, so we can't merge this...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How so? Why couldn’t you update the Makefile?

Copy link
Member

Choose a reason for hiding this comment

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

Well the debian packaging doesn't use a makefile...

@josegonzalez
Copy link
Member

Okay I'm going to close this PR. Please redo the PR and target the mh-switch-to-plugn branch. We can merge it into there and then see how we like/dislike the experience :)

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