Skip to content

Commit edcc484

Browse files
feat(split_namespace): follow up changes (#1414)
1 parent f8efe89 commit edcc484

File tree

8 files changed

+11
-20
lines changed

8 files changed

+11
-20
lines changed

agent-control/src/agent_control/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,7 @@ k8s:
500500

501501
let k8s = config.k8s.unwrap();
502502

503+
assert_eq!(k8s.namespace_agents, "some-namespace-agents");
503504
assert_eq!(k8s.cluster_name, "some-cluster");
504505
assert_eq!(k8s.namespace, "some-namespace");
505506
}

agent-control/src/agent_control/resource_cleaner/k8s_garbage_collector.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl K8sGarbageCollector {
127127
let labels = obj_meta.labels.as_ref().unwrap_or(&empty_map);
128128

129129
// We delete resources only if they are managed by Agent Control
130-
if !labels::is_managed_by_agentcontrol(labels) {
130+
if !labels::is_managed_by_agent_control(labels) {
131131
return Ok(false);
132132
}
133133

@@ -146,11 +146,7 @@ impl K8sGarbageCollector {
146146
}
147147

148148
impl ResourceCleaner for K8sGarbageCollector {
149-
fn clean(
150-
&self,
151-
id: &AgentID,
152-
agent_type_id: &AgentTypeID,
153-
) -> Result<(), super::ResourceCleanerError> {
149+
fn clean(&self, id: &AgentID, agent_type_id: &AgentTypeID) -> Result<(), ResourceCleanerError> {
154150
// Call the collect method to perform garbage collection.
155151
self.collect(id, agent_type_id)?;
156152
Ok(())
@@ -195,7 +191,7 @@ impl K8sGarbageCollectorMode<'_> {
195191
if let Some(agent_type_id) = agent_identities.get(agent_id) {
196192
let annotated_agent_type_id = Self::retrieve_annotated_agent_type_id(obj_meta)?;
197193
// Check if the agent type is different from the one in the config.
198-
// This is to support the case where the agent id exists in the config
194+
// This is to support the case where the agent id exists in the config,
199195
// but it's a different agent type. See PR#655 for some details.
200196
Ok(&annotated_agent_type_id != agent_type_id)
201197
} else {

agent-control/src/flags.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub enum InitError {
4545
pub enum Command {
4646
/// Normal operation requested. Get the required config and continue.
4747
InitAgentControl(AgentControlRunConfig, Vec<TracingGuardBox>),
48-
/// Do an "one-shot" operation and exit successfully.
48+
/// Do a "one-shot" operation and exit successfully.
4949
/// In the future, many different operations could be added here.
5050
OneShot(OneShotCommand),
5151
}
@@ -143,7 +143,7 @@ impl Flags {
143143

144144
k8s_config: match mode {
145145
// This config is not used on the OnHost environment, a blank config is used.
146-
// K8sConfig has not default since cluster_name is a required.
146+
// K8sConfig has not "default" since cluster_name is a required.
147147
Environment::OnHost => K8sConfig::default(),
148148
Environment::K8s => agent_control_config.k8s.ok_or(InitError::K8sConfig())?,
149149
},

agent-control/src/k8s/client.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,13 +537,8 @@ pub(crate) mod tests {
537537
let config = Config::new(Uri::try_from("https://localhost.com").unwrap());
538538
let msg =
539539
"looks like kube-rs has revisit the timeout, see [DEFAULT_CLIENT_TIMEOUT] for details.";
540-
assert_eq!(config.read_timeout, Some(DEFAULT_CLIENT_TIMEOUT), "{}", msg);
541-
assert_eq!(
542-
config.write_timeout,
543-
Some(DEFAULT_CLIENT_TIMEOUT),
544-
"{}",
545-
msg
546-
);
540+
assert_eq!(config.read_timeout, Some(DEFAULT_CLIENT_TIMEOUT), "{msg}");
541+
assert_eq!(config.write_timeout, Some(DEFAULT_CLIENT_TIMEOUT), "{msg}");
547542
}
548543

549544
#[tokio::test]

agent-control/src/k8s/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub enum K8sError {
2828
#[error("the name of the resource is missing")]
2929
MissingResourceName,
3030

31-
#[error("the Namespace of the resource is missing")]
31+
#[error("the namespace of the resource is missing")]
3232
MissingResourceNamespace,
3333

3434
#[error("{0} does not have .metadata.name")]

agent-control/src/k8s/labels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Labels {
5353
}
5454

5555
/// returns true if labels indicates that is managed by the agentControl
56-
pub fn is_managed_by_agentcontrol(labels: &BTreeMap<String, String>) -> bool {
56+
pub fn is_managed_by_agent_control(labels: &BTreeMap<String, String>) -> bool {
5757
labels
5858
.get(MANAGED_BY_KEY)
5959
.is_some_and(|v| v == MANAGED_BY_VAL)

agent-control/src/k8s/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ pub mod tests {
240240
impl TestCase {
241241
fn run(self) {
242242
// As we cannot control foreign errors (these errors come from the standard library) we simply test
243-
// that it fails but we do not need to know which error.
243+
// that it fails, but we do not need to know which error.
244244
let _ = IntOrPercentage::try_from(self.int_or_string).inspect(|ok| {
245245
panic!(
246246
"Test case '{}' should error and did not. Value returned: {}",

agent-control/tests/common/agent_control.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ pub fn start_agent_control_with_custom_config(
4646

4747
k8s_config: match mode {
4848
// This config is not used on the OnHost environment, a blank config is used.
49-
// K8sConfig has not default since cluster_name is a required.
5049
Environment::OnHost => K8sConfig::default(),
5150
Environment::K8s => {
5251
let mut cfg = agent_control_config

0 commit comments

Comments
 (0)