GitLab upgrades are managed by the sre.gitlab.upgrade cookbook which surrounds the package upgrade with proper downtimes, backups and depooling.
However it's still possible to manually upgrade the gitlab-ce apt package and trigger an upgrade without this additional safeguards (which has happened in T426164).
So we should explore how we can prevent accidental upgrades with measures like apt-pinning or apt hold.
A brief research returned apt-mark hold is probably all we need:
hold
hold is used to mark a package as held back, which will prevent the package from being automatically installed, upgraded or removed.unhold
unhold is used to cancel a previously set hold on a package to allow all actions again.showhold
showhold is used to print a list of packages on hold in the same way as for the other show commands.
https://manpages.ubuntu.com/manpages/bionic/man8/apt-mark.8.html#prevent-changes-for-a-package
The cookbook could unhold the package, do a upgrade and hold it after a successful upgrade.