Skip to content

Commit 49a8522

Browse files
authored
refactor: skip redundant dynamic object change detection (#946)
* refactor: remove redundant `has_dynamic_object_changed` calls * test: remove mock expectation to call has_dynamic_object_changed
1 parent eafbd32 commit 49a8522

File tree

2 files changed

+0
-45
lines changed

2 files changed

+0
-45
lines changed

agent-control/src/sub_agent/health/k8s/helm_release.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -154,23 +154,6 @@ impl HealthChecker for K8sHealthFluxHelmRelease {
154154
HealthCheckerError::Generic("HelmRelease data is not an object".to_string())
155155
})?;
156156

157-
// Check if the HelmRelease is properly updated: it should reflect the agent's configuration
158-
if self
159-
.k8s_client
160-
.has_dynamic_object_changed(&self.k8s_object)?
161-
{
162-
return Ok(HealthWithStartTime::from_unhealthy(
163-
Unhealthy::new(
164-
String::default(),
165-
format!(
166-
"HelmRelease '{}' does not match the latest agent configuration",
167-
&self.name,
168-
),
169-
),
170-
self.start_time,
171-
));
172-
}
173-
174157
let status = self.get_status(helm_release_data)?;
175158
let conditions = self.get_status_conditions(&status)?;
176159

@@ -207,15 +190,6 @@ pub mod tests {
207190
fn(&mut MockSyncK8sClient),
208191
);
209192
let test_cases : Vec<TestCase> = vec![
210-
(
211-
"Helm release unhealthy when the helm-release object should change",
212-
Ok(Unhealthy::new(String::default(),"HelmRelease 'example-release' does not match the latest agent configuration".to_string()).into()),
213-
|mock: &mut MockSyncK8sClient| {
214-
mock.expect_get_dynamic_object()
215-
.returning(|_,_| Ok(Some(Arc::new(dynamic_object()))));
216-
mock.expect_has_dynamic_object_changed().times(1).returning(|_| Ok(true));
217-
},
218-
),
219193
(
220194
"Helm release healthy when ready and status true",
221195
Ok(Healthy::default().into()),
@@ -337,7 +311,5 @@ pub mod tests {
337311
}),
338312
})))
339313
});
340-
mock.expect_has_dynamic_object_changed()
341-
.returning(|_| Ok(false));
342314
}
343315
}

agent-control/src/sub_agent/health/k8s/instrumentation.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -149,23 +149,6 @@ impl HealthChecker for K8sHealthNRInstrumentation {
149149
HealthCheckerError::Generic("instrumentation CR data is not an object".to_string())
150150
})?;
151151

152-
// Check if the instrumentation is properly updated: it should reflect the agent's configuration
153-
if self
154-
.k8s_client
155-
.has_dynamic_object_changed(&self.k8s_object)?
156-
{
157-
return Ok(HealthWithStartTime::from_unhealthy(
158-
Unhealthy::new(
159-
String::default(),
160-
format!(
161-
"instrumentation CR '{}' does not match the latest agent configuration",
162-
&self.name,
163-
),
164-
),
165-
self.start_time,
166-
));
167-
}
168-
169152
let status = instrumentation_data.get("status").cloned().ok_or_else(|| {
170153
HealthCheckerError::Generic("instrumentation status could not be retrieved".to_string())
171154
})?;

0 commit comments

Comments
 (0)