Skip to content

[support bundle] Ensure that the transfer buffers are flushed #8708

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

Merged
merged 1 commit into from
Jul 29, 2025

Conversation

smklein
Copy link
Collaborator

@smklein smklein commented Jul 28, 2025

Fixes #8681

@@ -592,11 +592,12 @@ impl BundleCollection {
})?;

// Only stream at most "transfer_chunk_size" bytes at once
let remaining = std::cmp::min(
let chunk_size = std::cmp::min(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is just for clarify; it's not the bug fix

})?;

offset += self.transfer_chunk_size.get();
offset += chunk_size;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This technically wasn't "wrong" before, because we didn't use the offset after the very last call, but over-shooting the actual length of the support bundle still felt fishy, so I changed this.

(The resulting behavior should be identical)

// It is possible, although uncommon, for us to write to this file,
// drop the handle to it, and for it to have not been fully written to
// storage.
tmp_file.flush().await?;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the real fix of this issue

tmp_file
.seek(tokio::io::SeekFrom::Current(i64::try_from(offset)?))
.await?;
tmp_file.seek(tokio::io::SeekFrom::Start(offset)).await?;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Again, this isn't wrong, because we just opened the file, so it should be equivalent. However, IMO this version is less sketchy.

Copy link
Contributor

@wfchandler wfchandler left a comment

Choose a reason for hiding this comment

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

Thanks, @smklein, great job running this down. There was one change you made that I don't quite understand, but otherwise this looks good.

@@ -743,7 +758,7 @@ impl<'a> SupportBundleManager<'a> {
info!(log, "Bundle written successfully");
let metadata = SupportBundleMetadata {
support_bundle_id,
state: SupportBundleState::Complete,
state: SupportBundleState::Incomplete,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain this change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TL;DR this is basically an informational change that results in no behavioral changes, but it was a code smell.

  • Before we chunked support bundles, the status would return "has the bundle been created, and is it ready for usage"
  • We used "Complete" to indicate "you're good to use the bundle" and "incomplete" to mean "the bundle has not been fully written to durable storage yet"
  • When we switched to chunking behavior, this protocol changes a little bit. Nexus used the new "transfer + finalize" APIs, and would never infer that the bundle was ready from a call to "Transfer" alone
  • However, we didn't change that returned state from transfer. Even though bundles are never ready-to-use before finalize, we returned "Complete"
  • ... but this didn't matter, because Nexus was ignoring the returned state anyway.

So: It's more accurate to say "The bundle has not been finalized" during this transfer. Arguably we could remove this state from the internal transfer API altogether. But "Incomplete" is more accurate than "Complete"

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, makes sense.

Copy link
Contributor

@wfchandler wfchandler left a comment

Choose a reason for hiding this comment

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

Nothing further from me, thanks!

@@ -743,7 +758,7 @@ impl<'a> SupportBundleManager<'a> {
info!(log, "Bundle written successfully");
let metadata = SupportBundleMetadata {
support_bundle_id,
state: SupportBundleState::Complete,
state: SupportBundleState::Incomplete,
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks, makes sense.

@smklein smklein merged commit 62c33c8 into main Jul 29, 2025
16 checks passed
@smklein smklein deleted the collect-chunked branch July 29, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test failed in CI: test_collect_chunked
2 participants