Skip to content

Runtime resource-name changes are not advertised after mock plugin startup #22

Closed

Description

@blackdragoon26

What happened:

MockLister.SetResource does not notify the device-plugin manager when the set of resource names changes after the first plugins have been created.

This is reachable with the current Ascend soft-mode implementation. An Ascend node can initially expose only its memory resource. If the node’s hami-vnpu-core annotation is later changed to true, GetResource begins returning an additional -core resource.

At that point, MockLister already has a memory plugin in pluginsMap. The current SetResource implementation therefore enters its existing-plugin branch and only updates counts for resources already present in pluginsMap. The new core resource has no plugin yet, and no update is sent through ResUpdateChan.

As a result, the core resource is never registered with kubelet. The reverse transition also does not notify the manager when a resource name disappears.

What you expected to happen:

Whenever the set of resource names changes, MockLister should send the complete updated resource-name list to the device-plugin manager.

Changes to counts for an unchanged resource set should continue updating existing plugins without unnecessarily recreating them.

For the Ascend example, enabling hami-vnpu-core at runtime should cause the corresponding -core resource to appear. Disabling it should remove that resource through the normal device-plugin-manager lifecycle.

How to reproduce it (as minimally and precisely as possible):

The problem can be reproduced without GPU hardware using MockLister directly:

  1. Create a lister and publish one resource:

    lister := mock.NewMockLister("example.com")
    lister.SetResource(map[string]int{
        "memory": 32768,
    })
  2. Let the manager create the initial memory plugin:

    lister.NewPlugin("memory")
  3. Simulate enabling Ascend soft mode by publishing an additional core resource:

    lister.SetResource(map[string]int{
        "memory": 32768,
         "core":   100,
    })
  4. Observe that the current implementation does not send a new resource list through ResUpdateChan, because pluginsMap is no longer empty.

  5. NewPlugin("core") is therefore never requested by the manager, and the new resource cannot be advertised to kubelet.

A regression test can reproduce the failure deterministically on macOS by using a buffered ResUpdateChan and asserting that the second call publishes ["core", "memory"].

Anything else we need to know? :

The issue is in the generic resource-discovery path, not in GPU drivers or hardware interaction.

A focused fix can:

  • track the last advertised resource-name set independently from pluginsMap;
  • send a sorted, complete resource-name list when names are added or removed;
  • continue updating counts in place when only values change;
  • avoid holding the lister mutex while sending through ResUpdateChan;
  • cover resource addition, removal, count-only changes, and initial zero counts with unit tests.

The proposed behavior follows the existing Discover contract, whose comments already state that dynamic implementations can publish a new list whenever available resources change.

The complete test suite, race-enabled lister tests, go vet, and git diff --check can all run on macOS without a Kubernetes cluster or accelerator hardware.

The output of nvidia-smi -a on your host: Not applicable; no NVIDIA hardware is required.
Your docker or containerd configuration file (e.g: /etc/docker/daemon.json): Not applicable.
The hami-device-plugin container logs: Not applicable; this concerns mock-device-plugin resource discovery.
The hami-scheduler container logs: Not applicable.
The kubelet logs on the node (e.g: sudo journalctl -r -u kubelet): Not required for the source-level reproduction.
Any relevant kernel output lines from dmesg: Not applicable.

Environment :

  • HAMi version: Not applicable; reproduced against Project-HAMi/mock-device-plugin master at d3b1687d79ade6e964f0213ff5bbd7d4f94cc3e1
  • nvidia driver or other AI device driver version: Not applicable
  • Docker version from docker version: Not applicable
  • Docker command, image and tag used: Not applicable
  • Kernel version from uname -a: macOS host; hardware-independent unit reproduction
    • Others:Repository: Project-HAMi/mock-device-plugin
    • Go version: 1.21 or newer
    • Affected component: internal/pkg/mock/lister.go

Activity

  1. blackdragoon26 commented on Aug 8, 2026

    @blackdragoon26
    MemberAuthor

    /assign

  2. coderabbitai commented on Aug 8, 2026

    @coderabbitai
    🔗 Related PRs

    #18 - feat(ascend,hygon): register AI-core/dcucores and support new and legacy vnpus config [merged]


    📝 Issue Planner

    Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.

    • Create Plan

    🧪 Issue enrichment is currently in open beta.

    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord!

  3. moezdil commented on Sep 22, 2026

    @moezdil

    Old PRs and issues are being closed because they are no longer relevant. Or it was closed because of th
    inactivity or PR/issues owners.
    If you believe the issue is still relevant, please submit feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions