Skip to content

Commit

Permalink
feat(csi-driver): add expansion logs
Browse files Browse the repository at this point in the history
Signed-off-by: Niladri Halder <niladri.halder26@gmail.com>
  • Loading branch information
niladrih committed Mar 1, 2024
1 parent 4fcc8a8 commit 138f119
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 6 additions & 1 deletion control-plane/csi-driver/src/bin/controller/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use utils::{CREATED_BY_KEY, DSP_OPERATOR};
use regex::Regex;
use std::{collections::HashMap, str::FromStr};
use tonic::{Request, Response, Status};
use tracing::{debug, error, instrument, trace, warn};
use tracing::{debug, error, info, instrument, trace, warn};
use uuid::Uuid;
use volume_capability::AccessType;

Expand Down Expand Up @@ -981,6 +981,7 @@ impl rpc::csi::controller_server::Controller for CsiControllerSvc {
request: tonic::Request<ControllerExpandVolumeRequest>,
) -> Result<tonic::Response<ControllerExpandVolumeResponse>, tonic::Status> {
let request = request.into_inner();
info!("Volume expansion request: {:?}", &request);

let vol_uuid = Uuid::parse_str(&request.volume_id).map_err(|error| {
Status::invalid_argument(format!(
Expand Down Expand Up @@ -1020,6 +1021,10 @@ impl rpc::csi::controller_server::Controller for CsiControllerSvc {
error => Status::from(error),
})?;

info!(
size_bytes = requested_size,
"Expansion succeeded for volume {}", &vol_uuid
);
Ok(tonic::Response::new(ControllerExpandVolumeResponse {
capacity_bytes: vol.spec.size as i64,
node_expansion_required,
Expand Down
16 changes: 14 additions & 2 deletions control-plane/csi-driver/src/bin/node/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ impl node_server::Node for Node {
//===============================CsiAccessType=============================================

let request = request.into_inner();
info!("Volume expansion request: {:?}", &request);

let vol_uuid = Uuid::parse_str(request.volume_id.as_str()).map_err(|error| {
failure!(
Expand Down Expand Up @@ -562,10 +563,17 @@ impl node_server::Node for Node {
// filesystem identification part.
let filesystem_handle = match CsiAccessType::from(&request.volume_capability) {
// volume_capability AccessType says this is not a 'Mount' type. Nothing to do.
CsiAccessType::NotAFilesystem => return success_result,
CsiAccessType::NotAFilesystem => {
info!(
"Filesystem expansion not required as volume {vol_uuid} \
is not a Filesystem type volume",
);
return success_result;
}
// volume_capability says that the filesystem is something we don't know about.
CsiAccessType::UnsupportedFilesystem(fs_err) => {
return Err(Status::invalid_argument(fs_err))
error!("Cannot expand filesystem: {}", &fs_err);
return Err(Status::invalid_argument(fs_err));
}
// volume_capability has identified a supported filesystem 🎉.
CsiAccessType::SupportedFilesystem(fs_type) => fs_type,
Expand Down Expand Up @@ -595,6 +603,10 @@ impl node_server::Node for Node {
.await
.map_err(|err| failure!(Code::Internal, "{}", err))?;

info!(
size_bytes = required_bytes,
"Expansion succeeded for volume {}", &vol_uuid
);
success_result
}

Expand Down

0 comments on commit 138f119

Please sign in to comment.