Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add/set status when managing extensions #237

Merged
merged 10 commits into from
Apr 12, 2023
Merged

Add/set status when managing extensions #237

merged 10 commits into from
Apr 12, 2023

Conversation

ChuckHend
Copy link
Member

  • update status when changing or installing new extensions

@aws-amplify-us-east-1
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-237.d3q0v4ajtiq4fs.amplifyapp.com

Comment on lines +52 to +53
#[serde(default = "defaults::default_extensions")]
pub extensions: Vec<Extension>,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing the default here to the empty array, rather than making them optional. this puts status in line with how it is defined in spec

Comment on lines +138 to 142
let patch_status = json!({
"status": {"running": true}
});
patch_cdb_status_merge(&coredbs, &name, patch_status).await?;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should always set status.running here too. cc @shahadarsh , maybe we dont need it?

error!("Error updating CoreDB status: {:?}", e);
Action::requeue(Duration::from_secs(10))
})?;
patch_cdb_status_force(&coredbs, &name, patch_status).await?;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved this into a function

Comment on lines +303 to +330
pub async fn patch_cdb_status_force(
cdb: &Api<CoreDB>,
name: &str,
patch: serde_json::Value,
) -> Result<(), Action> {
let ps = PatchParams::apply("cntrlr").force();
let patch_status = Patch::Apply(patch);
let _o = cdb.patch_status(name, &ps, &patch_status).await.map_err(|e| {
error!("Error updating CoreDB status: {:?}", e);
Action::requeue(Duration::from_secs(10))
})?;
Ok(())
}

pub async fn patch_cdb_status_merge(
cdb: &Api<CoreDB>,
name: &str,
patch: serde_json::Value,
) -> Result<(), Action> {
let pp = PatchParams::default();
let patch_status = Patch::Merge(patch);
let _o = cdb.patch_status(name, &pp, &patch_status).await.map_err(|e| {
error!("Error updating CoreDB status: {:?}", e);
Action::requeue(Duration::from_secs(10))
})?;
Ok(())
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two patch helpers - one for the merge and one for the force

Comment on lines +384 to +394
'loc: for loc_desired in extension_desired.locations.clone() {
for loc_actual in extension_actual.locations.clone() {
if loc_desired.database == loc_actual.database {
// TODO: when we want to support version changes, this is where we would do it
if loc_desired.enabled != loc_actual.enabled {
debug!("desired: {:?}, actual: {:?}", extension_desired, extension_actual);
changed.push(extension_desired.clone());
break 'loc;
}
}
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fixes a bug where we'd continuously reconcile an extension when the description of the extension has changed. We have no way to change the description of an extension, but we do change whether they are enabled. Therefore, only consider it a "change" if the enable toggle has changed, rather than any attribute about the extension.

"status": {"extensionsUpdating": true}
});
// TODO: we should have better handling/behavior for when we fail to patch the status
let _ = patch_cdb_status_merge(cdb_api, name, status).await;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nhudson 👁️

@ChuckHend ChuckHend marked this pull request as ready for review April 12, 2023 17:17
@ChuckHend ChuckHend merged commit 5a3d929 into main Apr 12, 2023
@ChuckHend ChuckHend deleted the cor-613 branch April 12, 2023 18:23
sjmiller609 pushed a commit that referenced this pull request Dec 5, 2023
sjmiller609 pushed a commit that referenced this pull request Dec 5, 2023
* Add functionality to reconcile extensions for multiple pods

* add just macro to run telemetry with jaeger

* adding a few more minor changes

* adding name to debug message

* rework code, write unit tests

* fmt

* fix logging
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants