8000 stage0: added support for fetching plugins, refactored docker/http(s) by cgonyeo · Pull Request #2830 · rkt/rkt · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

stage0: added support for fetching plugins, refactored docker/http(s) #2830

Closed
wants to merge 1 commit into from

Conversation

cgonyeo
Copy link
Member
@cgonyeo cgonyeo commented Jun 22, 2016

Adds support for having images fetched via a plugin. Plugins take the
form of a binary on the user's path named "rkt-fetcher-%s", with the %s
taking the place of the schema, so for example fetching
docker://alpine is redirected to the rkt-fetcher-docker binary.

When the plugin is started it has a JSON configuration written to it on
stdin, and its stdout and stderr are forwarded on to the user. The
configuration contains paths to write the ACI and ASC files to, which
rkt will then verify (unless the insecure image option is specified).

This isn't done yet, just putting this up for review to see what people think before I work on it further.

Things done:

  • Wrote the plugin fetcher in rkt
  • Moved the logic for fetching docker images into a plugin

Things left to do:

  • Pull the http(s) logic out into another plugin
  • Write docs
  • Tweak autotools to build the plugins

Questions:

  • Is putting the plugins on the path ok? Should they instead live in a known directory like stage1s can? Maybe support both?
  • Does the config look versatile enough? Should there be more things in its schema?

To try it out:

  • go build -o rkt-fetcher-docker rkt/image/fetchers/remote-aci/main.go
  • put rkt-fetcher-docker on your path
  • build this version of rkt
  • fetch something

Related issue: #1831

@jonboulle
Copy link
Contributor

cc @sgotti, @runcom

defer aciFile.Close()

if !f.InsecureFlags.SkipImageCheck() {
ascFile, err := os.Open(ascFilePath)
Copy link
Contributor
@runcom runcom Jun 23, 2016

Choose a reason for hiding this comment

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

aren't you double opening this file (if the if above is true)?

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm? ascFile != aciFile

Copy link
8000 Contributor

Choose a reason for hiding this comment

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

my bad, it was early in the morning here..

@sgotti
Copy link
Contributor
sgotti commented Jun 23, 2016

Does the config look versatile enough? Should there be more things in its schema?

As an example, there's the need to both send and receive http caching information to/from an http plugin (like ETag and Cache controls saved in the store remote data).

Since in this way every plugin may have different inputs/outputs I'm not sure which is the best way to make generic input config and outputs or every plugin (or schema) should have different inputs and outputs.

@cgonyeo
Copy link
Member Author
cgonyeo commented Jun 23, 2016

@sgotti The hope is that this change would enable 3rd parties to write plugins without our intervention, and tweaking the config for each plugin means you need rkt support added in for each additional plugin. Maybe the answer here is just in the input include all the possible information the plugin could want, and each one will probably only need a subset of it?

Also as far as an output config, I could only pass the plugin's stderr through to the user, and have plugins write a report in json to stdout that rkt can parse, so as to pass rkt Etag and Cache controls and such.

@cgonyeo
Copy link
Member Author
cgonyeo commented Jun 28, 2016

Just pushed a change that moves the https fetching logic into a plugin. Also changed the plugins, such that they're expected to write a result json to stdout when they're finished. This is used to pass things like cache data back to rkt.

InsecureOpts *InsecureOpts `json:"insecure"`
Debug bool `json:"debug"`
Headers map[string]map[string][]string `json:"headers"`
OutputACIPath string `json:"output_aci_path"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This implies ACI being the image format interface format between rkt and fetcher plugins, don't we want to make the leap and go straight to OCI?

@cgonyeo cgonyeo force-pushed the fetching-plugins branch from 7a930d3 to 8fc886a Compare July 5, 2016 23:51
@cgonyeo
Copy link
Member 8000 Author
cgonyeo commented Jul 5, 2016

Status update: haven't forgotten about this. Currently working through the broken tests and figuring out what functionality I'm still missing.

@jonboulle
Copy link
Contributor

bump

@cgonyeo
Copy link
Member Author
cgonyeo commented Jul 14, 2016

I'm currently in the middle of refactoring hell, getting the https plugin to have all the functionality of the previous code. As I'm not working today/tomorrow, I hope to have this finished sometime next week.

On Jul 14, 2016, at 06:47, Jonathan Boulle notifications@github.com wrote:

bump


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@sgotti
Copy link
Contributor
sgotti commented Jul 14, 2016

@dgonyeo

before commenting on the code I have a broader doubt.

In relation to #2925 looks like these are plugins for fetching given an input scheme. But the input scheme used with rkt (http://, docker://) isn't a transport scheme but covers the distribution concept. To be clear http:// is not just the transport but covers returning an aci and optionally a provided signature url, the docker:// covers calling docker2aci the return an aci using as a distribution a docker registry

Did I get it right?

I originally thought (reading the linked issues) that the idea was to provide plugins for a transport, also for being able to lower some privileges.
So, for example for http:// will just be a plugin to fetch a file from http. docker:// instead doesn't make great sense being a plugin since the transport is done inside docker2aci and I can't see a strong need for different implementations.

Additionally there're other parts that fetch from a remote for example the appc pubkeys are fetched in rkt/pubkey/pubkey.go and they could use a transport plugin.

Perhaps I missed some discussions around this. @lucab?

}
defer ascFile.Close()
_, err = fetchURL(config, "Signature", config.Scheme+"://"+config.Name+".asc", ascFile)
if err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

The original httpfetcher, fetches the asc if provided externally by the user. Instead this assumes that an asc exists and is the aci path + .asc.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah you're right. Haven't pushed it yet, but I tossed this and am refactoring the fetching logic rkt already had to be part of the https plugin, and I'll fix the asc logic.

@cgonyeo
Copy link
Member Author
cgonyeo commented Jul 18, 2016

@sgotti I had been implementing this with the assumption that distribution and image format would remain bundled like they are in rkt today, but after reading over #2925 I think this is just splitting out the distribution mechanism, and we could evaluate making the image format logic more pluggable after this.

This implementation hands a plugin a string, and the plugin is expected to perform the distribution logic to convert that string into a local ACI (and possible ASC), after which the stage0 binary imports this into the store. In the case of the docker:// scheme, this means that the distribution also involves the image conversion. I intend for this PR to have the stage0 binary do AppC discovery and hand the resulting URI off to a plugin after doing the template substitution, and the stage0 itself would fetch the public key over https (I didn't want to have to worry about introducing any security concerns there by offloading that work to plugins).

The objective of all this is to allow users to write their own plugins without needing to modify rkt. If a user wants to fetch images using some specialized s3 protocol, they could create a fetching plugin and it would just work, instead of needing to make a feature request from us.

I could see it possibly making more sense to only allow fetching ACIs via plugins, and keeping the docker:// schema logic in the stage0, as it involving image conversion makes it a little different than the other schemas, but at this point I think I like the separation of also pulling that out into a plugin.

@sgotti
Copy link
Contributor
sgotti commented Jul 18, 2016

intend for this PR to have the stage0 binary do AppC discovery and hand the resulting URI off to a plugin after doing the template substitution, and the stage0 itself would fetch the public key over https (I didn't want to have to worry about introducing any security concerns there by offloading that work to plugins).

Ok, Just to clarify my concepts (but I may be wrong 😄) I think of distribution as the whole process, starting from an input string, to fetch the required image. In this case since the discovery will be done by the stage0 the plugin is just doing the transport logic (http, s3, bittorrent, ipfs). So I'm going to call them transport plugin.

I could see it possibly making more sense to only allow fetching ACIs via plugins, and keeping the docker:// schema logic in the stage0, as it involving image conversion makes it a little different than the other schemas, but at this point I think I like the separation of also pulling that out into a plugin.

Seems Good. As an example, when rkt will support native OCI images the 'docker://' distribution should check the docker registry/manifest version and choose to use docker2aci for v1 and directly handle oci for v2, oci images fetched from a docker registry (the docker:// will mean docker registry distribution). Additionally when natively fetching the OCI blobs they aren't just one file but multiple blobs with different mediaType so I'm not sure how a full distribution plugin could handle this, instead this logic could use an http transport plugin.

@cgonyeo cgonyeo force-pushed the fetching-plugins branch 2 times, most recently from 8e329e4 to e5a18a8 Compare July 21, 2016 17:51
@cgonyeo
Copy link
Member Author
cgonyeo commented Jul 21, 2016

Much closer now. I believe all the relevant tests should pass, but I have yet to tweak autotools to build the plugins.

Also after talking to @sgotti I think I'd like to hold off on merging this until the new store work gets further along, as it's not clear to me how that will impact this.

@cgonyeo
Copy link
Member Author
cgonyeo commented Jul 21, 2016

Still, if anyone has further feedback or would be willing to give this another review pass, that would be awesome.

Adds support for having images fetched via a plugin. Plugins take the
form of a binary on the user's path named "rkt-fetcher-%s", with the %s
taking the place of the schema, so for example fetching
`docker://alpine` is redirected to the `rkt-fetcher-docker` binary.

When the plugin is started it has a JSON configuration written to it on
stdin, its stderr is forwarded on to the user, and its expected to write
result json to stdout. The configuration contains paths to write the ACI
and ASC files to, which rkt will then verify (unless the insecure image
option is specified).

This commit also changes the behavior of the `--insecure-options=http`
flag. It used to only impact the AppC discovery phase, and
post-discovery images could be fetched over http regardless of the flag.
Now rkt will refuse to fetch an image over http unless the flag is
provided.
@jonboulle
Copy link
Contributor

From an out-of-band update: this should be receiving more attention and an update around the end of this week.

@cgonyeo
67E6 Copy link
Member Author
cgonyeo commented Aug 22, 2016

I've been too busy to give this much attention, and am busy this week with LinuxCon. I was going to focus on this next week.

Unless you mean someone else got impatient and is going to pick this up for me.

On Aug 22, 2016, at 08:14, Jonathan Boulle notifications@github.com wrote:

From an out-of-band update: this should be receiving more attention and an update around the end of this week.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@jonboulle
Copy link
Contributor

Nope, just capturing that you'll be back to it soon ;-)

On 22 August 2016 at 16:47, Derek Gonyeo notifications@github.com wrote:

I've been too busy to give this much attention, and am busy this week with
LinuxCon. I was going to focus on this next week.

Unless you mean someone else got impatient and is going to pick this up
for me.

On Aug 22, 2016, at 08:14, Jonathan Boulle notifications@github.com
wrote:

From an out-of-band update: this should be receiving more attention and
an update around the end of this week.


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#2830 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACewN8LusbefONB0IqkN749FfRf-o8n0ks5qibZkgaJpZM4I8SJs
.

@cgonyeo
Copy link
Member Author
cgonyeo commented Apr 6, 2018

This is stale and has a ton of conflicts. Closing.

@cgonyeo cgonyeo closed this Apr 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0