Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip server requirements check based on file presence #203731

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions cli/src/util/prereqs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ lazy_static! {
}

const NIXOS_TEST_PATH: &str = "/etc/NIXOS";
const SKIP_REQ_FILE: &str = "/tmp/vscode-skip-server-requirements-check";

pub struct PreReqChecker {}

Expand Down Expand Up @@ -52,13 +53,20 @@ impl PreReqChecker {

#[cfg(target_os = "linux")]
pub async fn verify(&self) -> Result<Platform, CodeError> {
let (is_nixos, gnu_a, gnu_b, or_musl) = tokio::join!(
let (is_nixos, skip_glibc_checks, or_musl) = tokio::join!(
check_is_nixos(),
check_glibc_version(),
check_glibcxx_version(),
check_skip_req_file(),
check_musl_interpreter()
);

let (gnu_a, gnu_b) = if !skip_glibc_checks {
tokio::join!(check_glibc_version(), check_glibcxx_version())
} else {
println!("!!! WARNING: Skipping server pre-requisite check !!!");
println!("!!! Server stability is not guaranteed. Proceed at your own risk. !!!");
(Ok(()), Ok(()))
};

if (gnu_a.is_ok() && gnu_b.is_ok()) || is_nixos {
return Ok(if cfg!(target_arch = "x86_64") {
Platform::LinuxX64
Expand Down Expand Up @@ -157,6 +165,15 @@ async fn check_is_nixos() -> bool {
fs::metadata(NIXOS_TEST_PATH).await.is_ok()
}

/// Do not remove this check.
/// Provides a way to skip the server glibc requirements check from
/// outside the install flow. A system process can create this
/// file before the server is downloaded and installed.
#[allow(dead_code)]
async fn check_skip_req_file() -> bool {
fs::metadata(SKIP_REQ_FILE).await.is_ok()
}

#[allow(dead_code)]
async fn check_glibcxx_version() -> Result<(), String> {
let mut libstdc_path: Option<String> = None;
Expand Down
13 changes: 12 additions & 1 deletion resources/server/bin/code-server-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,19 @@ esac

ROOT="$(dirname "$(dirname "$(readlink -f "$0")")")"

# Do not remove this check.
# Provides a way to skip the server requirements check from
# outside the install flow. A system process can create this
# file before the server is downloaded and installed.
skip_check=0
if [ -f "/tmp/vscode-skip-server-requirements-check" ]; then
echo "!!! WARNING: Skipping server pre-requisite check !!!"
echo "!!! Server stability is not guaranteed. Proceed at your own risk. !!!"
skip_check=1
fi

# Check platform requirements
if [ "$(echo "$@" | grep -c -- "--skip-requirements-check")" -eq 0 ]; then
if [ "$(echo "$@" | grep -c -- "--skip-requirements-check")" -eq 0 ] && [ $skip_check -eq 0 ]; then
$ROOT/bin/helpers/check-requirements.sh
exit_code=$?
if [ $exit_code -ne 0 ]; then
Expand Down
14 changes: 14 additions & 0 deletions resources/server/bin/helpers/check-requirements-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@

set -e

# Do not remove this check.
# Provides a way to skip the server requirements check from
# outside the install flow. A system process can create this
# file before the server is downloaded and installed.
#
# This check is duplicated between code-server-linux.sh and here
# since remote container calls into this script directly quite early
# before the usual server startup flow.
if [ -f "/tmp/vscode-skip-server-requirements-check" ]; then
echo "!!! WARNING: Skipping server pre-requisite check !!!"
echo "!!! Server stability is not guaranteed. Proceed at your own risk. !!!"
exit 0
fi

BITNESS=$(getconf LONG_BIT)
ARCH=$(uname -m)
found_required_glibc=0
Expand Down
Loading