2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-08-03 16:07:00 +00:00

Merge pull request #250 from Obihoernchen/stateless-booted-status

Report stateless boot completion via new 'booted' status
This commit is contained in:
Jarrod Johnson
2026-07-20 12:55:55 -04:00
committed by GitHub
6 changed files with 22 additions and 13 deletions
@@ -49,5 +49,5 @@ run_remote_parts onboot.d
# Induce execution of remote configuration, e.g. ansible plays in ansible/onboot.d/
run_remote_config onboot.d
#curl -X POST -d 'status: booted' -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus
printf 'state: booted\nstatus: booted' | curl -X POST --data-binary @- -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus
kill $logshowpid
@@ -70,5 +70,5 @@ if [ -f /run/confluent/onboot_sleep.pid ]; then
kill "$sleeppid"
rm -f /run/confluent/onboot_sleep.pid
fi
#curl -X POST -d 'status: booted' -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus
printf 'state: booted\nstatus: booted' | curl -X POST --data-binary @- -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus
kill $logshowpid
@@ -65,5 +65,5 @@ if [ -f /run/confluent/onboot_sleep.pid ]; then
rm -f /run/confluent/onboot_sleep.pid
fi
#curl -X POST -d 'status: booted' -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus
printf 'state: booted\nstatus: booted' | curl -X POST --data-binary @- -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus
kill $logshowpid
@@ -29,5 +29,5 @@ run_remote_parts onboot.d
# Induce execution of remote configuration, e.g. ansible plays in ansible/onboot.d/
run_remote_config onboot.d
#curl -X POST -d 'status: booted' -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus
printf 'state: booted\nstatus: booted' | curl -X POST --data-binary @- -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus
kill $logshowpid
@@ -36,5 +36,5 @@ run_remote_parts onboot.d
# Induce execution of remote configuration, e.g. ansible plays in ansible/onboot.d/
run_remote_config onboot.d
#curl -X POST -d 'status: booted' -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus
printf 'state: booted\nstatus: booted' | curl -X POST --data-binary @- -H "CONFLUENT_NODENAME: $nodename" -H "CONFLUENT_APIKEY: $confluent_apikey" https://$confluent_mgr/confluent-api/self/updatestatus
kill $logshowpid
+17 -8
View File
@@ -480,10 +480,17 @@ async def handle_request(req, make_response, mimetype):
mrsp = await make_response(mimetype, 200, 'Ok')
await mrsp.write(b'Accepted')
return
stayarmed = False
if update['status'] == 'staged':
targattr = 'deployment.stagedprofile'
elif update['status'] == 'complete':
targattr = 'deployment.profile'
elif update['status'] == 'booted':
# a stateless node reporting a successful boot; record the booted
# profile as current, but leave pendingprofile armed since the
# node needs it to network boot the same image on next boot
targattr = 'deployment.profile'
stayarmed = True
else:
raise Exception('Unknown update status request')
currattr = cfg.get_node_attributes(nodename, 'deployment.*').get(
@@ -495,17 +502,19 @@ async def handle_request(req, make_response, mimetype):
pending = currattr.get('deployment.pendingprofile', {}).get('value', '')
updates = {}
if pending:
updates['deployment.pendingprofile'] = {'value': ''}
if targattr == 'deployment.profile':
updates['deployment.stagedprofile'] = {'value': ''}
dls = cfg.get_node_attributes(nodename, 'deployment.lock')
dls = dls.get(nodename, {}).get('deployment.lock', {}).get('value', None)
if dls == 'autolock':
updates['deployment.lock'] = 'locked'
if not stayarmed:
updates['deployment.pendingprofile'] = {'value': ''}
if targattr == 'deployment.profile':
updates['deployment.stagedprofile'] = {'value': ''}
dls = cfg.get_node_attributes(nodename, 'deployment.lock')
dls = dls.get(nodename, {}).get('deployment.lock', {}).get('value', None)
if dls == 'autolock':
updates['deployment.lock'] = 'locked'
currprof = currattr.get(targattr, {}).get('value', '')
if currprof != pending:
updates[targattr] = {'value': pending}
await cfg.set_node_attributes({nodename: updates})
if updates:
await cfg.set_node_attributes({nodename: updates})
return await make_response('text/plain', 200, 'OK', body='OK')
else:
return await make_response('text/plain', 500, 'Error', body='No pending profile detected, unable to accept status update')