Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

outset file on_demand line 538 #91

Open
Theile opened this issue Dec 30, 2021 · 4 comments
Open

outset file on_demand line 538 #91

Theile opened this issue Dec 30, 2021 · 4 comments

Comments

@Theile
Copy link

Theile commented Dec 30, 2021

I have been looking into this solution, and we use it on several customers, thank you very much!

On line 538 of outset (as part of on_demand argument), this is done:

        open(cleanup_trigger, "w").close()
        time.sleep(0.5)
        if os.path.exists(cleanup_trigger):
            cleanup(cleanup_trigger)

I might not now all about python, but to me it looks like you are creating the cleanup_trigger file, and deleting it again. What am I missing?

@arubdesu
Copy link
Contributor

You could run git blame for the time that code was added (although it's probably been a few years at this point) to see what feature it was being delivered alongside (I'm assuming it's on-demand stuff).
Do you actually have a code issue or are you just curious? We can't exactly walk you through the entire control flow as it is 600+ lines, but if you clarify what you expect we can discuss it.

@Theile
Copy link
Author

Theile commented Dec 30, 2021

I don't have an issue, but to me this looked like a file being created and deleted again, and maybe this was actually not what was needed, or I don't understand these lines of Python. Just close this…

@chilcote
Copy link
Owner

Normally I can't interrogate what my fevered mind was thinking six years ago, but luckily we have git blame! ffed742 is where that was added. And looking at that, it seems that the problem was a race condition where the launch daemon would trigger again before the on demand job had a chance to remove the trigger file. (Launchd runs on a 10s loop iirc).

So this was a (very naive; again, fevered mind and six years ago) way of ensuring the trigger file was removed very early after the on demand job was kicked off.

I suppose it would make more sense to put this at the beginning of the on demand section, or maybe to rethink my life choices that led me to that point 😂. Cheers

@Theile
Copy link
Author

Theile commented Dec 30, 2021

Thank you so much, I really appreciate this explanation.

Happy New Year!!!

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

No branches or pull requests

3 participants