From 8d09bb5b0d0147decbd3456c3a750d0324aa02c8 Mon Sep 17 00:00:00 2001 From: Markus Hilger Date: Sun, 1 Nov 2026 12:21:56 +0100 Subject: [PATCH] Add deployment.kernelargs for per-node kernel arguments Kernel arguments could only be set per profile, baked into the static boot files of the profile. Nodes or groups that need extra arguments, such as a different console or driver options, required a copy of the whole profile. When deployment.kernelargs is set, the iPXE boot offer now points at the existing /confluent-api/boot/by-node endpoint, which serves the profile boot.ipxe or boot.ipxe.shim with the node arguments appended to the kernel line and the paths made absolute. UEFI HTTP boot takes the same path, as it chainloads the iPXE shim when that is installed. A UEFI HTTP boot that loads the static boot.img instead logs that the node arguments are not applied. Nodes without the attribute keep receiving the static profile files. --- .../confluent/config/attributes.py | 7 ++++++ .../confluent/discovery/protocols/pxe.py | 23 ++++++++++++++---- confluent_server/confluent/httpapi.py | 24 ++++++++++++++++++- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/confluent_server/confluent/config/attributes.py b/confluent_server/confluent/config/attributes.py index fe067368..9e8a0e69 100644 --- a/confluent_server/confluent/config/attributes.py +++ b/confluent_server/confluent/config/attributes.py @@ -218,6 +218,13 @@ node = { 'deployment.client_ip': { 'description': ('Client IP used when most recently reporting state.') }, + 'deployment.kernelargs': { + 'description': ('Additional kernel command line arguments to pass at ' + 'network boot, appended after the kernelargs of the ' + 'profile. These arguments are not made ' + 'persistent in the installed OS, except on SUSE 16, ' + 'whose installer keeps its own kernel arguments.'), + }, 'deployment.lock': { 'description': ('Indicates whether deployment actions should be impeded. ' 'If locked, it indicates that a pending profile should not be applied. ' diff --git a/confluent_server/confluent/discovery/protocols/pxe.py b/confluent_server/confluent/discovery/protocols/pxe.py index 02616ff3..f6d802c0 100644 --- a/confluent_server/confluent/discovery/protocols/pxe.py +++ b/confluent_server/confluent/discovery/protocols/pxe.py @@ -354,10 +354,13 @@ async def proxydhcp(handler, nodeguess): log.log({'info': 'No pending profile for {0}, skipping proxyDHCP reply'.format(node)}) continue myip = socket.inet_ntoa(myipn) + bootbase = '{0}://{1}/confluent-public/os/{2}/boot.'.format(webproto, myip, profile) + if cfd.get(node, {}).get('deployment.kernelargs', {}).get('value', None): + bootbase = '{0}://{1}/confluent-api/boot/by-node/{2}/'.format(webproto, myip, node) if disco['arch'] == 'bios-x86' or not os.path.exists('/var/lib/confluent/public/os/{0}/boot.ipxe.shim'.format(profile)): - bootfile = '{0}://{1}/confluent-public/os/{2}/boot.ipxe'.format(webproto, myip, profile).encode('utf8') + bootfile = (bootbase + 'ipxe').encode('utf8') else: - bootfile = '{0}://{1}/confluent-public/os/{2}/boot.ipxe.shim'.format(webproto, myip, profile).encode('utf8') + bootfile = (bootbase + 'ipxe.shim').encode('utf8') elif disco['arch'] == 'uefi-x64': bootfile = b'confluent/x86_64/ipxe-shim.efi' elif disco['arch'] == 'bios-x86': @@ -667,6 +670,10 @@ async def reply_dhcp6(node, addr, cfg, packet, cfd, profile, sock, niccfg=None): bootfile = '{0}://[{1}]/confluent-public/os/{2}/boot.ipxe'.format( proto, ipv6srvaddr, profile ) + if cfd.get(node, {}).get('deployment.kernelargs', {}).get('value', None): + bootfile = '{0}://[{1}]/confluent-api/boot/by-node/{2}/ipxe'.format( + proto, ipv6srvaddr, node + ) if hasshim and bootarch != 'bios-x86': bootfile += '.shim' elif hasshim and os.path.exists('/var/lib/confluent/public/ipxe/{}/ipxe-shim.efi'.format(shimarch)): @@ -695,6 +702,9 @@ async def reply_dhcp6(node, addr, cfg, packet, cfd, profile, sock, niccfg=None): 'HTTPClient:Arch:')): # do not send ip-less replies to anything but HTTPClient and iPXE return + if (packet['rqtype'] == 1 and bootfile.endswith(b'/boot.img') + and cfd.get(node, {}).get('deployment.kernelargs', {}).get('value', None)): + log.log({'warning': 'deployment.kernelargs of {0} is not applied, UEFI HTTP boot of profile {1} does not go through iPXE'.format(node, profile)}) # 1 msgtype # 3 txid # 22 - server ident @@ -849,6 +859,8 @@ async def reply_dhcp4(node, info, packet, cfg, reqview, httpboot, cfd, profile, proto, myipn, profile ) bootshorturl = '/confluent-public/os/{0}/boot.img'.format(profile) + if rqtype == 1 and cfd.get(node, {}).get('deployment.kernelargs', {}).get('value', None): + log.log({'warning': 'deployment.kernelargs of {0} is not applied, UEFI HTTP boot of profile {1} does not go through iPXE'.format(node, profile)}) bootfilename = '/var/lib/confluent/public/os/{0}/boot.img'.format(profile) can302 = False if not isinstance(bootfile, bytes): @@ -871,10 +883,13 @@ async def reply_dhcp4(node, info, packet, cfg, reqview, httpboot, cfd, profile, if not profile: log.log({'info': 'No pending profile for {0}, skipping proxyDHCP reply'.format(node)}) return + bootbase = '{0}://{1}/confluent-public/os/{2}/boot.'.format(proto, myipn, profile) + if cfd.get(node, {}).get('deployment.kernelargs', {}).get('value', None): + bootbase = '{0}://{1}/confluent-api/boot/by-node/{2}/'.format(proto, myipn, node) if not os.path.exists('/var/lib/confluent/public/os/{0}/boot.ipxe.shim'.format(profile)): - bootfile = '{0}://{1}/confluent-public/os/{2}/boot.ipxe'.format(proto, myipn, profile).encode('utf8') + bootfile = (bootbase + 'ipxe').encode('utf8') else: - bootfile = '{0}://{1}/confluent-public/os/{2}/boot.ipxe.shim'.format(proto, myipn, profile).encode('utf8') + bootfile = (bootbase + 'ipxe.shim').encode('utf8') if len(bootfile) > 127: if bootfile.startswith(b'http'): bootfile = register_shorturl(bootfile.decode('utf8')).encode('utf8') diff --git a/confluent_server/confluent/httpapi.py b/confluent_server/confluent/httpapi.py index d040497c..35a2ef07 100644 --- a/confluent_server/confluent/httpapi.py +++ b/confluent_server/confluent/httpapi.py @@ -767,10 +767,32 @@ async def resourcehandler_backend(req, make_response): nodename = request[2] bootfile = request[3] cfg = configmanager.ConfigManager(None) - nodec = cfg.get_node_attributes(nodename, 'deployment.pendingprofile') + nodec = cfg.get_node_attributes(nodename, ('deployment.pendingprofile', 'deployment.kernelargs')) pprofile = nodec.get(nodename, {}).get('deployment.pendingprofile', {}).get('value', None) if not pprofile: return await make_response(mimetype, 404, 'Not Found') + kernelargs = nodec.get(nodename, {}).get('deployment.kernelargs', {}).get('value', None) + # one line of arguments, so nothing in the value becomes an iPXE command + kernelargs = ' '.join(str(kernelargs or '').split()) + if kernelargs and bootfile in ('ipxe', 'ipxe.shim'): + # Serve the profile script with the node kernelargs appended, + # making paths absolute as it is no longer fetched from the profile + bootscript = [] + appended = False + with open('/var/lib/confluent/public/os/{0}/boot.{1}'.format(pprofile, bootfile)) as ipxein: + for line in ipxein.read().split('\n'): + cmd = line.split(' ', 2) + if len(cmd) > 1 and cmd[0] in ('imgfetch', 'shim', 'chain'): + if not cmd[1].startswith('/') and '://' not in cmd[1]: + cmd[1] = '/confluent-public/os/{0}/{1}'.format(pprofile, cmd[1]) + if cmd[1].endswith('/boot/kernel'): + cmd.append(kernelargs) + appended = True + line = ' '.join(cmd) + bootscript.append(line) + if not appended: + log.log({'warning': 'deployment.kernelargs of {0} is not applied, the boot script of profile {1} does not load a Linux kernel'.format(nodename, pprofile)}) + return await make_response('text/plain', 200, 'OK', body='\n'.join(bootscript)) redir = '/confluent-public/os/{0}/boot.{1}'.format(pprofile, bootfile) rsp = await make_response(mimetype, 302, 'Found', {'Location': redir}) return rsp