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

cli: skip integrity check when prereq skip flag is present #203912

Merged
merged 1 commit 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
33 changes: 19 additions & 14 deletions cli/src/tunnels/code_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::util::errors::{wrap, AnyError, CodeError, ExtensionInstallFailed, Wra
use crate::util::http::{self, BoxedHttp};
use crate::util::io::SilentCopyProgress;
use crate::util::machine::process_exists;
use crate::util::prereqs::skip_requirements_check;
use crate::{debug, info, log, spanf, trace, warning};
use lazy_static::lazy_static;
use opentelemetry::KeyValue;
Expand Down Expand Up @@ -425,20 +426,24 @@ impl<'a> ServerBuilder<'a> {
let server_dir = target_dir.join(SERVER_FOLDER_NAME);
unzip_downloaded_release(&archive_path, &server_dir, SilentCopyProgress())?;

let output = capture_command_and_check_status(
server_dir
.join("bin")
.join(self.server_params.release.quality.server_entrypoint()),
&["--version"],
)
.await
.map_err(|e| wrap(e, "error checking server integrity"))?;

trace!(
self.logger,
"Server integrity verified, version: {}",
String::from_utf8_lossy(&output.stdout).replace('\n', " / ")
);
if !skip_requirements_check().await {
let output = capture_command_and_check_status(
server_dir
.join("bin")
.join(self.server_params.release.quality.server_entrypoint()),
&["--version"],
)
.await
.map_err(|e| wrap(e, "error checking server integrity"))?;

trace!(
self.logger,
"Server integrity verified, version: {}",
String::from_utf8_lossy(&output.stdout).replace('\n', " / ")
);
} else {
info!(self.logger, "Skipping server integrity check");
}

Ok(())
})
Expand Down
16 changes: 11 additions & 5 deletions cli/src/util/prereqs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ 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 @@ -55,7 +54,7 @@ impl PreReqChecker {
pub async fn verify(&self) -> Result<Platform, CodeError> {
let (is_nixos, skip_glibc_checks, or_musl) = tokio::join!(
check_is_nixos(),
check_skip_req_file(),
skip_requirements_check(),
check_musl_interpreter()
);

Expand Down Expand Up @@ -169,9 +168,16 @@ async fn check_is_nixos() -> bool {
/// 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()
#[cfg(not(windows))]
pub async fn skip_requirements_check() -> bool {
fs::metadata("/tmp/vscode-skip-server-requirements-check")
.await
.is_ok()
}

#[cfg(windows)]
pub async fn skip_requirements_check() -> bool {
false
}

#[allow(dead_code)]
Expand Down
Loading