8000 rkt: experimental support for pod sandbox by s-urbaniak · Pull Request #3318 · 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.

rkt: experimental support for pod sandbox #3318

Merged
merged 35 commits into from
Nov 7, 2016
Merged

Conversation

s-urbaniak
Copy link
Contributor
@s-urbaniak s-urbaniak commented Oct 26, 2016

This PR merge the cri branch back into master, introducing an experimental app subcommands. This is the second sync-point for CRI tasks (the first one was #3218).

This introduces the concept of a "pod sandbox", i.e. a mutable pod where applications can be added/started/stopped/removed while the pod is already running.

This feature and the corresponding v5 stage interface are currently marked as experimental, and will undergo a stabilization process in the next release cycles. This also applies at the CLI level, where the app subcommand is gated by default behind an environment flag.

Closes: #3135
Closes: #3136
Closes: #3137
Closes: #3153

Yifan Gu and others added 25 commits October 25, 2016 12:56
Since 'rkt stop' is idempotent, 'rkt stop' on an already stopped
pod should not return error.
When the pod is stopped, don't call app-add/app-rm entrypoint
because there is not much we can/need to do when the whole pod
is stopped.
Also add annotations, startedAt in the json definition 
8000
of the pod.
This enables injecting user-defined pod level labels and annotations.
This documents and autodetects stage1 mutable cabability detection. It
is needed for stage1 images which do not support mutable operations, and
retains backwards compatibility with old stage1 images.
… flags.

Add these flags for 'rkt app add', 'rkt run', 'rkt prepare'.
It will be used in more places.
If we try to stop an app that doesn't have a service file (either
because it was not started or because the starting failed) we should
give an appropriate error message.

Also, since `app rm` calls the stop entrypoint, we should identify this
error and continue removing the app.
Also removed unneccessary flag conflict checks for --pod-manifest
v.s. other flags (--name, --environment, etc) because they are already
taken care of since they all need to follow an image.
Currently we set up the app's service during app-start which is not the
right place.

This implements the proper logic to set up systemd service files, as
well as any remounts of cgroups during app-add.
This removes some duplicated code in AddApp which was previously copied
over.
This introduces a dedicated RmConfig synchronous to all the other *App
methods.
This specifies the synchronization of pod mutation operations using a
file lock.
@jonboulle
Copy link
Contributor

+1 on moving back to master, perhaps with app subcommands hidden behind a
$RKT_APPS_EXPERIMENTAL environtment var as suggested elsewhere

On 26 October 2016 at 14:54, Sergiusz Urbaniak notifications@github.com
wrote:

This PR cherry-picks the commits from the cri branch back into master,
leaving out the app subcommands. This is the second sync-point (the first
one was introduced in #3218 #3218).

The diff to the current cri branch is as follows:

$ git diff --stat crisync..cri
rkt/app.go | 28 ++++++++++++
rkt/app_add.go | 146 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rkt/app_exec.go | 37 ++++++++++++++++
rkt/app_list.go | 65 +++++++++++++++++++++++++++
rkt/app_rm.go | 93 ++++++++++++++++++++++++++++++++++++++
rkt/app_sandbox.go | 321 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
rkt/app_start.go | 94 +++++++++++++++++++++++++++++++++++++++
rkt/app_status.go | 134 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
rkt/app_stop.go | 99 +++++++++++++++++++++++++++++++++++++++++
9 files changed, 1017 insertions(+)

Given the current development, and a remerged appc 0.8.8 I am wondering if
we should move back to the "develop-against-master" mode. My intuition
tells me we should wait until we have first e2e-results ready from the
rktlet. @lucab https://github.com/lucab @euank
https://github.com/euank @yifan-gu https://github.com/yifan-gu

thoughts?

You can view, comment on, or merge this pull request online at:

#3318
Commit Summary

  • stop: Don't treat 'rkt stop already-stopped-pods' as errors.
  • Allow rkt app rm on a stopped pod.
  • rkt status: Add '--format=json' flag to print json format for pods.
  • cri: Prepare isolators
  • stage1: mount cgroup knobs RW for new app
  • stage1: add mount/umount in all flavors
  • cgroup: resolve merge conflict
  • CRI: Allow the pod sandbox to accept port f 8000 orwards
  • run: allow port forwards from a specific IP
  • kvm/init: remove condition for kvm mutable pods
  • cri: don't remount cgroup knobs RW with cgroup2
  • CRI: Add '--annotation' and '--label' flag for 'rkt app sandbox'.
  • CRI: Add '--name', '--annotation', '--label', '--environment' for
    'rkt app add'.
  • cri/sandbox: autodect mutable stage1 capabilities
  • CRI: Add '--working-dir', '--supplementary-gids',
    '--readonly-rootfs' flags.
  • common,tests: refactor GetExitStatus
  • stage0,stage1: handle exit status from stop entrypoint
  • CRI: add oom_score_adj isolator
  • run/repare: Support mutating the app for 'rkt run/prepare' as well.
  • Documentation: Update docs for rkt run/prepare.
  • app-start: set up unit files/cgroups during app-add
  • app: remove code duplication for preparing the stage1 image
  • app-rm: introduce RmConfig
  • Documentation: specify app subcommands synchronization
  • app: implement synchronization of pod mutation operations
  • glide: pull in kr/pretty for unit tests
  • CRI: Support volume creation at app add time
  • CRI: pick up appc annotation rename
  • CRI: add cpu-shares isolator
  • Merge remote-tracking branch 'origin/master' into crisync

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#3318, or mute the thread
https://github.com/notifications/unsubscribe-auth/ACewNxQdTshaPWqDgP6QtCarbSoQBHURks5q302OgaJpZM4KhIiQ
.

@s-urbaniak
Copy link
Contributor Author

CI failure is a known flake in TestNetDefaultRestrictedConnectivity.

@lucab lucab added this to the v1.19.0 milestone Oct 27, 2016
squeed and others added 4 commits November 1, 2016 08:36
Squashed commit of the following:

commit 0b348ab71a2b3a5a576a1129458487fb957f0e43
Merge: ce991fc 2ef0885
Author: Casey Callendrello <c1@caseyc.net>
Date:   Fri Oct 7 15:08:00 2016 +0200

    Merge remote-tracking branch 'origin/cri' into cri-volumes

commit ce991fcf1bbce5fb22b519e88eb0f0cfd6dbaca6
Author: Casey Callendrello <c1@caseyc.net>
Date:   Tue Oct 4 20:24:59 2016 +0200

    WIP: support app volumes

commit dca86e7
Merge: 081300c b9ddcc6
Author: Casey Callendrello <c1@caseyc.net>
Date:   Tue Oct 4 12:23:06 2016 +0200

    Merge remote-tracking branch 'origin/cri' into cri-volumes

commit 081300c
Author: Alban Crequy <alban@kinvolk.io>
Date:   Thu Sep 22 12:45:32 2016 +0200

    cri: mount volumes in the app

    This requires systemd with the following fix:
    systemd/systemd#4152
@s-urbaniak
Copy link
Contributor Author

Regarding hiding those app subcommands, cobra already has a simple Hidden flag as per https://godoc.org/github.com/spf13/cobra#Command. This lets those command not appear in any of the usage/help messages.

Hmm ... I think this is "good enough" for hiding them, or do we additionally want an activation env var? @lucab

@lucab
Copy link
Member
lucab commented Nov 1, 2016

@s-urbaniak I'd suggest to mark the whole app subcommand as hidden and behind an activation env flag until we are comfortably happy with the UX and we have some tests around it.

This also introduces a common.IsExperimentEnabled function for querying
experiments in rkt.
@jonboulle
Copy link
Contributor

+1

On 1 November 2016 at 09:31, Luca Bruno notifications@github.com wrote:

@s-urbaniak https://github.com/s-urbaniak I'd suggest to mark the whole
app subcommand as hidden and behind an activation env flag until we are
comfortably happy with the UX and we have some tests around it.


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

Copy link
Member
@lucab lucab left a comment

Choose a reason for hiding this comment

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

Several comments, but no big blockers.


#### Arguments

`start $OPTIONS UUID APPNAME ENTERENTRYPOINT PID`
Copy link
Member

Choose a reason for hiding this comment

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

$OPTIONS should be documented (they are mostly enterexec related). Moreover, there is a TODO entry to make the remaining flag named one (instead of positional arguments).


If the annotation is not present, `false` is assumed.

### Versioning
Copy link
Member

Choose a reason for hiding this comment

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

Version interface should also be bumped once we agree on entrypoints interface.

@@ -102,6 +102,13 @@ func PodManifestPath(root string) string {
return filepath.Join(root, "pod")
}

// PodManifestLockPath returns the path in root to the Pod Manifest lock file.
// This must be different from the PodManifestPath since mutations on the pod manifest file
Copy link
Member

Choose a reason for hiding this comment

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

What is "this" here? Are we talking about the fact that the lockfile must be a new specific one and we can't re-use one of the other lock types we have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Member

Choose a reason for hiding this comment

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

Ok, I guessed so but the comment may be a bit more explicit as casual readers won't have the whole context in mind.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agreed, as a self-note, I should add more rationale in this section of the pod-lifecycle.md https://github.com/coreos/rkt/pull/3318/files#diff-7f4a1c7974386fb54394c2fd1f91e9d9R44 document

@@ -95,11 +96,6 @@ func newApp(ra *schema.RuntimeApp, podManifest *schema.PodManifest, pod *pkgPod.
})
}

// Generate annotations.
for _, anno := range ra.Annotations {
app.Annotations[anno.Name.String()] = anno.Value
Copy link
Member

Choose a reason for hiding this comment

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

@squeed aren't we loosing app-level annotations here (not speaking about user ones, but the ones coming with the image itself)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The change was introduced in 348facd, where App.Annotations was renamed to App.CRIAnnotations, and later to App.UserAnnotations.

We are setting them directly without iteration now here https://github.com/s-urbaniak/rkt/blob/crisync/lib/app.go#L64

Copy link
Member

Choose a reason for hiding this comment

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

Ok, thanks for digging through history. I think we should double-check this later and verify that we are not messing between internal annotations and user annotations at any point, but from a quick glance this should be fine.

@@ -139,7 +135,7 @@ func appState(app *App, pod *pkgPod.Pod) error {
}

app.State = AppStateCreated
createdAt := fi.ModTime().UnixNano()
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused by this change, as comments in lib/types explictly say "nanoseconds since epoch" and CRI seems to agree on that. @yifan-gu do you remember what's going on here?

Copy link
Contributor

Choose a reason for hiding this comment

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

@lucab Good catch, the change happens before CRI decides on using nano seconds.
We need to change it back to unix nano.

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
Contributor Author

Choose a reason for hiding this comment

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

fixed in 2f5de7f

cmdAppStart = &cobra.Command{
Use: "start UUID --app=NAME",
Short: "Start an app in a pod",
Long: `Start appz!`,
Copy link
Member

Choose a reason for hiding this comment

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

"appz"

Copy link
Member

Choose a reason for hiding this comment

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

@iaguis 🤘

return 1
}

if flagAppName == "" {
Copy link
Member
@lucab lucab Nov 2, 2016

Choose a reason for hiding this comment

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

Should app-start implement the "if there is only one app, use that" semantic that we have in other places (like enter)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, that sounds like a nice addition. If we intend the app subcommands to be first-class for end-users, I'm all for this feature. For the current use-case of machine-only usage (rktlet) I'd say it is even good to err out.

return 1
}

// TODO(yifan): Print yamls.
Copy link
Member

Choose a reason for hiding this comment

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

I'd say is a non-TODO, for the moment, unless some k8s consumer needs it.

cmdAppStop = &cobra.Command{
Use: "stop UUID --app=NAME",
Short: "Stop an app in a pod",
Long: `Stop appz!`,
Copy link
Member

Choose a reason for hiding this comment

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

"appz"

_, appStartOk := s1m.Annotations.Get(appStartEntrypoint)
_, appStopOk := s1m.Annotations.Get(appStopEntrypoint)

return appRmOk && appStartOk && appStopOk, nil
Copy link
Member

Choose a reason for hiding this comment

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

This seems to be lacking a check on "app/add" entrypoint.

This reintroduces nanosecond units for reporting the app state.
@lucab lucab changed the title cri: branch sync rkt: experimental support for pod sandbox Nov 3, 2016
@lucab
Copy link
Member
lucab commented Nov 3, 2016

LGTM.

There are clearly still a lot of comments and TODO to be addressed, but new features are gated behind an experimental flag and we didn't introduce any regression. So I think we can move forward here by landing this and addressing concerns in followup PRs.

@s-urbaniak @jonboulle @squeed can you have a review pass on this and check if you spot any blockers?

@lucab
Copy link
Member
lucab commented Nov 7, 2016

There was some concern about the experimental interface changes not being documented well enough, so I put together s-urbaniak#4 to start polishing and documenting the app and attach entrypoints, PTAL. Once that PR is merged, anything else blocking this?

lucab and others added 2 commits November 7, 2016 09:46
This commit introduces and unifies "crossing entrypoints"
for app and attach commands, defining an experimental
interface v5 (yet to be finalized).
stage1: document experimental interface v5
@s-urbaniak
3D11 Copy link
Contributor Author

LGTM

@squeed
Copy link
Contributor
squeed commented Nov 7, 2016

👍

@lucab
Copy link
Member
lucab commented Nov 7, 2016

All green, merging.

@lucab lucab merged commit 2c53c16 into rkt:master Nov 7, 2016
@s-urbaniak s-urbaniak mentioned this pull request Nov 7, 2016
@s-urbaniak s-urbaniak deleted the crisync branch November 7, 2016 12:58
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
0