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

Proof of concept: plugin architecture based on event bus + plugin listeners, using go-plugin #1235

Closed
wants to merge 30 commits into from

Conversation

metacosm
Copy link
Contributor

@metacosm metacosm commented Jan 26, 2019

What is the purpose of this change? What does it change?

This proof of concept takes the work accomplished in #1173 and changes the underlying mechanism to use hashicorp/go-plugin instead, using plain RPC.

Was the change discussed in an issue?

No.

How to test changes?

  • Go to a directory outside of your $GOPATH (unless you know how to deal with go modules installed in $GOPATH)
  • git clone https://github.com/metacosm/odo-tracer-listener.git
  • cd odo-tracer-listener
  • git checkout go-plugin
  • go build -o tracer.listener.odo listener.go
  • mkdir -p ~/.odo/plugins/ (if you don't already have that dir)
  • cp tracer.listener.odo ~/.odo/plugins/
  • Build this PR and issue an odo command that uses the new oc command pattern (any service, catalog or link/unlink commands, only these commands are automatically wired to dispatch events)
  • You should see some plugin-related debugging messages
  • Check ~/.odo/plugins/tracer.log to see the logging performed by the tracer plugin.

Note: It might happen that the command you issued failed with an error and you might need to check that the plugin process is not still running: ps aux | grep tracer and then killall tracer.listener.odo. Basically, plugins are "managed" and need to be cleaned-up before the application exits. This is done by a deferred call in the main odo function. However, calls to os.Exit don't run deferred functions. I have added some code to perform plugins clean up before some calls to os.Exit but might have missed some, which might lead dangling plugin processes running (basically a server process). A proper solution to this issue will have to be devised.

@codeclimate
Copy link

codeclimate bot commented Jan 26, 2019

Code Climate has analyzed commit c504336 and detected 15 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Bug Risk 1
Style 13

View more on Code Climate.

@metacosm metacosm added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jan 26, 2019
@AppVeyorBot
Copy link

@codecov
Copy link

codecov bot commented Jan 27, 2019

Codecov Report

Merging #1235 into master will decrease coverage by 0.16%.
The diff coverage is 32.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1235      +/-   ##
==========================================
- Coverage   42.53%   42.36%   -0.17%     
==========================================
  Files          40       41       +1     
  Lines        5050     5136      +86     
==========================================
+ Hits         2148     2176      +28     
- Misses       2687     2741      +54     
- Partials      215      219       +4
Impacted Files Coverage Δ
pkg/odo/util/completion/completion.go 0% <ø> (ø) ⬆️
pkg/config/config.go 48.83% <0%> (-2.75%) ⬇️
pkg/odo/util/cmdutils.go 4.87% <0%> (-0.13%) ⬇️
pkg/odo/events/bus.go 40.57% <40.57%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update caea0b7...c504336. Read the comment docs.

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@kadel
Copy link
Member

kadel commented Jan 29, 2019

I have a lot of questions about plugin mechanism:

  • Have you considered using the same plugin system as kubectl?
  • How will be plugins distributed and installed?
  • What is the use case for plugins?
  • Do you have any particular plugin in mind while implementing this?

My other concern is that we have quite a lot of fundamental problems mainly with interacting with S2I.
We definitely want some kind of plugin mechanism for odo in the future. But we need to have a stable foundation that we can build on. Odo won't be useful without stable core functionality. If it is not useful, no-one is going to use odo or its plugins :-(

@metacosm
Copy link
Contributor Author

I have a lot of questions about plugin mechanism:

* Have you considered using the same plugin system as kubectl?

There is no plugin system in kubectl, just conventionally called external binaries. So you really cannot call that a plugin system as there is no real information exchange between the host and the "plugin".

* How will be plugins distributed and installed?

Binaries located in .odo/plugins/ right now, though it could be changed.

* What is the use case for plugins?

See: #1173
#1236
#1238

General use case: be able to extend odo without us having to implement everything people might want to do with it… :)

* Do you have any particular plugin in mind while implementing this?

As has been discussed several times already, the initial use case was supporting component CRD work without impacting the odo core.

My other concern is that we have quite a lot of fundamental problems mainly with interacting with S2I.
We definitely want some kind of plugin mechanism for odo in the future. But we need to have a stable foundation that we can build on. Odo won't be useful without stable core functionality. If it is not useful, no-one is going to use odo or its plugins :-(

Understood, though none of these issues are being worked on at the moment, at least, that I can see… The biggest obstacle I see right now is not moving fast enough on small things that should be done in a couple of days but are blocked by a review process that takes way too long.

@metacosm metacosm removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jan 30, 2019
@kadel
Copy link
Member

kadel commented Jan 31, 2019

I have a lot of questions about plugin mechanism:

* Have you considered using the same plugin system as kubectl?

There is no plugin system in kubectl, just conventionally called external binaries. So you really cannot call that a plugin system as there is no real information exchange between the host and the "plugin".

I agreed that this is not an ideal approach but on the other hand, it is easy to do, enough for a lot of use cases, and more importantly, it could mean that kubectl plugins will be compatible with odo. Which would be really nice.

* How will be plugins distributed and installed?

Binaries located in .odo/plugins/ right now, though it could be changed.

I know, but how the user will install it? Are we going to guide users in the docs to copy binaries to this directory? Are we going to provide some easier mechanism like odo plugin install etc..

My other concern is that we have quite a lot of fundamental problems mainly with interacting with S2I.
We definitely want some kind of plugin mechanism for odo in the future. But we need to have a stable foundation that we can build on. Odo won't be useful without stable core functionality. If it is not useful, no-one is going to use odo or its plugins :-(

Understood, though none of these issues are being worked on at the moment, at least, that I can see…

You are very welcomed to help us solve those issues.

The biggest obstacle I see right now is not moving fast enough on small things that should be done in a couple of days but are blocked by a review process that takes way too long.

Agreed, but I'm afraid that adding big changes that are not properly defined beforehand are going to make things even worse.
This is one of the reasons review process takes way too long.

@metacosm
Copy link
Contributor Author

metacosm commented Jan 31, 2019

There is no plugin system in kubectl, just conventionally called external binaries. So you really cannot call that a plugin system as there is no real information exchange between the host and the "plugin".

I agreed that this is not an ideal approach but on the other hand, it is easy to do, enough for a lot of use cases, and more importantly, it could mean that kubectl plugins will be compatible with odo. Which would be really nice.

The only way kubectl plugins would work with odo was if odo had the same commands. As far as I understand it, at least: basically, if kubectl detects a properly named binary in the path, it will run that binary if its name matches the input command name. It would be easy to support this in odo as well, I think. That wouldn't help much, though…

Binaries located in .odo/plugins/ right now, though it could be changed.

I know, but how the user will install it? Are we going to guide users in the docs to copy binaries to this directory? Are we going to provide some easier mechanism like odo plugin install etc..

Could be an option, yes. You could imagine pulling a plugin from github and compiling it on the fly to install it.

My other concern is that we have quite a lot of fundamental problems mainly with interacting with S2I.
We definitely want some kind of plugin mechanism for odo in the future. But we need to have a stable foundation that we can build on. Odo won't be useful without stable core functionality. If it is not useful, no-one is going to use odo or its plugins :-(

Understood, though none of these issues are being worked on at the moment, at least, that I can see…

You are very welcomed to help us solve those issues.

That's not where my expertise lies, though, so I'm trying to help where I can help.

Agreed, but I'm afraid that adding big changes that are not properly defined beforehand are going to make things even worse.
This is one of the reasons review process takes way too long.

The point of this work (as is #1161) is to foster the discussion and see how things could work, because it's easier to reason on concrete examples than abstract ideas. Also, because restrictions might only become apparent after actually trying to implement a concept. However, if no one looks at it then it's just work for nothing.

@metacosm metacosm force-pushed the event-bus-go-plugin branch from 955407b to 8ccf08c Compare January 31, 2019 09:22
@metacosm metacosm requested a review from sspeiche as a code owner January 31, 2019 09:22
@AppVeyorBot
Copy link

@cmoulliard
Copy link
Contributor

supporting component CRD work without impacting the odo core.

another use cases could be to :

  • audit, log what odo is doing
  • scaffold a project (spring boot, vertx, tornthail, ....)
  • export resources : helm chart, openshift template, ...

@metacosm metacosm force-pushed the event-bus-go-plugin branch from 8ccf08c to 75764f7 Compare February 1, 2019 17:12
@AppVeyorBot
Copy link

@metacosm metacosm force-pushed the event-bus-go-plugin branch from 75764f7 to b7ef382 Compare February 4, 2019 16:29
@AppVeyorBot
Copy link

@metacosm metacosm force-pushed the event-bus-go-plugin branch from b7ef382 to 9e1e28a Compare February 5, 2019 19:35
@AppVeyorBot
Copy link

@anmolbabu
Copy link
Contributor

anmolbabu commented Feb 11, 2019

Extremely difficult to review the PR(very huge PR beyond the size I could think of for a PR ;) )...
Can we plan a session where you can walk the reviewers through the code?

API is found at https://github.com/metacosm/odo-event-api.
This, however, doesn't work well with vendoring so right now, both the
app and plugin can only be built against an api that's in the same spot
in $GOPATH. See golang/go#20481 for more
details.
For some reason, need to force grpc version explicitly otherwise
go-plugin won't compile. Seems like glide doesn't properly resolves the
transitive dependency… :(
@metacosm metacosm force-pushed the event-bus-go-plugin branch from 9e1e28a to c504336 Compare February 12, 2019 17:23
@AppVeyorBot
Copy link

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Mar 8, 2019
@openshift-ci-robot
Copy link
Collaborator

@metacosm: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot
Copy link
Collaborator

@metacosm: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/prow/e2e-core c504336 link /test e2e-core
ci/prow/e2e-scenarios c504336 link /test e2e-scenarios

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@girishramnani
Copy link
Contributor

girishramnani commented May 2, 2019

This PR as of now needs alot of work due to the major changes in odo. It would be better if a new PR using the current master is created at a later point when plugins become priority.

Hence closing the PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants