Skip to content

Conversation

guptadev21
Copy link
Member

@guptadev21 guptadev21 commented Sep 26, 2025

Description

This PR optimizes the behavior of the get_intf_ip filter when applied to devices that are not online.
Previously, the filter would always invoke device.ready(), which internally polls the device up to 18 times before giving up. This led to unnecessary delays and wasted time in cases where the device was already offline.

With this change, the filter first checks whether the device is online. If the device is not online, it will skip the ready-state polling and fail fast, avoiding the long wait.

Why this change is needed

  • Prevents unnecessary polling on offline devices.
  • Reduces latency when executing filters over devices that are known to be offline.
  • Improves user experience by making filter execution faster and more predictable.

Impact

  • Only affects get_intf_ip filter logic.
  • Online devices will continue to behave as before.
  • Offline devices will now short-circuit without waiting for the 18 polling cycles.

@guptadev21 guptadev21 self-assigned this Sep 26, 2025
@guptadev21 guptadev21 requested review from a team as code owners September 26, 2025 08:13
Copy link

github-actions bot commented Sep 26, 2025

🤖 Pull Request Artifacts (#18032272877) 🎉

@guptadev21 guptadev21 force-pushed the fix/check-device-state branch from ec14ef8 to d3c2eb8 Compare September 26, 2025 08:24

device = client.get_device(device_id)

if device["status"] == "REGISTERED":
Copy link
Contributor

Choose a reason for hiding this comment

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

it might not solve the problem, say for example if device is offline, now we poll it ready and bailout with exception and the resource which was dependent on this function will fail resulting into incomplete resources in the system. Instead this flow is more resilent:

  • have a function named poll_till_intf_ready() which will with a retry wait for say same period as we are doing currently for 180s until interface is available in devices response
  • since the poller on cloud side runs every 120s we are bound to get interface if interface is there on the device.
  • in case of registered state also if device is actually onboarded we will get the interface ready within 180s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants