Skip to content

feat(daemonset): add restart and rollout-aware wait methods #2752

Description

@rnetser

Problem

DaemonSet is missing two capabilities that force consumers to shell out to oc:

  1. No restart methodoc rollout restart works by patching the pod template with a kubectl.kubernetes.io/restartedAt annotation, triggering a rolling update. The wrapper has Resource.update() which can do a merge-patch, but there's no convenience method on DaemonSet.

  2. No rollout-aware waitwait_until_deployed only checks desiredNumberScheduled == numberReady, which is racy after a restart (old pods are still ready, returns immediately).

Root Cause

File: ocp_resources/daemonset.py

  • No restart() method exists. VirtualMachine has one (via subresource API), but DaemonSet restart is a standard annotation patch — not currently implemented.
  • wait_until_deployed (line 15) checks only:
    if desired_number_scheduled > 0 and desired_number_scheduled == number_ready:
    This doesn't verify pods are actually updated — just that enough are ready.

Proposed Approach

restart() method

Patch the pod template with a restartedAt annotation (same as oc rollout restart):

def restart(self):
    self.update(resource_dict={
        "spec": {"template": {"metadata": {"annotations": {
            "kubectl.kubernetes.io/restartedAt": datetime.utcnow().isoformat()
        }}}}
    })

wait_for_rollout() method

Check all three conditions (mirrors oc rollout status):

  1. status.observedGeneration == metadata.generation
  2. status.updatedNumberScheduled == status.desiredNumberScheduled
  3. status.numberAvailable == status.desiredNumberScheduled

Similar to how Deployment.wait_for_replicas checks updatedReplicas.

Done

  • Add restart() method to DaemonSet class
  • Add wait_for_rollout() method to DaemonSet class
  • Keep existing wait_until_deployed unchanged (no breaking change)
  • Add tests for both new methods

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions