Skip to content
This repository was archived by the owner on Feb 24, 2020. It is now read-only.

*: add new rkt fly command#1072

Closed
jonboulle wants to merge 1 commit intorkt:masterfrom
jonboulle:fly
Closed

*: add new rkt fly command#1072
jonboulle wants to merge 1 commit intorkt:masterfrom
jonboulle:fly

Conversation

@jonboulle
Copy link
Contributor

This is a dummy/strawman prototype for a new command, rkt fly, which
executes a single application image with no constraints or pod.

This still performs an exec() so retains the basic rkt process model
(i.e. any constraints applied to the rkt process are inherited), but has
no further lifecycle tracking beyond the execution stage.

Essentially, it just:

  • extracts an application image
  • chroots into the image
  • execs the app image's command (and any additional args)

Follows the same syntax as rkt run

Several TODOs/outstanding questions inline.

This is a dummy/strawman prototype for a new command, `rkt fly`, which
executes a single application image with no constraints or pod.

This still performs an exec() so retains the basic rkt process model
(i.e. any constraints applied to the rkt process are inherited), but has
no further lifecycle tracking beyond the execution stage.

Essentially, it just:
- extracts an application image
- chroots into the image
- execs the app image's command (and any additional args)

Follows the same syntax as `rkt run`

Several TODOs/outstanding questions inline.
Copy link
Contributor

Choose a reason for hiding this comment

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

where's rktApps coming from? if it's a global var somewhere, can it be refactored to make it local somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Almost certainly, I don't like the global var, was just cribbing from rkt
run

On Thu, Jun 18, 2015 at 3:31 PM, Eugene Yakubovich <[email protected]

wrote:

In rkt/fly.go
#1072 (comment):

  •   Long:  `IMAGE should be a string referencing an image; either a hash, local file on disk, or URL.`,
    
  •   Run:   runWrapper(runFly),
    
  • }
    +)

+func init() {

  • cmdRkt.AddCommand(cmdFly)
  • // Disable interspersed flags to stop parsing after the first non flag
  • // argument. All the subsequent parsing will be done by parseApps.
  • // This is needed to correctly handle image args
  • cmdFly.Flags().SetInterspersed(false)
    +}

+func runFly(cmd *cobra.Command, args []string) (exit int) {

  • err := parseApps(&rktApps, args, cmd.Flags(), true)

where's rktApps coming from? if it's a global var somewhere, can it be
refactored to make it local somehow?


Reply to this email directly or view it on GitHub
https://github.com/coreos/rkt/pull/1072/files#r32785941.

@eyakubovich
Copy link
Contributor

runFly is a little big -- it would be good to split it out a bit.

@jonboulle
Copy link
Contributor Author

Agreed - should have mentioned I'm curious on more general feedback about
the feature/approach

On Thu, Jun 18, 2015 at 3:39 PM, Eugene Yakubovich <[email protected]

wrote:

runFly is a little big -- it would be good to split it out a bit.


Reply to this email directly or view it on GitHub
#1072 (comment).

@eyakubovich
Copy link
Contributor

We still need to gc these runs somehow, correct? How will it interact with rkt gc?

@eyakubovich
Copy link
Contributor

These exit when the app exists so there's no need for the mark phase of gc. But it still needs to be sweeped.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the case that execpath is a symlink, this check will fail. Maybe change order to chroot first, then stat execargs[0]

@jonboulle jonboulle added this to the v0.8.0 milestone Jul 2, 2015
@jonboulle
Copy link
Contributor Author

@tixxdz could you please take this one over? (the feature, that is - this PR was largely a proof of concept so no need to keep this commit if it's not worthwhile) - relates to #1046 obviously

@tixxdz
Copy link
Contributor

tixxdz commented Jul 8, 2015

@jonboulle yes I noticed this issue, ok noted for the commit. I will give it time when I'm blocked with the kernel uidshift. OK thanks!

@philips philips modified the milestones: v0.9.0, v0.8.0 Jul 22, 2015
@stevenschlansker
Copy link

This feature looks extremely interesting for integration with Mesos and like systems -- it would allow us to use the Mesos isolator with Rocket provisioning. Looking forward to seeing this!

@f0
Copy link

f0 commented Sep 4, 2015

this would be helpful for things like monitoring agents (e.g zabbix) who support custom user parameters, so is there a plan when this comes into rkt?

@tixxdz
Copy link
Contributor

tixxdz commented Sep 8, 2015

@f0 yes we are working on this one

@jonboulle
Copy link
Contributor Author

@tixxdz do you want to put up your latest branch in another PR?

@ppalucki
Copy link
Contributor

@jonboulle what is rationale behind this ? is performance an only incentive here or there other features I don't see ?

If we eliminate nspwan+systemd we lose isolation(namespaces), manageability(supervising), other helpers(diagexec/volumes/network modes) - I can see value in simplicity (distribution/chroot+exec), but if in future we will add some missing features (like namespaces/bind mounting) we will end up with re implementing nspwan in go (as proposed here #1318).

What I expect as end user is clear distinction between these two commands:

  • rkt fly - "Run a single application image with no pod or isolation" (one app ?)
  • rkt run - "Run image~~(s)~~ in a pod in rkt" - (many apps ?)

why not just create another flavor called "just chroot/exec" as stage1 ?

@tixxdz
Copy link
Contributor

tixxdz commented Sep 15, 2015

@jonboulle ok will push it.

@ppalucki for the rationale please refer to #1046

@ppalucki "why not just create another flavor called "just chroot/exec" as stage1 ?" well the intended behaviour was to separate the traditional "run" from the "fly" so another flavor is perhaps not the best solution here. With rkt fly the pid and possibly other namespaces will be shared with the host. And yes if rkt fly does not have a clear scope we may reimplement things and nspawn in go...

Goal

Execute a single application image with no constraints or pod. No init or systemd, so we can share the pid, uts and ipc namespaces easily with the host.

@jonboulle @ppalucki @philips yes I also think that we should continue with nspawn+systemd where it's possible. nspawn supports --share-system switch to share other namespaces. In this case containers will not be registered in machined, so they will have basic rkt listing, and I think we should not care about gc'ing them? ping @eyakubovich

So, this can be implemented using two solutions:

1) extract+exec

Extracts an application image, chroots into the image and execs the app image's command. Additionally we may create new mount and network namespaces, users may need this, please see these comments:
#1046 (comment)
#1046 (comment)

Only a new mount and network namespaces, it will allow us to cope with solution 2) nspawn and we continue to share the pid namespace. I guess it does not hurt.

2) nspawn

Use nspawn --share-system, I think this is the best solution. Why ? it will allow us to support the first use case easily (share the pid namespace) + support user namespaces where an application or a monitoring app will run with a different uid. It will have access to the pid namespace, monitor apps without being affected by other users or any resources limits. "rkt fly --private-users" to run as a different user.

Why "--private-users" only with nspawn ? well nspawn does some other chown, mkdir uid shifts that we do not want to implement in rkt.

Thoughts ?

@tixxdz tixxdz mentioned this pull request Sep 16, 2015
@tixxdz
Copy link
Contributor

tixxdz commented Sep 16, 2015

@jonboulle the PR that implements solution 1) extract+exec without creating a new mount namespace is here #1416

I believe the only missing part for this one is perhaps to replace the chroot with a new mount namespace, yes waiting for more feedback and use cases for it.

Finally in case we add a new mount namespace perhaps we will also need to make the root tree shared and the container one slave so mounts are propagated into the container as it's done in nspawn by default! #1046 (comment)

@jonboulle
Copy link
Contributor Author

Closing in favour of #1416

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.

8 participants