Register for the iXsystems Community to get an ad-free experience

Chart application restart flow

Western Digital Drives - The Preferred Drives of FreeNAS and TrueNAS CORE

kiler129

Cadet
Joined
Apr 16, 2016
Messages
7
I'm scripting a custom certificate installation for an application running on TNS. After the certificate is installed I need to "restart" the application (PoC: https://gist.github.com/kiler129/39c1330731ba263f15e28c04f154c0f8).

After playing with the API I came up with the following flow:

  1. Query application status via midclt call chart.release.query '[["id","=","plex"]]' | jq -r '.[] | .status'
    • If status is not ACTIVE nor DEPLOYING abort
  2. Scale to 0 replicas using midclt call chart.release.scale 'plex' '{"replica_count":0}'
    • Job id is returned, which took me a while to find. I'm not sure if there's any place where this is documented.
  3. Wait for the job to complete
    • The websocket api seems to use some subscription API, but midclt doesn't seem to have any equivalent, or I cannot find it
    • Currently I'm querying the jobs api to check the status: midclt call core.get_jobs '[["id","=",1234]]' | jq -r '.[0].state'
    • Based on the middleware source my code needs to wait until the status is WAITING or RUNNING
    • When scaling succeeded the job will have a status of SUCCESS
  4. Scale to 1 replica using midclt call chart.release.scale 'plex' '{"replica_count":1}'
  5. Wait for the job to complete and report status to the user like in #3
Is my understanding of the flow correct? Is there a smarter way to wait for the job to complete/await completion of the scaling, or polling is the only option in CLI?
 
Last edited:
Top