Skip to content

Commit

Permalink
fix: skip server requirements check based on file presence (#203731)
Browse files Browse the repository at this point in the history
* fix: skip server requirements check based on file presence

* chore: update check for remote containers
  • Loading branch information
deepak1556 authored Jan 31, 2024
1 parent 8c08612 commit 0504748
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
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

0 comments on commit 0504748

Please sign in to comment.