Skip to content
This repository has been archived by the owner on Nov 8, 2024. It is now read-only.

Commit

Permalink
More google groups error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
augustuswm committed Jan 26, 2024
1 parent bebd530 commit 24db0c3
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cio/src/gsuite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use gsuite_api::{
},
Client as GSuite,
};
use log::info;
use log::{info, warn};
use serde_json::Value;

use crate::{
Expand Down Expand Up @@ -325,6 +325,7 @@ pub async fn update_group_aliases(gsuite: &GSuite, g: &GSuiteGroup) -> Result<()
{
Ok(_) => (),
Err(e) => {
warn!("Received error response from Google Group alias update: {:?}", e);
if e.to_string().contains("Entity already exists") {
// Ignore the error.
continue;
Expand All @@ -346,10 +347,15 @@ pub async fn update_google_group_settings(db: &Database, group: &Group, company:
let email = format!("{}@{}", group.name, company.gsuite_domain);
let mut result = ggs.groups().get(google_groups_settings::types::Alt::Json, &email).await;
if result.is_err() {
warn!("First attempt to lookup Google Group failed: {:?}", result);
// Try again.
tokio::time::sleep(time::Duration::from_secs(1)).await;
result = ggs.groups().get(google_groups_settings::types::Alt::Json, &email).await;
}
if result.is_err() {
warn!("Second attempt to lookup Google Group failed: {:?}", result);
}

let mut settings = result?.body;

// Update the groups settings.
Expand All @@ -373,11 +379,17 @@ pub async fn update_google_group_settings(db: &Database, group: &Group, company:
.update(google_groups_settings::types::Alt::Json, &email, &settings)
.await;
if result2.is_err() {
warn!("First attempt to update Google Group failed: {:?}", result2);

// Try again.
tokio::time::sleep(time::Duration::from_secs(1)).await;
ggs.groups()
.update(google_groups_settings::types::Alt::Json, &email, &settings)
.await?;
.await
.map_err(|err| {
warn!("Second attempt to update Google Group failed: {:?}", err);
err
})?;
}

info!("updated gsuite groups settings {}", group.name);
Expand Down

0 comments on commit 24db0c3

Please sign in to comment.