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

containerd: add OCI default spec and settings #2697

Merged
merged 2 commits into from
Jan 17, 2023

Conversation

mchaker
Copy link
Contributor

@mchaker mchaker commented Jan 3, 2023

Issue number:

Closes #1703

Description of changes:

This PR adds support for setting default OCI spec values. The default OCI spec stored at /etc/containerd/cri-base.json is applied to all containers run by containerd, unless otherwise configured (e.g. by Kubernetes).

The OCI spec can be found in detail at /~https://github.com/opencontainers/runtime-spec/blob/main/config.md .

This PR also adds some default settings that we want Bottlerocket to ship with: namely, a specific set of process capabilities (sources/models/shared-defaults/oci-capabilities.toml) and resource limits (sources/models/shared-defaults/oci-resource-limits.toml).

Testing done:

OCI Defaults Test Plan

Manual Testing

Baseline

  • Baseline with Production AMI v1.11 (i.e. ami-09d516ec16c94c0e0)
    • Get the OCI spec for a sample nginx workload container launched via kubernetes (save it for comparison)
    • Run a pod that opens as many files as it can, as well as printing the container capabilities
      • How many files were opened: 65533 due to our containerd patch.
      • Bounding capabilities: {CAP_SETFCAP, CAP_NET_RAW, CAP_KILL, CAP_CHOWN, CAP_SETUID, CAP_FSETID, CAP_FOWNER, CAP_AUDIT_WRITE, CAP_MKNOD, CAP_SYS_CHROOT, CAP_DAC_OVERRIDE, CAP_SETPCAP, CAP_NET_BIND_SERVICE, CAP_SETGID}

Test case: feature enabled and configured with default settings


Make sure there is no behavior change when not configuring the new settings.

  • Run modified AMI (ami-0f58fc68a762109e8, 7ad3110d) without setting oci-defaults.capabilities, oci-defaults.resource-limits in userdata
    • Get the OCI spec for a nginx workload container: it matched v1.11
    • Run a pod that opens as many files as it can, as well as printing the container capabilities
      • How many files were opened: 65533 (matched v1.11)
      • Bounding capabilities: {CAP_CHOWN, CAP_MKNOD, CAP_SYS_CHROOT, CAP_NET_BIND_SERVICE, CAP_SETFCAP, CAP_SETUID, CAP_FOWNER, CAP_DAC_OVERRIDE, CAP_KILL, CAP_SETGID, CAP_FSETID, CAP_SETPCAP, CAP_AUDIT_WRITE} (matched v1.11, with the exception of CAP_NET_RAW, which is intentionally removed)
  • Log in to the test node and verify that the cri-base.json file contains the desired settings default values

Test case: set capabilities

  • Run modified AMI (ami-01b0018dc3c2ad0de, 3940728)
    • Add a capability (CAP_BPF) via apiclient
  • Run a pod that opens as many files as it can, as well as printing the container capabilities
    • How many files were opened: 65533 (unchaged from defaults)
    • Bounding capabilities: {CAP_SETFCAP, CAP_MKNOD, CAP_SETUID, CAP_BPF, CAP_SETGID, CAP_FSETID, CAP_AUDIT_WRITE, CAP_NET_BIND_SERVICE, CAP_DAC_OVERRIDE, CAP_CHOWN, CAP_KILL, CAP_FOWNER, CAP_SETPCAP, CAP_SYS_CHROOT} (capabilities changed accordingly: CAP_BPF was added)
  • Log in to the test node and verify that the cri-base.json file contains the desired settings values

Test case: set resource-limits

  • Run modified AMI (ami-01b0018dc3c2ad0de, 3940728)
    • Use apiclient to change the RLIMIT_NOFILE soft value to 90000
  • Run a pod that opens as many files as it can, as well as printing the container capabilities
    • How many files were opened: 89997 (changed according to new RLIMIT_NOFILE soft)
    • Bounding capabilities: {CAP_SETPCAP, CAP_FOWNER, CAP_AUDIT_WRITE, CAP_CHOWN, CAP_SETGID, CAP_MKNOD, CAP_SYS_CHROOT, CAP_SETFCAP, CAP_KILL, CAP_NET_BIND_SERVICE, CAP_FSETID, CAP_SETUID, CAP_DAC_OVERRIDE} (unchanged from defaults)
  • Log in to the test node and verify that the cri-base.json file contains the desired settings values

Test case: set both capabilities and resource-limits


Combine both of the above: i.e. set capabilities and rlimit_nofile values

  • Run modified AMI (ami-0628b6b13d2b7c83e, 69c158f)
    • Use apiclient to change the RLIMIT_NOFILE soft value to 90000
    • Use apiclient to add a capability (CAP_BPF)
  • Run a pod that opens as many files as it can, as well as printing the container capabilities
    • How many files were opened: 89997 (changed according to new RLIMIT_NOFILE soft)
    • Bounding capabilities: {CAP_KILL, CAP_SETUID, CAP_NET_BIND_SERVICE, CAP_DAC_OVERRIDE, CAP_BPF, CAP_SETPCAP, CAP_AUDIT_WRITE, CAP_MKNOD, CAP_SETFCAP, CAP_SYS_CHROOT, CAP_CHOWN, CAP_SETGID, CAP_FSETID, CAP_FOWNER} (capabilities changed accordingly: CAP_BPF was added)
  • Log in to the test node and verify that the cri-base.json file contains the desired settings values

Test all variants

Repeat above Manual Testing steps for the following variants:

  • aws-k8s-1.23
  • aws-k8s-1.23-nvidia
  • metal-k8s-1.24
  • vmware-k8s-1.23

Run abridged Manual Testing steps for the following variants:

  • aws-k8s-1.21
  • aws-k8s-1.21-nvidia
  • aws-k8s-1.22
  • aws-k8s-1.22-nvidia
  • aws-k8s-1.24-nvidia
  • aws-k8s-1.24
  • metal-k8s-1.21
  • metal-k8s-1.22
  • metal-k8s-1.23
  • vmware-k8s-1.21
  • vmware-k8s-1.22
  • vmware-k8s-1.24

Run Sonobuoy Conformance

  • Run Sonobuoy quick suite
  • Run Sonobuoy full suite

Test case: Upgrade Downgrade

  • v1.11 --> this version --> v1.11

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Copy link
Contributor Author

@mchaker mchaker left a comment

Choose a reason for hiding this comment

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

remaining TODOs based on early feedback

sources/models/shared-defaults/oci-capabilities.toml Outdated Show resolved Hide resolved
sources/models/shared-defaults/oci-capabilities.toml Outdated Show resolved Hide resolved
sources/models/shared-defaults/oci-defaults.toml Outdated Show resolved Hide resolved
sources/models/shared-defaults/oci-resource-limits.toml Outdated Show resolved Hide resolved
@mchaker mchaker force-pushed the 1703-rlimits-clean branch from 98dc430 to 021d433 Compare January 3, 2023 23:56
@mchaker
Copy link
Contributor Author

mchaker commented Jan 3, 2023

Force push: resolved remaining TODOs based on early feedback.

@mchaker mchaker force-pushed the 1703-rlimits-clean branch 2 times, most recently from 7dad2fb to 2a8101c Compare January 4, 2023 00:56
@mchaker
Copy link
Contributor Author

mchaker commented Jan 4, 2023

Force push: resolved merge conflict

@mchaker mchaker force-pushed the 1703-rlimits-clean branch 2 times, most recently from a3aed67 to afbec9e Compare January 4, 2023 21:34
@mchaker mchaker force-pushed the 1703-rlimits-clean branch from afbec9e to 9c72669 Compare January 5, 2023 14:54
@mchaker
Copy link
Contributor Author

mchaker commented Jan 5, 2023

Force push: removed panic in helper and reset default capabilities to 1.0.2-dev defaults.

@etungsten etungsten self-requested a review January 5, 2023 19:17
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
sources/models/src/modeled_types/mod.rs Outdated Show resolved Hide resolved
sources/api/schnauzer/src/helpers.rs Outdated Show resolved Hide resolved
sources/api/schnauzer/src/helpers.rs Outdated Show resolved Hide resolved
sources/api/schnauzer/src/helpers.rs Outdated Show resolved Hide resolved
sources/api/schnauzer/src/helpers.rs Outdated Show resolved Hide resolved
@etungsten etungsten mentioned this pull request Jan 5, 2023
11 tasks
@mchaker mchaker force-pushed the 1703-rlimits-clean branch from 9c72669 to e19d8eb Compare January 5, 2023 23:49
@mchaker
Copy link
Contributor Author

mchaker commented Jan 5, 2023

Force push: address some comments

@webern webern force-pushed the 1703-rlimits-clean branch from e19d8eb to c633a17 Compare January 6, 2023 00:19
@webern
Copy link
Contributor

webern commented Jan 6, 2023

@webern webern force-pushed the 1703-rlimits-clean branch from c633a17 to 46d0035 Compare January 6, 2023 01:07
@webern
Copy link
Contributor

webern commented Jan 6, 2023

^ /~https://github.com/bottlerocket-os/bottlerocket/compare/c633a175eadb7edd95f6fb1374de3ef16d8b62d8..46d0035f43b35102443877f2338a763f2d8fedec

  • Use #[model(add_option = false)] to require both hard and soft limits to be set (as is required by the spec).
  • Add the OCI defaults settings to all the k8s variants.

@webern webern force-pushed the 1703-rlimits-clean branch from 46d0035 to 9d7001a Compare January 6, 2023 01:15
README.md Outdated Show resolved Hide resolved
@mchaker mchaker force-pushed the 1703-rlimits-clean branch from 9d7001a to bf2b51b Compare January 6, 2023 16:47
@mchaker
Copy link
Contributor Author

mchaker commented Jan 6, 2023

README.md Outdated

The **default** capabilities that are set in Bottlerocket are:

setting key | setting value
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe

Suggested change
setting key | setting value
setting | default value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it's clearer - accepted suggestion

README.md Outdated
Comment on lines 621 to 629
setting key | corresponding linux process capability
----- | -----
`settings.oci-defaults.capabilities.audit-control` | `CAP_AUDIT_CONTROL`
`settings.oci-defaults.capabilities.audit-read` | `CAP_AUDIT_READ`
`settings.oci-defaults.capabilities.audit-write` | `CAP_AUDIT_WRITE`
`settings.oci-defaults.capabilities.block-suspend` | `CAP_BLOCK_SUSPEND`
`settings.oci-defaults.capabilities.bpf` | `CAP_BPF`
`settings.oci-defaults.capabilities.checkpoint-restore` | `CAP_CHECKPOINT_RESTORE`
`settings.oci-defaults.capabilities.chown` | `CAP_CHOWN`
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to organize this as:

capability | setting | default value
CAP_AUDIT_CONTROL | settings.oci-defaults.capabilities.audit-control | false

With all the default-true ones first, followed by the others. Then we wouldn't have the duplication, and the sorting would be similar to runc's list of capabilities.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What would be preferable for default value in the case of capabilities we do not configure with default values?

A: The semantically correct setting of false
B: The syntactically correct "setting" of (unset)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, does this comment (reorganizing to capability | setting | default value) also apply to rlimits as well?
Meaning, reorganizing the rlimits section to be resource limit | setting | default value?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer something like - to indicate unset, so there's less visual noise.

Making the same change to the rlimits section would be good too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +665 to +656
##### OCI Defaults: Resource Limits

Each of the `resource-limits` settings below contain two numeric fields: `hard-limit` and `soft-limit`, which are **32-bit unsigned integers**.

Please see the [`getrlimit` linux manpage](https://man7.org/linux/man-pages/man7/capabilities.7.html) for meanings of `hard-limit` and `soft-limit`.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is quite a lot of change to land in one commit. The functionality is great, no complaints there, but it makes it a bit harder for reviewers to digest.

As a suggestion for commit structure in the future, I'd recommend:

  • one commit to add the scaffolding and base functionality
  • one commit to add settings + template fields for rlimits (smaller)
  • one commit to add settings + template fields for capabilities (larger)
  • one commit for required migrations

It's fine for this PR though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apologies for the monolithic PR structure and thank you for explaining a better way. I'll keep this comment in my notebook as a reminder for my next PR.

@@ -0,0 +1 @@
../../../shared-defaults/oci-defaults.toml
Copy link
Contributor

Choose a reason for hiding this comment

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

It's a minor thing, but I'd prefer to have these in the 75-79 or 85-89 range, together with ??-oci-hooks.toml, rather than at the end of the 90 range. That way all the OCI related defaults share the same range.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Symlinks renamed in latest force push

Comment on lines 1 to 3
[settings.oci-defaults.resource-limits.max-open-files]
hard-limit = 1048576
soft-limit = 65536
Copy link
Contributor

Choose a reason for hiding this comment

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

In preparation for future Docker support, we should give these files a name to keep them distinct:

  • oci-defaults-containerd-cri.toml
  • oci-defaults-containerd-cri-resource-limits.toml
  • oci-defaults-containerd-cri-capabilities.toml

The capabilities will be the same but the resource limits and configuration files will be different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Accepted suggestion, thank you

Comment on lines 12 to 16
migrate(common_migrations::AddPrefixesMigration(vec![
"settings.oci-defaults",
]))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
migrate(common_migrations::AddPrefixesMigration(vec![
"settings.oci-defaults",
]))
migrate(common_migrations::AddPrefixesMigration(vec![
"settings.oci-defaults",
"services.oci-defaults",
"configuration-files.oci-defaults",
]))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, accepted suggestion

Comment on lines 1 to 2
[metadata.settings.oci-defaults]
affected-services = ["oci-defaults", "containerd"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Need a metadata migration for the affected services.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines 4 to 12
/// OciDefaultsCapability specifies which process capabilities are
/// allowed to be modified in Bottlerocket. The Linux process
/// capabilities are defined in the Linux manpages (see the man7.org link below).
/// Default values can be found in: sources/models/shared-defaults/oci-capabilities.toml
/// OCI spec: /~https://github.com/opencontainers/runtime-spec/blob/c4ee7d12c742ffe806cd9350b6af3b4b19faed6f/config.md#linux-process
/// Linux kernel capabilities: https://man7.org/linux/man-pages/man7/capabilities.7.html
///
/// Default capabilities are specified in the following file:
/// * sources/models/shared-defaults/oci-capabilities.toml
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd probably clean up all of these links and just say:

Suggested change
/// OciDefaultsCapability specifies which process capabilities are
/// allowed to be modified in Bottlerocket. The Linux process
/// capabilities are defined in the Linux manpages (see the man7.org link below).
/// Default values can be found in: sources/models/shared-defaults/oci-capabilities.toml
/// OCI spec: /~https://github.com/opencontainers/runtime-spec/blob/c4ee7d12c742ffe806cd9350b6af3b4b19faed6f/config.md#linux-process
/// Linux kernel capabilities: https://man7.org/linux/man-pages/man7/capabilities.7.html
///
/// Default capabilities are specified in the following file:
/// * sources/models/shared-defaults/oci-capabilities.toml
/// OciDefaultsCapability specifies which process capabilities are
/// allowed to be set in the default OCI spec.

sources/models/shared-defaults/oci-capabilities.toml is extremely likely to be renamed during a refactor, and this comment probably won't stay correct. The OCI spec link seems a little out-of-place here, and the man page is pretty easy to find by anyone who knows they're working with Linux capabilities.

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 - wouldn't want stale references in comments. Accepted suggestion

Comment on lines 98 to 106
/// OciDefaultsResourceLimitType specifies which resource limits are
/// allowed to be modified in Bottlerocket. The full list of Linux resource limits can
/// be found in the Linux manpages (for convenience at the man7.org link below.)
/// Default values can be found in: sources/models/shared-defaults/oci-resource-limits.toml
/// OCI spec: /~https://github.com/opencontainers/runtime-spec/blob/c4ee7d12c742ffe806cd9350b6af3b4b19faed6f/config.md#posix-process
/// Linux resource limits: https://man7.org/linux/man-pages/man2/getrlimit.2.html#DESCRIPTION
///
/// Default resource limits are specified in the following file:
/// * sources/models/shared-defaults/oci-resource-limits.toml
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// OciDefaultsResourceLimitType specifies which resource limits are
/// allowed to be modified in Bottlerocket. The full list of Linux resource limits can
/// be found in the Linux manpages (for convenience at the man7.org link below.)
/// Default values can be found in: sources/models/shared-defaults/oci-resource-limits.toml
/// OCI spec: /~https://github.com/opencontainers/runtime-spec/blob/c4ee7d12c742ffe806cd9350b6af3b4b19faed6f/config.md#posix-process
/// Linux resource limits: https://man7.org/linux/man-pages/man2/getrlimit.2.html#DESCRIPTION
///
/// Default resource limits are specified in the following file:
/// * sources/models/shared-defaults/oci-resource-limits.toml
/// OciDefaultsResourceLimitType specifies which resource limits are
/// allowed to be set in the default OCI spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Accepted suggestion

@mchaker mchaker force-pushed the 1703-rlimits-clean branch from bf2b51b to ec2a9f4 Compare January 10, 2023 01:14
@mchaker
Copy link
Contributor Author

mchaker commented Jan 10, 2023

Comment on lines 12 to 16
migrate(common_migrations::AddPrefixesMigration(vec![
"settings.oci-defaults",
"services.oci-defaults",
"configuration-files.oci-defaults",
]))
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is a feature for k8s only, you may want to exclude the execution of the migration for all the other variants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! Thanks :)

@mchaker mchaker force-pushed the 1703-rlimits-clean branch from 66c1115 to e3d47c4 Compare January 11, 2023 17:44
@mchaker
Copy link
Contributor Author

mchaker commented Jan 11, 2023

Copy link
Contributor

@etungsten etungsten left a comment

Choose a reason for hiding this comment

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

🍕

LGTM assuming all the testing looks good.

@webern webern force-pushed the 1703-rlimits-clean branch from e3d47c4 to 6a7d5a6 Compare January 13, 2023 19:33
@webern webern force-pushed the 1703-rlimits-clean branch from 6a7d5a6 to 8be44e0 Compare January 14, 2023 00:30
@webern
Copy link
Contributor

webern commented Jan 14, 2023

@webern webern force-pushed the 1703-rlimits-clean branch from 8be44e0 to 8a04add Compare January 14, 2023 01:45
@webern
Copy link
Contributor

webern commented Jan 14, 2023

Copy link
Contributor

@stmcginnis stmcginnis left a comment

Choose a reason for hiding this comment

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

Looks good to me, testing done looks good, and tests are passing. I'm not strong on the migrations, so definitely would be good to have someone that understands those better take a closer look.

let mut is_first = true;
for (rlimit_type, values) in &oci_default_rlimits {
if !is_first {
result_lines.push_str(",\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to note - I don't think it makes that much difference - but you could have results_line be an array, then use result_lines.join(",\n") at the end to get the resulting comma separated final string.

@bcressey
Copy link
Contributor

Can you fix the co-authored-by tags in the commit messages?

Co-authored-by: name <mmchaker@amazon.com>
Co-authored-by: name <brigmatt@amazon.com>

Also, this description is not correct:

The default OCI spec stored at /etc/containerd/cri-base.json is applied to all containers run by containerd, unless otherwise configured (e.g. by Kubernetes pod specs).

The changes here only affect containerd-cri, and not containers launched by other means (host / bootstrap containers, Docker for ECS variants).

Copy link
Contributor

@bcressey bcressey left a comment

Choose a reason for hiding this comment

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

LGTM apart from a few style nits and the commit messages.

Comment on lines 10 to 15
if cfg!(variant_runtime = "k8s") {
migrate(AddMetadataMigration(&[SettingMetadata {
metadata: &["affected-services"],
setting: "settings.oci-defaults",
}]))?;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

If I understand correctly - conditionalizing this on the variant is just for defensive / documentation purposes, it isn't actually necessary for aws-ecs-1 which won't have this metadata.

Comment on lines 11 to 21
fn run() -> Result<()> {
if cfg!(variant_runtime = "k8s") {
migrate(common_migrations::AddPrefixesMigration(vec![
"settings.oci-defaults",
"services.oci-defaults",
"configuration-files.oci-defaults",
]))
} else {
Ok(())
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

to avoid the "else" branch:

Suggested change
fn run() -> Result<()> {
if cfg!(variant_runtime = "k8s") {
migrate(common_migrations::AddPrefixesMigration(vec![
"settings.oci-defaults",
"services.oci-defaults",
"configuration-files.oci-defaults",
]))
} else {
Ok(())
}
}
fn run() -> Result<()> {
if cfg!(variant_runtime = "k8s") {
migrate(common_migrations::AddPrefixesMigration(vec![
"settings.oci-defaults",
"services.oci-defaults",
"configuration-files.oci-defaults",
]))?;
}
Ok(())
}

Comment on lines 10 to 15
if cfg!(variant_runtime = "k8s") {
migrate(AddMetadataMigration(&[SettingMetadata {
metadata: &["affected-services"],
setting: "settings.oci-defaults",
}]))?;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I don't think that last semicolon is needed:

Suggested change
if cfg!(variant_runtime = "k8s") {
migrate(AddMetadataMigration(&[SettingMetadata {
metadata: &["affected-services"],
setting: "settings.oci-defaults",
}]))?;
};
if cfg!(variant_runtime = "k8s") {
migrate(AddMetadataMigration(&[SettingMetadata {
metadata: &["affected-services"],
setting: "settings.oci-defaults",
}]))?;
}

Comment on lines 1453 to 1470
let capabilities_section = format!(
"\"bounding\": [
{capabilities_bounding}
],
\"effective\": [
{capabilities_effective}
],
\"permitted\": [
{capabilities_permitted}
]",
capabilities_bounding = capabilities_lines_joined,
capabilities_effective = capabilities_lines_joined,
capabilities_permitted = capabilities_lines_joined,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use a combination of raw strings and concat! to clean this up so the string literal isn't flush with the left margin:

Suggested change
let capabilities_section = format!(
"\"bounding\": [
{capabilities_bounding}
],
\"effective\": [
{capabilities_effective}
],
\"permitted\": [
{capabilities_permitted}
]",
capabilities_bounding = capabilities_lines_joined,
capabilities_effective = capabilities_lines_joined,
capabilities_permitted = capabilities_lines_joined,
);
let capabilities_section = format!(
concat!(
r#""bounding": ["#,
"{capabilities_bounding}",
"]",
r#""effective": ["#,
"{capabilities_effective}",
"]",
r#""permitted": ["#,
"{capabilities_permitted}",
"]",
),
capabilities_bounding = capabilities_lines_joined,
capabilities_effective = capabilities_lines_joined,
capabilities_permitted = capabilities_lines_joined,
);

(same for the rlimit function)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is much nicer, thank you!

@webern webern force-pushed the 1703-rlimits-clean branch from 8a04add to 684e813 Compare January 17, 2023 19:16
@webern
Copy link
Contributor

webern commented Jan 17, 2023

^ /~https://github.com/bottlerocket-os/bottlerocket/compare/8a04adde8601155ca1aa26389f7d522b94dde41a..684e813d7c88e27dba71a12c0c1bc7826110c141

  • Avoid the else branch
  • nit: I don't think that last semicolon is needed:
  • You can use a combination of raw strings and concat! to clean this up so the string literal isn't flush with the left margin:
  • Use Vec.join
  • Can you fix the co-authored-by tags in the commit messages?
  • The changes here only affect containerd-cri, and not containers launched by other means (host / bootstrap containers, Docker for ECS variants).

@webern webern force-pushed the 1703-rlimits-clean branch from 684e813 to b0d09dc Compare January 17, 2023 21:24
mchaker and others added 2 commits January 17, 2023 13:59
This change adds support for setting default OCI spec values. The
default OCI spec stored at `/etc/containerd/cri-base.json` is applied
to all containers run by `containerd-cri`, unless otherwise configured
(e.g. by Kubernetes pod specs).

Co-authored-by: Mahdi Chaker <mmchaker@amazon.com>
Co-authored-by: Matthew James Briggs <brigmatt@amazon.com>
Co-authored-by: Mahdi Chaker <mmchaker@amazon.com>
Co-authored-by: Matthew James Briggs <brigmatt@amazon.com>
@webern webern force-pushed the 1703-rlimits-clean branch from b0d09dc to 352a0a1 Compare January 17, 2023 21:59
Copy link
Contributor

@webern webern left a comment

Choose a reason for hiding this comment

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

I performed upgrade/downgrade testing from v1.11.0 -> v1.12.0 -> v1.11.0

On v1.11 and v1.12 I ran an ngnix pod and checked its oci spec with a command like this:

ctr -n k8s.io c info --spec 5a724a53cf

The specs were the same on both versions of Bottlerocket (i.e. if a customer does not use these new settings, their pods will not be affected).

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

containerd: set process_rlimit_no_file_soft/hard
6 participants