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

add cgroupPath capability arg #141

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pkg/ocicni/ocicni.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,12 @@ func buildCNIRuntimeConf(podNetwork *PodNetwork, ifName string, runtimeConfig Ru
if len(podNetwork.Aliases) > 0 {
rt.CapabilityArgs["aliases"] = podNetwork.Aliases
}

// set cgroupPath in Capabilities
if runtimeConfig.CgroupPath != "" {
rt.CapabilityArgs["cgroupPath"] = runtimeConfig.CgroupPath
Copy link
Member

Choose a reason for hiding this comment

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

does this string exist anywhere we can reference directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

not that I see; I just followed the existing code that puts capability names here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good suggestion for libcni sometime though.

}

return rt, nil
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/ocicni/ocicni_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,13 @@ var _ = Describe("ocicni operations", func() {
Expect(len(ir)).To(Equal(1))
Expect(len(ir[0])).To(Equal(1))
Expect(ir[0][0].Gateway).To(Equal("192.168.0.254"))

runtimeConfig = RuntimeConfig{CgroupPath: "/slice/pod/testing"}
rt, err = buildCNIRuntimeConf(podNetwork, ifName, runtimeConfig)
Expect(err).NotTo(HaveOccurred())
cg, ok := rt.CapabilityArgs["cgroupPath"].(string)
Expect(ok).To(Equal(true))
Expect(cg).To(Equal("/slice/pod/testing"))
})

It("sets up and tears down a pod using the default network", func() {
Expand Down
3 changes: 3 additions & 0 deletions pkg/ocicni/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ type RuntimeConfig struct {
Bandwidth *BandwidthConfig
// IpRanges is the ip range gather which is used for address allocation
IpRanges [][]IpRange
// CgroupPath is the path to the pod's cgroup
// e.g. "/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-burstable.slice/kubelet-kubepods-burstable-pod28ce45bc_63f8_48a3_a99b_cfb9e63c856c.slice"
CgroupPath string
}

// BandwidthConfig maps to the standard CNI bandwidth Capability
Expand Down