-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24064 from nvartolomei/nv/manual-backport-24000-v…
…24.1.x-504 [v24.1.x] cleanup tiered storage temporary cache file if exceptions are thrown during download
- Loading branch information
Showing
4 changed files
with
123 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2024 Redpanda Data, Inc. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.md | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0 | ||
|
||
#pragma once | ||
|
||
#include "base/seastarx.h" | ||
|
||
#include <seastar/core/future.hh> | ||
#include <seastar/core/iostream.hh> | ||
#include <seastar/core/temporary_buffer.hh> | ||
|
||
namespace tests { | ||
|
||
/// Create an input stream that throws an exception on first interaction. | ||
template<class Err> | ||
ss::input_stream<char> make_throwing_stream(Err err) { | ||
struct throwing_stream final : ss::data_source_impl { | ||
explicit throwing_stream(Err e) | ||
: _err(std::move(e)) {} | ||
|
||
ss::future<ss::temporary_buffer<char>> skip(uint64_t) final { | ||
return get(); | ||
} | ||
|
||
ss::future<ss::temporary_buffer<char>> get() final { | ||
return ss::make_exception_future<ss::temporary_buffer<char>>( | ||
std::move(_err)); | ||
} | ||
|
||
Err _err; | ||
}; | ||
auto ds = ss::data_source(std::make_unique<throwing_stream>(err)); | ||
return ss::input_stream<char>(std::move(ds)); | ||
} | ||
|
||
} // namespace tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters