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

Pod Security Option support and Infra Inheritance changes #12208

Merged
merged 1 commit into from
Jan 5, 2022

Conversation

cdoern
Copy link
Contributor

@cdoern cdoern commented Nov 8, 2021

What this PR does / why we need it:

Added support for pod security options. These are applied to infra and passed down to the
containers as added (unless overridden).

Modified the inheritance process from infra, creating a new function Inherit() which reads the config, and marshals the compatible options into an intermediate struct InfraInherit
This is then unmarshaled into a container config and all of this is added to the CtrCreateOptions. Removes the need (mostly) for special additions which complicate the Container_create
code and pod creation.

Which issue(s) this PR fixes:

resolves #12173

Signed-off-by: cdoern [email protected]

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 9, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 9, 2021
libpod/container_config.go Outdated Show resolved Hide resolved
@cdoern cdoern marked this pull request as draft November 9, 2021 19:51
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 9, 2021
@cdoern cdoern force-pushed the podSecurityOpt branch 2 times, most recently from bbdf94a to 52c829e Compare November 12, 2021 14:05
@cdoern cdoern changed the title Pod Security Option support Pod Security Option support and Infra Inheritance changes Nov 12, 2021
@cdoern cdoern force-pushed the podSecurityOpt branch 4 times, most recently from 14154c6 to 1b1866d Compare November 17, 2021 03:43
@cdoern
Copy link
Contributor Author

cdoern commented Nov 17, 2021

@mheon any idea why the play kube seccomp tests are failing? looks like something that is not supposed to be permitted is being allowed. Could this be something that doesn't apply now since security options are allowed?

@cdoern cdoern force-pushed the podSecurityOpt branch 2 times, most recently from 0e49ee8 to 2215e29 Compare November 17, 2021 15:48
@mheon
Copy link
Member

mheon commented Nov 17, 2021

Can you link a failure? Gitvalidation is failing now, so I can't see the failures

@cdoern
Copy link
Contributor Author

cdoern commented Nov 17, 2021

@mheon here is a link: https://storage.googleapis.com/cirrus-ci-6707778565701632-fcae48/artifacts/containers/podman/6536676483792896/html/int-podman-fedora-33-rootless-host.log.html

I am pushing now to fix the validation, trying something new to see if that fixes the seccomp issues

EDIT: seeing same failures in most recent test runs.

@mheon
Copy link
Member

mheon commented Nov 17, 2021

It's complaining we don't have a private mount namespace?

Error is coming out of crun, definitely, but I think we're passing an invalid config - I don't see how Podman can create a container without a private mount namespace though.

libpod/container_inspect.go Outdated Show resolved Hide resolved
@mheon
Copy link
Member

mheon commented Nov 17, 2021

I think you're mangling the spec such that we no longer have a mount namespace, but I'm not sure how that's happening. Maybe we're trying to inherit the pod's mount namespace?

@cdoern cdoern force-pushed the podSecurityOpt branch 4 times, most recently from 6d24cd2 to 5cd899b Compare November 18, 2021 17:28
@cdoern
Copy link
Contributor Author

cdoern commented Nov 22, 2021

@containers/podman-maintainers PTAL I think this is good to go

@rhatdan
Copy link
Member

rhatdan commented Nov 23, 2021

While you are in fixing the SELinux check could you add a --security-opt seccomp=unconfined check, also.

@cdoern
Copy link
Contributor Author

cdoern commented Nov 23, 2021

While you are in fixing the SELinux check could you add a --security-opt seccomp=unconfined check, also.

the seccomp=unconfined is in the first test, I do it simultaneously with label=type:spc_t @rhatdan

@cdoern cdoern force-pushed the podSecurityOpt branch 2 times, most recently from 63b0f4a to 6c31371 Compare December 2, 2021 19:34
@cdoern
Copy link
Contributor Author

cdoern commented Dec 3, 2021

@containers/podman-maintainers PTAL

@rhatdan
Copy link
Member

rhatdan commented Dec 3, 2021

LGTM
/approve
@mheon PTAL

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 3, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cdoern, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 3, 2021
@cdoern
Copy link
Contributor Author

cdoern commented Dec 8, 2021

@containers/podman-maintainers PTAL

}
}
if compatibleOptions != nil {
options = append(options, libpod.WithInfraConfig(*compatibleOptions))
Copy link
Member

Choose a reason for hiding this comment

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

Instead of doing this, can we return the InfraInherit and do the unmarshal over the spec within pkg/specgen/generate/oci.go as we create the spec itself? Localizes the changes to pkg/spec which seems simpler, though you will have to pass the InfraInherit around a bit

Copy link
Member

Choose a reason for hiding this comment

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

Actually, it looks like you're passing it into SpecGenToOCI below, so it probably isn't even necessary to change how it's passed around

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so is this good as is? theSpecGenToOCI bit is just for config elements that get overwritten. This works for like 90% of options.

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 prefer to remove the option and just set the values in the spec in SpecGenToOCI - most options alter more than just the spec, if we're just changing the spec we can do it during spec generation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I am trying to have this just be done in the spec, but for some reason all of the tests are failing even though the runtime spec has the proper values. I am going to investigate a bit,

Copy link
Member

Choose a reason for hiding this comment

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

Huh...

Can you verify if it has the correct values after it gets put into the DB? I wonder if some other part of container creation is overwriting it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok @mheon I did some digging, I do not think the issue is with the runtime spec, I think the container config needs to be modified as well. some options like volumes are not explicitly in the spec and will be dropped.

Instead of doing options, I could make a path that opts to do something like a checkpoint where we load the config from infra (or at least what matches). Could help delineate this from regular create options

Copy link
Member

Choose a reason for hiding this comment

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

OK, if we need config changes, options are fine - I'd just prefer to keep things split (the options modify the container config, while state modification is done without options in SpecGen). Doesn't need to be more than one option, either - the old approach of a single option to grab all relevant config blobs from the infra works fine in my book.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok @mheon, then is this PR good as is? I never pushed the new changes.

@rhatdan
Copy link
Member

rhatdan commented Dec 14, 2021

@cdoern Back in your hands.

@cdoern
Copy link
Contributor Author

cdoern commented Dec 15, 2021

@cdoern Back in your hands.

sorry I will circle back to this later tonight.

@cdoern
Copy link
Contributor Author

cdoern commented Dec 21, 2021

@containers/podman-maintainers PTAL

@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 23, 2021
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 27, 2021
Added support for pod security options. These are applied to infra and passed down to the
containers as added (unless overridden).

Modified the inheritance process from infra, creating a new function Inherit() which reads the config, and marshals the compatible options into an intermediate struct `InfraInherit`
This is then unmarshaled into a container config and all of this is added to the CtrCreateOptions. Removes the need (mostly) for special additons which complicate the Container_create
code and pod creation.

resolves containers#12173

Signed-off-by: cdoern <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented Dec 28, 2021

@mheon PTAL

@rhatdan
Copy link
Member

rhatdan commented Jan 5, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 5, 2022
@openshift-merge-robot openshift-merge-robot merged commit 50e156b into containers:main Jan 5, 2022
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 22, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman pod create needs to support --security-opt
7 participants