Skip to content

Commit

Permalink
Search for main container
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidNix committed Sep 20, 2023
1 parent e67106b commit 368f482
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 10 additions & 1 deletion internal/fullnode/build_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func BuildPods(crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) ([]diff.Res
continue
}
if o.Image != "" {
pod.Spec.Containers[0].Image = o.Image
setMainContainerImage(pod, o.Image)
}
}
pod.Annotations[configChecksumAnnotation] = cksums[client.ObjectKeyFromObject(pod)]
Expand All @@ -39,6 +39,15 @@ func BuildPods(crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) ([]diff.Res
return pods, nil
}

func setMainContainerImage(pod *corev1.Pod, image string) {
for i := range pod.Spec.Containers {
if pod.Spec.Containers[i].Name == mainContainer {
pod.Spec.Containers[i].Image = image
return
}
}
}

func podCandidates(crd *cosmosv1.CosmosFullNode) map[string]struct{} {
candidates := make(map[string]struct{})
for _, v := range crd.Status.ScheduledSnapshotStatus {
Expand Down
7 changes: 5 additions & 2 deletions internal/fullnode/pod_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import (

var bufPool = sync.Pool{New: func() any { return new(bytes.Buffer) }}

const healthCheckPort = healthcheck.Port
const (
healthCheckPort = healthcheck.Port
mainContainer = "node"
)

// PodBuilder builds corev1.Pods
type PodBuilder struct {
Expand Down Expand Up @@ -65,7 +68,7 @@ func NewPodBuilder(crd *cosmosv1.CosmosFullNode) PodBuilder {
Containers: []corev1.Container{
// Main start container.
{
Name: "node",
Name: mainContainer,
Image: tpl.Image,
// The following is a useful hack if you need to inspect the PV.
//Command: []string{"/bin/sh"},
Expand Down

0 comments on commit 368f482

Please sign in to comment.