Azure / azure-webjobs-sdk-extensions

Azure WebJobs SDK Extensions
MIT License
344 stars 206 forks source link

Timer: add metadata to blob lease that indicates which host has the lock #366

Open brettsam opened 6 years ago

brettsam commented 6 years ago

The function host blob lease mechanism does this today and it'd be useful to share that code. There are cases where a hardcoded host id means that timers are running on a local machine running the CLI and nothing in Azure is able to run.

This currently doesn't happen in the case of TimerTrigger because the SingletonListener passes null as the functionInstanceId: https://github.com/Azure/azure-webjobs-sdk/blob/bd2d9ea34f13fc16569e8d8f80bafdb605eeb6f9/src/Microsoft.Azure.WebJobs.Host/Singleton/SingletonListener.cs#L48

The writing of metadata is handled here: https://github.com/Azure/azure-webjobs-sdk/blob/bd2d9ea34f13fc16569e8d8f80bafdb605eeb6f9/src/Microsoft.Azure.WebJobs.Host/Singleton/BlobLeaseDistributedLockManager.cs#L278-L287

mathewc commented 6 years ago

Yes, the metadata I put in place for singleton initially wasn't targeted for listener level locks but function locks. The metadata is used to show in the Dashboard which function instance (not app instance) is currently holding the lock.

It would be good to also add the app instance ID to this metadata.