Skip to content
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
21 changes: 0 additions & 21 deletions pkg/device/ascend/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,27 +161,6 @@ func (dev *Devices) MutateAdmission(ctr *corev1.Container, p *corev1.Pod) (bool,
}
}

if isHAMiCore {
klog.V(3).Infof("Ascend core resource detected, injecting postStart lifecycle for container %s", ctr.Name)

if ctr.Lifecycle == nil {
ctr.Lifecycle = &corev1.Lifecycle{}
}

// Inject PostStart hook to start the limiter process
if ctr.Lifecycle.PostStart == nil {
ctr.Lifecycle.PostStart = &corev1.LifecycleHandler{
Exec: &corev1.ExecAction{
Command: []string{
"bash",
"-c",
"export RUST_LOG=info\n/hami-vnpu-core/limiter > /tmp/limiter_manager.log 2>&1 &",
},
},
}
}
}

trimMem := dev.config.MemoryAllocatable
memory, ok := ctr.Resources.Limits[corev1.ResourceName(dev.config.ResourceMemoryName)]
if ok {
Expand Down
14 changes: 6 additions & 8 deletions pkg/device/ascend/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ func Test_MutateAdmission_VNPUCoreMode(t *testing.T) {
wantCore int64
}{
{
name: "vNPU-mode hami-core: inject postStart and keep raw memory",
name: "vNPU-mode hami-core: keep raw memory without postStart",
args: struct {
ctr corev1.Container
pod corev1.Pod
Expand Down Expand Up @@ -884,7 +884,7 @@ func Test_MutateAdmission_VNPUCoreMode(t *testing.T) {
},
},
},
wantPostStart: true,
wantPostStart: false,
wantMem: 15360,
wantCore: 20,
},
Expand All @@ -906,12 +906,10 @@ func Test_MutateAdmission_VNPUCoreMode(t *testing.T) {
assert.NilError(t, err)
assert.Equal(t, ok, true)

if test.wantPostStart {
assert.Assert(t, test.args.ctr.Lifecycle != nil, "Lifecycle should not be nil")
assert.Assert(t, test.args.ctr.Lifecycle.PostStart != nil, "PostStart should not be nil")
assert.Assert(t, test.args.ctr.Lifecycle.PostStart.Exec != nil)
commandStr := strings.Join(test.args.ctr.Lifecycle.PostStart.Exec.Command, " ")
assert.Assert(t, strings.Contains(commandStr, "/hami-vnpu-core/limiter"))
if !test.wantPostStart {
if test.args.ctr.Lifecycle != nil {
assert.Assert(t, test.args.ctr.Lifecycle.PostStart == nil, "PostStart should not be set")
}
}
Comment thread
archlitchi marked this conversation as resolved.

memLimit := test.args.ctr.Resources.Limits[corev1.ResourceName(dev.config.ResourceMemoryName)]
Expand Down
Loading