canonical / canonical/cloud-init

cloud-init reporting does not report boot stage start;finish events for init-local, init-network, modules-config, modules-final

Open
#4,032 0 comments 0 reactions 0 assignees View on GitHub
bug launchpad
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

This bug was originally filed in Launchpad as [LP: #1992711](https://bugs.launchpad.net/cloud-init/+bug/1992711)

Launchpad details

affected_projects = []

assignee = None
assignee_name = None
date_closed = None
date_created = 2022-10-13T03:05:58.140480+00:00
date_fix_committed = None
date_fix_released = None
id = 1992711
importance = undecided
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1992711
milestone = None
owner = chad.smith
owner_name = Chad Smith
private = False
status = triaged
submitter = chad.smith
submitter_name = Chad Smith
tags = []
duplicates = []

_Launchpad user **Chad Smith(chad.smith)** wrote on 2022-10-13T03:05:58.140480+00:00_

cloud-init 22.3 reporting configuration doesn't report paired start/finish event_types for all of cloud-init's boot stages.

Expected behavior:
cloud-init boot stages (init-local, init-network, config-modules and config-final) to emit both event_type start and finish to represent entry and exit of each boot stage and result "SUCCESS" or "FAILURE".

Results seen:
Only intermittently see init-network finish events, otherwise strictly event children within the named scope of init-local/*, init-network/*, modules-config/* and modules-final/* publish both start and finish events.

# desired init-network event only seen sometimes.
{"name": "init-network", "description": "searching for network datasources", "event_type": "finish", "origin": "cloudinit", "timestamp": 1665613954.3995728, "result": "SUCCESS"}

Test Procedure:

# terminal 1 on LXC host setup simple http server to log POST name:event_type tuples

cat > report_server.py << EOF
#!/usr/bin/env python3

from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
import json

class S(BaseHTTPRequestHandler):
def _set_response(self):
self.send_response(200)
self.send_header('Content-type', 'text/plain')
self.end_headers()

def do_POST(self):
content_length = int(self.headers['Content-Length'])
post_data = self.rfile.read(content_length)
json_data = json.loads(post_data.decode('utf-8'))
msg = f"{json_data['name']}:{json_data['event_type']}"
logging.info(msg)
self._set_response()

def run(server_class=HTTPServer, handler_class=S, port=8080):
logging.basicConfig(level=logging.INFO)
server_address = ('', port)
httpd = server_class(server_address, handler_class)
logging.info('Starting httpd...\n')
try:
httpd.serve_forever()
except KeyboardInterrupt:
pass
httpd.server_close()
logging.info('Stopping httpd...\n')

if __name__ == '__main__':
from sys import argv

if len(argv) == 2:
run(port=int(argv[1]))
else:
run()

EOF

python3 report_server.py 2> /dev/null

#### Terminal 2
# Setup LXC container with a reporting configuration which will talk to the LXC host
cat > 99-reporting.cfg <

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.