-
Notifications
You must be signed in to change notification settings - Fork 41
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
cleanup brs when brupop is removed from the node. #235
Conversation
2cb2f08
to
00e817a
Compare
Push above removing changes on apisever. Since controller has privilege to delete cluster resources, we don't need add deletion to apiserver. |
controller/src/main.rs
Outdated
}, | ||
_ = node_drainer => { | ||
event!(Level::ERROR, "node reflector drained"); | ||
return Err(controller_error::Error::KubernetesWatcherFailed {object: "node".to_string()}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason returning Err here? The Result<()> in main is actually not parsed by any other handler. If this is for log purpose, does it make sense to log in the event!
rather than return Err?
controller/src/controller.rs
Outdated
@@ -2,12 +2,16 @@ use super::{ | |||
metrics::{BrupopControllerMetrics, BrupopHostsData}, | |||
statemachine::determine_next_node_spec, | |||
}; | |||
use k8s_openapi::api::core::v1::Node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Would you mind sort the external import in alphabetical order?
controller/src/controller.rs
Outdated
.map(|arc_brs| (**arc_brs).clone()) | ||
.collect() | ||
} | ||
|
||
/// Returns the set of BottlerocketShadow objects which is currently being acted upon. | ||
/// | ||
/// Nodes are being acted upon if they are not in the `WaitingForUpdate` state, or if their desired state does | ||
/// not match their current state. | ||
#[instrument(skip(self))] | ||
fn active_node_set(&self) -> BTreeMap<String, BottlerocketShadow> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe active_brs_set
would be more clear?
controller/src/controller.rs
Outdated
@@ -111,7 +133,7 @@ impl<T: BottlerocketShadowClient> BrupopController<T> { | |||
/// set during the next iteration of the controller's event loop. | |||
#[instrument(skip(self))] | |||
async fn find_and_update_ready_node(&self) -> Result<Option<BottlerocketShadow>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, may be find_and_update_ready_brs
?
@@ -205,6 +264,11 @@ impl<T: BottlerocketShadowClient> BrupopController<T> { | |||
} | |||
} | |||
|
|||
// Cleanup BRS when the operator is removed from a node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering if it would be better to add more explanation here to illustrate that even the above steps moved a invalid Brs to active, the clean up would catch later here.
controller/src/controller.rs
Outdated
|
||
for unlabeled_node in unlabeled_nodes.drain(..) { | ||
let associated_bottlerocketshadow = brs_name_from_node_name(&unlabeled_node.name()); | ||
if brss |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any use for BottlerocketShadow
when deleting the shadow. Does it make sense to get the BottlerocketShadow's name in HashSet
to avoid iterating on all of the brss
for each unlabeld_node?
controller/src/controller.rs
Outdated
) -> Result<()> { | ||
let mut unlabeled_nodes = find_unlabeled_nodes(nodes); | ||
|
||
for unlabeled_node in unlabeled_nodes.drain(..) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if I understand correctly, the drain()
actually take the ownership for the unlabeld_nodes
, but in this use case we only need the reference for the unlabled_node.name()
, does it make sense to use reference for unlabeled_nodes
? Or is there any reason to use drain
here?
0c89293
to
b0b4489
Compare
b0b4489
to
b4bdb8f
Compare
Currently we require users to manually clean up the Custom Resources if they choose to delete only the updater-interface-version label. This change would help on automatically cleaning up BRS if users remove brupop(label) from corresponding node.
b4bdb8f
to
d17ad4c
Compare
self.brs_reader | ||
.state() | ||
.iter() | ||
.map(|arc_brs| (**arc_brs).clone()) | ||
.collect() | ||
} | ||
|
||
/// Returns a list of all bottlerocket nodes in the cluster. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: s/bottlerocket/Bottlerocket
&DeleteParams::default(), | ||
) | ||
.await | ||
.context(controllerclient_error::DeleteNode)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to log an event after the node is deleted?
Issue number:
#107
Description of changes:
Testing done:
Method: Run brupop integration test. Remove brupop label from nodes, and then confirm if associated brs has been removed.
Test with three scenarios
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.