canonical/pylxd

Instance status and state().status out of sync

Hook25 opened this issue · 0 comments

It seems that sometimes the instance.status and instance.state().status attributes are out of sync. I have debugged a little bit and the state().status seems to be correct. This causes a crash (trying to wait on a start operation on an already started machine) in my application.

One thing I found weird is the _set_state function that does something like this:

if wait:
    self.client.operations.wait_for_operation(response.json()["operation"])
    if "status" in self.__dirty__:
        self.__dirty__.remove("status")
    if self.ephemeral and state == "stop":
        self.client = None
    else:
        self.sync()

Could the clearing of the __dirty__ set in a previous stop transition be causing this problem?

I am using python 3.11.3 and pylxd 2.3.1