(ctx context.Context, client *containerd.Client, id, uts string, internalLabels *internalLabels, options types.ContainerCreateOptions)
| 44 | } |
| 45 | |
| 46 | func setPlatformOptions(ctx context.Context, client *containerd.Client, id, uts string, internalLabels *internalLabels, options types.ContainerCreateOptions) ([]oci.SpecOpts, error) { |
| 47 | var opts []oci.SpecOpts |
| 48 | opts = append(opts, |
| 49 | oci.WithDefaultUnixDevices, |
| 50 | WithoutRunMount(), // unmount default tmpfs on "/run": https://github.com/containerd/nerdctl/issues/157) |
| 51 | ) |
| 52 | |
| 53 | opts = append(opts, |
| 54 | oci.WithMounts([]specs.Mount{ |
| 55 | {Type: "cgroup", Source: "cgroup", Destination: "/sys/fs/cgroup", Options: []string{"ro", "nosuid", "noexec", "nodev"}}, |
| 56 | })) |
| 57 | |
| 58 | cgOpts, err := generateCgroupOpts(id, options, internalLabels) |
| 59 | if err != nil { |
| 60 | return nil, err |
| 61 | } |
| 62 | opts = append(opts, cgOpts...) |
| 63 | |
| 64 | annotations := strutil.ConvertKVStringsToMap(options.Annotations) |
| 65 | |
| 66 | capOpts, err := generateCapOpts( |
| 67 | strutil.DedupeStrSlice(options.CapAdd), |
| 68 | strutil.DedupeStrSlice(options.CapDrop)) |
| 69 | if err != nil { |
| 70 | return nil, err |
| 71 | } |
| 72 | opts = append(opts, capOpts...) |
| 73 | securityOptsMaps := strutil.ConvertKVStringsToMap(strutil.DedupeStrSlice(options.SecurityOpt)) |
| 74 | secOpts, err := generateSecurityOpts(options.Privileged, options.GOptions.SelinuxEnabled, securityOptsMaps) |
| 75 | if err != nil { |
| 76 | return nil, err |
| 77 | } |
| 78 | opts = append(opts, secOpts...) |
| 79 | |
| 80 | b4nnOpts, err := bypass4netnsutil.GenerateBypass4netnsOpts(securityOptsMaps, annotations, id) |
| 81 | if err != nil { |
| 82 | return nil, err |
| 83 | } |
| 84 | opts = append(opts, b4nnOpts...) |
| 85 | |
| 86 | ulimitOpts, err := generateUlimitsOpts(options.Ulimit) |
| 87 | if err != nil { |
| 88 | return nil, err |
| 89 | } |
| 90 | |
| 91 | // If without any ulimitOpts, we need to reset the default value from spec |
| 92 | // which has 1024 as file limit. Make this behavior same as containerd/cri. |
| 93 | if len(ulimitOpts) == 0 { |
| 94 | ulimitOpts = append(ulimitOpts, withRlimits(nil)) |
| 95 | } |
| 96 | |
| 97 | opts = append(opts, ulimitOpts...) |
| 98 | if options.Sysctl != nil { |
| 99 | opts = append(opts, WithSysctls(strutil.ConvertKVStringsToMap(options.Sysctl))) |
| 100 | } |
| 101 | |
| 102 | if options.RDTClass != "" { |
| 103 | opts = append(opts, oci.WithRdt(options.RDTClass, "", "")) |
no test coverage detected
searching dependent graphs…