Relax check_config conditions when installing patch releases
If Chef prematurely crashes for some reason (e.g. due to #8532 (closed)), users trying to install GitLab again are greeted with an unfriendly Malformed configuration JSON
error, which requires manual intervention:
# apt install gitlab-ee
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
libasn1-8-heimdal libffi7 libgssapi3-heimdal libhcrypto4-heimdal libheimbase1-heimdal libheimntlm0-heimdal libhx509-5-heimdal libicu66 libkrb5-26-heimdal libldap-2.4-2 libllvm10 libroken18-heimdal libwind0-heimdal
Use 'sudo apt autoremove' to remove them.
The following packages will be upgraded:
gitlab-ee
1 upgraded, 0 newly installed, 0 to remove and 85 not upgraded.
1 not fully installed or removed.
Need to get 1066 MB of archives.
After this operation, 1837 kB disk space will be freed.
Get:1 https://packages.gitlab.com/gitlab/pre-release/ubuntu jammy/main amd64 gitlab-ee amd64 17.0.202405091400-c2b357bf33a.5d54a8c7d13 [1066 MB]
Fetched 1066 MB in 1min 7s (15.9 MB/s)
(Reading database ... 343353 files and directories currently installed.)
Preparing to unpack .../gitlab-ee_17.0.202405091400-c2b357bf33a.5d54a8c7d13_amd64.deb ...
Malformed configuration JSON file found at /opt/gitlab/embedded/nodes/stanhu-gce.c.redacted.internal.json.
This usually happens when your last run of `gitlab-ctl reconfigure` didn't complete successfully.
This file is used to check if any of the unsupported configurations are enabled,
and hence require a working reconfigure before upgrading.
Please run `sudo gitlab-ctl reconfigure` to fix it and try again.
dpkg: error processing archive /var/cache/apt/archives/gitlab-ee_17.0.202405091400-c2b357bf33a.5d54a8c7d13_amd64.deb (--unpack):
new gitlab-ee package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/gitlab-ee_17.0.202405091400-c2b357bf33a.5d54a8c7d13_amd64.deb
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)
When gitlab-ctl reconfigure
first runs:
- Chef trashes the
/opt/gitlab/embedded/nodes
when it first runs: https://github.com/chef/omnibus-ctl/blob/4e968f4cf713a545bbb70ee13b8ff7ebd37f7f3e/lib/omnibus-ctl.rb#L500 - Then Chef runs
Chef::Node#find_or_create
for the nodes file. - Since it was trashed, the node info returns 404, so it creates a file with almost no info.
- If Chef crashes (e.g. due to
parser
3.3.1.0), Chef doesn't get a chance to runsave_updated_node
to update the info.
You would expect that reinstalling GitLab would recover here, but you have to manually remove the files in /opt/gitlab/embedded/nodes
to make this work.
Proposal:
- Check the currently-installed version.
- If
check_config
determines there aren't any config changes between old and new versions, just skip the malformed JSON check since it's going to be regenerated.
Edited by Stan Hu