vmware / vmware/pyvmomi

pyVim.task ProgressUpdater sometimes throws

Open
#771 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
Python
Stars
2.3k
Forks
763
PR merge metrics
No merged PRs in 30d

Description

I'm new to this lib, so correct me if I'm wrong, because it might be me doing something stupid, not a bug :)

  • ProgressUpdater and the default TaskUpdatesVerbose depend directly on task.info, instead on "snapshot" returned by propertyCollector.WaitForUpdates. The task.info is volatile and can change now and then, which causes TOCTOU in TaskUpdatesVerbose

What I'm seeing (every few executions of a script that just reverts 1 VM to a snapshot and powers it on) is that TaskUpdatesVerbose throws when it tries to format info.progress using %d and info.progress happens to be None at that moment. At the same time info.progress somehow passes the first if and at that point it apparently claims to be an int.

  • I've seen somewhere in docs that task.info can have progress not set to anything (when task doesn't want to return percentage), if that's the case, the default logging will discard it, because it accepts only ints, which makes it not as verbose as advertised ;).

It seems to be true, because if I changed logging function to plain print("%s"...), that will happily stringify progress field, I've seen much more updates dumped to screen.

And in general, if I'm right that task.info is volatile and propertyCollector updates are stable, then the whole task code relies too much on task.info directly and works mostly because important fields happen to be immutable strings.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with ProgressUpdater and the default TaskUpdatesVerbose, then trace how they read task.info versus snapshots from propertyCollector.WaitForUpdates. Reproduce the revert-and-power-on script and inspect the progress formatting path. Done means progress updates no longer intermittently raise when progress is None and the handling of unset progress matches the intended verbose behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.