Skip to content

Commit b97ebd0

Browse files
authored
Offer to raise the kernel key limits instead of only naming them (#81)
The check fires while usage is merely near the limit, then exited with 'limits exceeded' and pointed at a sysctl file that does not exist yet - which left the node unable to create any further container and gave no command to copy. It now offers to write the file and reload sysctl, and prints three runnable lines when declined.
1 parent da209e2 commit b97ebd0

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

‎ui/build-ui.func‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,19 +200,34 @@ maxkeys_check() {
200200

201201
if [[ "$used_lxc_keys" -gt "$threshold_keys" ]]; then
202202
msg_warn "Key usage is near the limit (${used_lxc_keys}/${per_user_maxkeys})"
203-
echo -e "${INFO} Suggested action: Set ${GN}kernel.keys.maxkeys=${new_limit_keys}${CL} in ${BOLD}/etc/sysctl.d/98-community-scripts.conf${CL}."
204203
failure=1
205204
fi
206205
if [[ "$used_lxc_bytes" -gt "$threshold_bytes" ]]; then
207206
msg_warn "Key byte usage is near the limit (${used_lxc_bytes}/${per_user_maxbytes})"
208-
echo -e "${INFO} Suggested action: Set ${GN}kernel.keys.maxbytes=${new_limit_bytes}${CL} in ${BOLD}/etc/sysctl.d/98-community-scripts.conf${CL}."
209207
failure=1
210208
fi
211209

212-
if [[ "$failure" -eq 1 ]]; then
213-
msg_error "Kernel key limits exceeded - see suggestions above"
214-
exit 108
210+
[[ "$failure" -eq 1 ]] || return 0
211+
212+
# Offering beats explaining: the old text named a file that does not exist yet and left
213+
# every further install on the node blocked behind a step nobody could copy.
214+
local keys_conf="/etc/sysctl.d/98-community-scripts.conf"
215+
if prompt_confirm "${TAB}Raise the kernel key limits now?" "y" 60; then
216+
if printf 'kernel.keys.maxkeys = %s\nkernel.keys.maxbytes = %s\n' \
217+
"$new_limit_keys" "$new_limit_bytes" >"$keys_conf" 2>/dev/null &&
218+
sysctl --system >/dev/null 2>&1; then
219+
msg_ok "Raised kernel key limits (maxkeys ${new_limit_keys}, maxbytes ${new_limit_bytes})"
220+
return 0
221+
fi
222+
msg_error "Could not apply ${keys_conf}"
215223
fi
224+
225+
echo -e "${TAB}${INFO} Run this on the node, then start the script again:"
226+
echo -e "${TAB}${GN}echo 'kernel.keys.maxkeys = ${new_limit_keys}' > ${keys_conf}${CL}"
227+
echo -e "${TAB}${GN}echo 'kernel.keys.maxbytes = ${new_limit_bytes}' >> ${keys_conf}${CL}"
228+
echo -e "${TAB}${GN}sysctl --system${CL}"
229+
msg_error "Kernel key limits too low to create another container"
230+
exit 108
216231
}
217232

218233
# ==============================================================================

0 commit comments

Comments
 (0)