Skip to content

Commit

Permalink
various small cleanup (openzfs#881)
Browse files Browse the repository at this point in the history
One change in behavior:  When the blob connectivity test succeeds, it
used to output a warning, which the customer can't do anything about.
This commit removes the warning.

```
 blob positive test
 test-connectivity-blob --bucket cloudburst-data-2 --azure-account dlpxdose --azure-key ...
-Connectivity test succeded with warning: has_retention unsupported for blob protocol
+Connectivity test succeeded.
```
  • Loading branch information
ahrens authored May 26, 2023
1 parent ab0dc65 commit 3b76abc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
3 changes: 2 additions & 1 deletion cmd/zfs_object_agent/util/src/cffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use std::fmt::Debug;
use std::fmt::Formatter;
use std::mem::align_of;
use std::mem::size_of;
use std::mem::size_of_val;
use std::ops::Deref;
use std::ptr;
use std::slice;
Expand Down Expand Up @@ -59,7 +60,7 @@ pub fn slice_to_bytes<T: Cffi>(struct_slice: &[T]) -> &[u8] {
unsafe {
slice::from_raw_parts(
struct_slice.as_ptr() as *const u8,
size_of::<T>() * struct_slice.len(),
size_of_val(struct_slice),
)
}
}
Expand Down
17 changes: 7 additions & 10 deletions cmd/zfs_object_agent/zettaobject/src/object_access/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,11 @@ impl From<&HttpError> for RequestError {
}
}

impl From<&HttpError> for OAError {
fn from(e: &HttpError) -> Self {
Self::RequestError(e.into())
}
}

impl From<azure_core::Error> for OAError {
fn from(e: azure_core::Error) -> Self {
match e.as_http_error() {
Some(http_error) => http_error.into(),
None => OAError::Other(e.into()),
Some(http_error) => Self::RequestError(http_error.into()),
None => Self::Other(e.into()),
}
}
}
Expand Down Expand Up @@ -256,6 +250,9 @@ impl ObjectAccessTrait for BlobObjectAccess {
.into_stream()
.try_fold(Vec::new(), |mut vec, response| async move {
vec.reserve(response.blob.properties.content_length.as_usize());
// ResponseBody.collect() doesn't preallocate a buffer of the total size,
// so using it would have the additional cost of reallocating the buffer
// as it grows.
response
.data
.try_fold(vec, |mut vec, b| async move {
Expand Down Expand Up @@ -284,7 +281,7 @@ impl ObjectAccessTrait for BlobObjectAccess {
// HTTP headers but before we have received the entire body. This occurs
// very rarely, and we simply retry immediately. See
// https://github.com/Azure/azure-sdk-for-rust/issues/1140
log::debug!("{msg}: retrying due to io error: {e}",);
debug!("{msg}: retrying due to io error: {e}",);
continue;
}
}
Expand Down Expand Up @@ -391,7 +388,7 @@ impl ObjectAccessTrait for BlobObjectAccess {
/// access retention policies. When that is implemented, we can properly check for retention.
#[async_backtrace::framed]
async fn has_retention(&self) -> Result<bool> {
Err(anyhow!("has_retention unsupported for blob protocol"))
Ok(false)
}

fn take_rate_limit_errors(&self) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion cmd/zfs_object_agent/zettaobject/src/reclaim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1184,7 +1184,7 @@ impl ReclaimComplete {

#[async_backtrace::framed]
pub async fn complete(self, txg: Txg, reclaim_info: &mut Reclaim) {
let mut reclaim_log = reclaim_info.get_pending_frees_log(self.best_log);
let reclaim_log = reclaim_info.get_pending_frees_log(self.best_log);
reclaim_log.pending_free_bytes -= self.freed_blocks_bytes;
let remaining_frees = self.frees_per_object.values().flatten();
build_new_frees(txg, reclaim_log, remaining_frees, self.frees_remainder).await;
Expand Down
8 changes: 3 additions & 5 deletions cmd/zfs_object_agent/zettaobject/src/test_connectivity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ async fn do_test_connectivity(object_access: &ObjectAccess) -> Result<Option<Str
.await
.map_err(|s| format!("unable to put object: {s}"))?;

if let Err(e) = object_access
object_access
.get_object(file.clone(), ObjectAccessOpType::MetadataGet)
.await
{
return Err(format!("unable to get object: {e}"));
}
.map_err(|s| format!("unable to get object: {s}"))?;

let objects = object_access
.try_list_objects(prefix, false)
Expand Down Expand Up @@ -107,7 +105,7 @@ async fn do_test_connectivity(object_access: &ObjectAccess) -> Result<Option<Str
match object_access.has_retention().await {
Ok(true) => Err("bucket has retention policy".to_string()),
Ok(false) => Ok(None),
Err(e) => Ok(Some(e.to_string())),
Err(e) => Ok(Some(format!("error getting retention policy: {e}"))),
}
}

Expand Down

0 comments on commit 3b76abc

Please sign in to comment.