To which API event do I have to subscribe to get a stack global status

Hello,

I’m currently sending commands to the rest API to Create/Start an application stack. By subscribing to the web socket I would like to know when my stack is ready to use.

I’ve looked at all the event that are sent, but nothings seems to have a “global stack” healthy status. The only resource.change event that is sent on the environment is only sent when I stop it and then the status is active

Any advice on how I could achieve this ?

There’s no great answer for this today; health states only actually exist on containers. They are aggregated up by the UI with and combined with service state to form what is displayed as the state of the service, and then again for stack. So you’d have to replicate the same logic. It’s on my list (#1052) for API v2 someday…

Thx for the answer. After digging in the API this was what I was about to do…

So basically, each time I receive a resource.change on a container, I should reconstruct the service & stack health with the API to get the complete stack health.

Yes… depending on exactly what you want you may just be able look for containers with healthState != ‘healthy’. To replicate all the stuff the UI does to handle global services, start-once containers, etc is quite a bit of logic (and why it should be in the API…):

Containers -> Service: https://github.com/rancher/ui/blob/master/app/models/service.js#L306-L381

Services -> Stack: https://github.com/rancher/ui/blob/master/app/models/environment.js#L113-L162

(API “environment” === UI “Stack”)

Ok thx for the pointers