-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter duplicate events from ClusterGroup reconcile (#87)
- Enroll into unstable-runtime to control and reuse object streams from watches. - Reduce cache size by removing managed_fields - Set the finalizer on the ClusterGroup object to ensure deletion events are not missed, and object is recreated Signed-off-by: Danil-Grigorev <[email protected]>
- Loading branch information
1 parent
e925cdc
commit 11fb534
Showing
9 changed files
with
164 additions
and
43 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use crate::api::fleet_addon_config::FleetAddonConfig; | ||
use crate::api::fleet_clustergroup::ClusterGroup; | ||
use crate::Result; | ||
|
||
use kube::runtime::controller::Action; | ||
|
||
use std::sync::Arc; | ||
|
||
use super::controller::{patch, Context, FleetBundle, FleetController}; | ||
use super::{GroupSyncError, SyncError}; | ||
|
||
impl FleetBundle for ClusterGroup { | ||
// Applies finalizer on the existing ClusterGroup object, so the deletion event is not missed | ||
async fn sync(&self, ctx: Arc<Context>) -> Result<Action> { | ||
patch(ctx.clone(), self.clone()) | ||
.await | ||
.map_err(Into::<GroupSyncError>::into) | ||
.map_err(Into::<SyncError>::into)?; | ||
|
||
Ok(Action::await_change()) | ||
} | ||
} | ||
|
||
impl FleetController for ClusterGroup { | ||
type Bundle = ClusterGroup; | ||
|
||
async fn to_bundle( | ||
&self, | ||
_ctx: Arc<Context>, | ||
_config: &FleetAddonConfig, | ||
) -> Result<Self::Bundle> { | ||
Ok(self.clone()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,4 +68,5 @@ pub enum PatchError { | |
|
||
pub mod cluster; | ||
pub mod cluster_class; | ||
pub mod cluster_group; | ||
pub mod controller; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use kube::runtime::predicates; | ||
use kube::ResourceExt; | ||
|
||
pub fn generation_with_deletion(obj: &impl ResourceExt) -> Option<u64> { | ||
match obj.meta().deletion_timestamp { | ||
Some(_) => predicates::resource_version(obj), | ||
None => predicates::generation(obj), | ||
} | ||
} |