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

Give a better error message when CI download fails #120098

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Teapot4195
Copy link
Contributor

@Teapot4195 Teapot4195 commented Jan 18, 2024

Fixes an issue introduced in 7b5577985df7. Looks like a typo, checked the output from diff and doesn't look like there are any other issues in with the commit.

resolves 118758

@rustbot
Copy link
Collaborator

rustbot commented Jan 18, 2024

r? @Mark-Simulacrum

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 18, 2024
@Teapot4195 Teapot4195 changed the title download_http_with_retries should only return when Powershell exits with success not failure. Give a better error message when CI download fails Jan 18, 2024
@Teapot4195
Copy link
Contributor Author

Not exactly as suggested in the original issue, however based on this zulip discussion it seems like putting it under download_http_with_retries is a better choice.

@rust-log-analyzer

This comment has been minimized.

@Teapot4195 Teapot4195 force-pushed the issue-118758-fix branch 4 times, most recently from b1dcabf to 05dce7c Compare January 18, 2024 23:59
@Teapot4195 Teapot4195 force-pushed the issue-118758-fix branch 2 times, most recently from 61e204f to 0fdf0a4 Compare January 19, 2024 14:08
src/bootstrap/src/core/download.rs Outdated Show resolved Hide resolved
src/bootstrap/src/core/download.rs Outdated Show resolved Hide resolved
src/bootstrap/src/core/download.rs Outdated Show resolved Hide resolved
.map(|c| c as char)
.collect();
let upstream = git::get_rust_lang_rust_remote(
&GitConfig { git_repository: "rust-lang/rust.git", nightly_branch: "" },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use something like self.config.git_config() or similar, not hardcode these values.

src/bootstrap/src/core/download.rs Outdated Show resolved Hide resolved
}
crate::exit!(1);
}
}

fn check_outdated(commit: &String) {
let check_outdated_msg = || {
if !commit.is_empty() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems surprising to do all of the user.name-based work, and then end up not actually looking at any timestamps anyway because commit.is_empty().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit.is_empty() is really just a sanity check, it should be very unlikely to hit that branch of the if statement now. Not sure how this should be refactored.

src/bootstrap/src/core/download.rs Outdated Show resolved Hide resolved
src/bootstrap/src/core/download.rs Outdated Show resolved Hide resolved
"NOTE: origin/master is {} days out of date, CI builds disappear in 168 days.",
diff / (24 * 60 * 60)
);
eprintln!("HELP: Consider updating your fork of the rust sources");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fork doesn't sound right here. origin/master should be the rust-lang/rust remote, not a fork.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original remote is the contributor's fork no? And then usually it would be upstream that is rust-lang/rust.

src/bootstrap/src/core/download.rs Outdated Show resolved Hide resolved
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 20, 2024
@Teapot4195
Copy link
Contributor Author

Teapot4195 commented Jan 20, 2024

fixed, did some thinking and it doesn't really make sense to check for commits not by the current user in origin/master..HEAD any more, nor does it make sense to be checking if the user's repo is out of date, checking if HEAD is out of date makes much more sense (especially since this is trying to explain why the download of a component failed).

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 20, 2024
.unwrap_or("".to_string());
match SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
Ok(n) => {
let replaced = last_commit.replace("\n", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let replaced = last_commit.replace("\n", "");
let replaced = last_commit.trim();

I suspect this is the actual intent.

src/bootstrap/src/core/download.rs Show resolved Hide resolved
@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 27, 2024
@Teapot4195
Copy link
Contributor Author

Teapot4195 commented Jan 28, 2024

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 28, 2024
tempfile: &Path,
url: &str,
help_on_error: &str,
commit: &String,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
commit: &String,
commit: &str,

@@ -194,7 +195,7 @@ impl Config {
let _ = try_run(self, patchelf.arg(fname));
}

fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str) {
fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str, commit: &String) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str, commit: &String) {
fn download_file(&self, url: &str, dest_path: &Path, help_on_error: &str, commit: &str) {

&String should almost never be in any API.

}
crate::exit!(1);
}
}

fn check_outdated(commit: &String) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn check_outdated(commit: &String) {
fn check_outdated(commit: &str) {

src/bootstrap/src/core/download.rs Show resolved Hide resolved
Command::new("git")
.arg("show")
.arg("-s")
.arg("--format=%ar")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why author date here. vs commit date above? Can we add comments indicating what the percent codes mean?

.unwrap_or("".to_string());
if build_date.is_empty() {
eprintln!(
"NOTE: tried to download builds for {}, CI builds will be gone in 168 days",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"NOTE: tried to download builds for {}, CI builds will be gone in 168 days",
"NOTE: tried to download builds for {}, CI builds are only retained for 168 days",

);
} else {
eprintln!(
"NOTE: tried to download builds for {} (from {}), CI builds will be gone in 168 days",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"NOTE: tried to download builds for {} (from {}), CI builds will be gone in 168 days",
"NOTE: tried to download builds for {} (from {}), CI builds are only retained for 168 days",

commit, build_date
);
}
eprintln!("HELP: Consider updating your copy of the rust sources");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like a suggestion we could improve upon, but I guess it's OK for now. It seems like we still have a divergence between rustc components and LLVM components on how we compute the right commit to download, so there's not necessarily single guidance we can give here.

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 4, 2024
@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Feb 4, 2024
@Teapot4195
Copy link
Contributor Author

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 5, 2024
Ok(status) => status,
Err(e) => fail(&format!("failed to execute command: {cmd:?}\nERROR: {e}")),
};
String::from_utf8(output.stdout).unwrap_or("".to_string())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just panic or similar if the output isn't utf-8. Returning an empty String is confusing.

.arg("--format=%cr") // Commit date in `x days ago` format
.arg(commit),
);
if build_date.is_empty() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given below change to panic on non-utf-8, we should remove this branch.

@@ -648,7 +695,7 @@ HELP: if trying to compile an old commit of rustc, disable `download-rustc` in c
download-rustc = false
";
}
self.download_file(&format!("{base_url}/{url}"), &tarball, help_on_error);
self.download_file(&format!("{base_url}/{url}"), &tarball, help_on_error, &key.to_string());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explicitly thread the commit through or rename the argument to commit. Otherwise changing the cache key will break this functionality in a confusing way.

You also shouldn't need to call .to_string() here.

&format!("{base}/{llvm_sha}/{filename}"),
&tarball,
help_on_error,
&llvm_sha.to_string(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
&llvm_sha.to_string(),
&llvm_sha,

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 18, 2024
@bors
Copy link
Contributor

bors commented Mar 12, 2024

☔ The latest upstream changes (presumably #122389) made this pull request unmergeable. Please resolve the merge conflicts.

@Teapot4195
Copy link
Contributor Author

Needed to take a break, but hopefully I understood the changes you wanted to be done.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented May 12, 2024

☔ The latest upstream changes (presumably #124883) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

give a better error when origin/HEAD is vastly out of date
6 participants