Wait for Minio to be reachable before attempting to update bucket configuration
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Pierre HUBERT 2024-12-17 21:16:03 +01:00
parent 152aa3622e
commit 356fca6f1f

View File

@ -10,6 +10,7 @@ use minio_operator::crd::{MinioBucket, MinioInstance};
use minio_operator::minio::{MinioService, MinioUser};
use minio_operator::secrets::{create_secret, read_secret_str};
use std::collections::BTreeMap;
use std::time::Duration;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
@ -54,6 +55,17 @@ async fn apply_bucket(b: &MinioBucket, client: &Client) -> anyhow::Result<()> {
secret_key: read_secret_str(&instance_secret, SECRET_MINIO_INSTANCE_SECRET_KEY)?,
};
// Check if Minio is responding
let mut ready_count = 0;
while !service.is_ready().await {
if ready_count > 5 {
panic!("Minio is unreachable!");
}
ready_count += 1;
tokio::time::sleep(Duration::from_millis(200)).await;
log::warn!("Minio is not responding yet, will try again to connect soon...");
}
// Get user key & password
let user_secret = match secrets.get_opt(&b.spec.secret).await? {
Some(s) => s,