Skip to content

Commit

Permalink
Merge pull request #141 from squeed/cgroup-capability
Browse files Browse the repository at this point in the history
add cgroupPath capability arg
  • Loading branch information
openshift-merge-robot committed Feb 27, 2023
2 parents af98d6c + 1b45ae4 commit 183c461
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
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
}

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

0 comments on commit 183c461

Please sign in to comment.