Thanks to visit codestin.com
Credit goes to github.com

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

Conversation

@squall0gd
Copy link
Contributor

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod

squall0gd added a commit to intelsdi-x/rkt that referenced this pull request Feb 25, 2016
Cherry pick for tests purposses. It should be merged in
pull request rkt#2222

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
squall0gd added a commit to intelsdi-x/rkt that referenced this pull request Feb 25, 2016
Cherry pick for tests purposses. It should be merged in
pull request rkt#2222

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
squall0gd added a commit to intelsdi-x/rkt that referenced this pull request Feb 26, 2016
Cherry pick for tests purposses. It should be merged in
pull request rkt#2222

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
@iaguis iaguis added this to the v1.2.0 milestone Mar 4, 2016
@jonboulle
Copy link
Contributor

is this ready for rereview?

@squall0gd
Copy link
Contributor Author

I haven't replied on @woodbor review yet. It's on my roadmap in next 6 work days, so I will refactor this code tomorrow

squall0gd added a commit to intelsdi-x/rkt that referenced this pull request Mar 18, 2016
Cherry pick for tests purposses. It should be merged in
pull request rkt#2222

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
@iaguis iaguis modified the milestones: v1.3.0, v1.2.0 Mar 18, 2016
squall0gd added a commit to intelsdi-x/rkt that referenced this pull request Mar 21, 2016
Cherry pick for tests purposses. It should be merged in
pull request rkt#2222

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
squall0gd added a commit to intelsdi-x/rkt that referenced this pull request Mar 21, 2016
Cherry pick for tests purposses. It should be merged in
pull request rkt#2222

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
squall0gd added a commit to intelsdi-x/rkt that referenced this pull request Mar 21, 2016
Cherry pick for tests purposses. It should be merged in
pull request rkt#2222

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
squall0gd added a commit to intelsdi-x/rkt that referenced this pull request Mar 21, 2016
Cherry pick for tests purposses. It should be merged in
pull request rkt#2222

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
@squall0gd squall0gd force-pushed the mstachow/rkt_add_default_capabilities branch 2 times, most recently from 0a325f8 to ac2102c Compare March 22, 2016 08:11
@squall0gd
Copy link
Contributor Author

Review request

var caps []types.LinuxCapability

for _, isolator := range app.Isolators {
switch capSet := isolator.Value().(type) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if there is only one case, if could be better solution than switch- a few lines less

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Go compiler requires switch:
build-rkt-1.0.0+git/gopath/src/github.com/coreos/rkt/stage1/init/kvm/resources.go:77: use of .(type) outside type switch

Copy link
Collaborator

Choose a reason for hiding this comment

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

Just one line less.

if capSet, ok := isolator.Value().(types.LinuxCapabilitiesSet); ok {
    ...
}

@borqosky
Copy link
Contributor

LGTM

@squall0gd squall0gd force-pushed the mstachow/rkt_add_default_capabilities branch from ac2102c to 169f391 Compare March 23, 2016 08:20
squall0gd added a commit to intelsdi-x/rkt that referenced this pull request Mar 24, 2016
Cherry pick for tests purposses. It should be merged in
pull request rkt#2222

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
@squall0gd
Copy link
Contributor Author

Review request


if flavor == "kvm" {
capabilities := kvm.GetAppCapabilities(app)
capabilities = append(capabilities, stdCapabilities...)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't actually understand this. This is the list of capabilities that we're applying to a particular app within the pod right? Why would this be any different for the KVM case than for the non-KVM case? And where does nspawn come into it once we're inside the pod?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nspawn is starting with pre-defined capabilities (as an isolation from host). Kvm is starting whole VM with full systemd (which has got every capability and You cannot(and really, You won't ;)) change them). This patch delivers standard capabilities for applications inside pod (so Your pod environment has got every single capability, but Your application don't).

Copy link
Contributor

Choose a reason for hiding this comment

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

So are you just trying to preserve parity with the fact that a process launched by a systemd-launched-by-systemd-nspawn will have different default capabilities to one launched by systemd-launched-by-lkvm?

If so, wouldn't the better approach be to change the systemd config for the lkvm variant? e.g. https://www.freedesktop.org/software/systemd/man/systemd-system.conf.html#CapabilityBoundingSet=

Copy link
Member

Choose a reason for hiding this comment

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

If we use the option systemd-system.conf#CapabilityBoundingSet=, it needs to contain the union of stdCapabilities with the union of caps of each app, because systemd-pid1 would only be able to give the caps from its CapabilityBoundingSet, not more.

rkt does that for systemd-nspawn: it adds --capbility= for each app, as it iterates over the apps and their caps:
https://github.com/coreos/rkt/blob/master/stage1/init/common/pod.go#L706

But I don't know if we need to keep parity between the nspawn and lkvm flavors?

Copy link
Member

Choose a reason for hiding this comment

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

If we want to have the exact same behavior as the nspawn flavor, we should add these capabilities (standard plus the apps') to systemd-system.conf#CapabilityBoundingSet=

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well this configuration file is great, but AFAIK each app inside pod could has got own capabilities configuration, so setting one common file for every app won't work.

Copy link
Contributor

Choose a reason for hiding this comment

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

@mstachowski Right, but what we're talking about here is the outer bounding set of the pod environment. Then within that, we apply per-app capabilities to each app.

but... @iaguis @alban do we not actually do this part today?!?

Copy link
Member

Choose a reason for hiding this comment

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

There's no "outer bounding set", if apps request capabilities we just give them to them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Per OOB it seems a bug that we don't set per-app ones - can someone chase that up?

Copy link
Member

Choose a reason for hiding this comment

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

comment captured in #2348

squall0gd added a commit to intelsdi-x/rkt that referenced this pull request Apr 6, 2016
Cherry pick for tests purposses. It should be merged in
pull request rkt#2222

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
squall0gd added a commit to intelsdi-x/rkt that referenced this pull request Apr 6, 2016
Cherry pick for tests purposses. It should be merged in
pull request rkt#2222

By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
@jonboulle
Copy link
Contributor

Is this ready for review again?

@squall0gd squall0gd force-pushed the mstachow/rkt_add_default_capabilities branch 2 times, most recently from b181b88 to 3bc66c1 Compare April 13, 2016 15:10
@squall0gd
Copy link
Contributor Author

@jonboulle yes, it is

"HOME": "/root",
}

// List of default capabilities inside systemd-nspawn pod is available
Copy link
Member

Choose a reason for hiding this comment

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

The list of default...

@iaguis
Copy link
Member

iaguis commented Apr 14, 2016

Some nits but after those LGTM

@squall0gd squall0gd force-pushed the mstachow/rkt_add_default_capabilities branch from 3bc66c1 to ee2ea7a Compare April 14, 2016 11:26
@squall0gd
Copy link
Contributor Author

@iaguis done

// GetAppCapabilities is a filter which returns a string slice of valid Linux capabilities
// It requires list of available isolators
func GetAppCapabilities(isolators types.Isolators) []string {

Copy link
Member

Choose a reason for hiding this comment

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

Can you remove this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure :)

@squall0gd squall0gd force-pushed the mstachow/rkt_add_default_capabilities branch from ee2ea7a to d7e2254 Compare April 14, 2016 12:09
return caps
}

// parseLinuxCapabilitySetToString parses a LinuxCapabilitiesSet into string slice
Copy link
Member

Choose a reason for hiding this comment

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

Last thing, outdated docstring :D

Copy link
Member

Choose a reason for hiding this comment

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

The test passed before updating the docstring so we can merge it right-away once it's updated.

@iaguis
Copy link
Member

iaguis commented Apr 14, 2016

LGTM

@squall0gd squall0gd force-pushed the mstachow/rkt_add_default_capabilities branch from d7e2254 to d66fa61 Compare April 14, 2016 12:39
@iaguis iaguis merged commit 94b6283 into rkt:master Apr 14, 2016
By default kvm flavor has got enabled every capability inside pod.
This is normal systemd behavior, when its running as a init process
inside VM. Coreos pod is started by systemd-nspawn, which apply some
initial capabilities by default.

This patch add support for restricted set of capabilities inside rkt-kvm
pod
@squall0gd squall0gd deleted the mstachow/rkt_add_default_capabilities branch April 14, 2016 12:41
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