Skip to content

Commit

Permalink
More logs and fix a minor typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Goutham Kannan committed Dec 5, 2023
1 parent cd46c6b commit 83aaccb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Welcome to the real world.

At MX we needed to run a job after a deployment successfully rolled out.
The primary use case was running migrations after a deploy.
We tried using ArgoCD hooks to run those wouldn't wait for a deployment, and we had to delete the job before we could re-run after a deploy, meaning if it was a long running migration, like creating an index, it would be terminated half way through execution.
We tried using ArgoCD hooks to run those wouldn't wait for a deployment, and we had to delete the job before we could re-run after a deploy, meaning if it was a long-running migration, like creating an index, it would be terminated halfway through execution.
Not good.
We looked at other operators but couldn't find anything simple that we could run to solve this problem, so we created docbot.

Expand Down
4 changes: 2 additions & 2 deletions docbot-controller/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ impl DeploymentPodTemplateHashCache {
.metadata
.namespace
.clone()
.expect("must have a name"),
.expect("must have a namespace"),
deployment
.metadata
.name
.clone()
.expect("must have a namespace"),
.expect("must have a name"),
);

if let Some(hash) = deployment.pod_template_hash() {
Expand Down
17 changes: 14 additions & 3 deletions docbot-crd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ impl DeploymentHook {
template: Some(template.clone()),
});
}

// Otherwise use the name to look it up via the k9s api.
// Otherwise use the name to look it up via the k8s api.
let pod_template_api: Api<PodTemplate> = Api::namespaced(
client,
&self
Expand All @@ -75,7 +74,19 @@ impl DeploymentHook {
);

if let Some(ref name) = self.spec.template.name {
return Ok(pod_template_api.get(&name).await?);
println!("Debug: asking k8s the podtemplate for {}", name);
let specific_pod_template = pod_template_api.get(&name).await?;
// Print containers and their images
if let Some(template) = &specific_pod_template.template {
if let Some(pod_spec) = &template.spec {
for container in &pod_spec.containers {
println!("Debug: Container Image frome k8s api {} : {:?}",container.name, container.image);
}
}
} else {
println!("Debug: No PodTemplate spec found for '{}'", name);
}
return Ok(specific_pod_template);
}

Err(format!(
Expand Down

0 comments on commit 83aaccb

Please sign in to comment.