Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/google.golang.org/grpc…
Browse files Browse the repository at this point in the history
…-1.57.1
  • Loading branch information
agouin committed Oct 26, 2023
2 parents 340c166 + c43035d commit 4be2950
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 11 deletions.
3 changes: 3 additions & 0 deletions api/v1/cosmosfullnode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ type PodSpec struct {

// Image is the docker reference in "repository:tag" format. E.g. busybox:latest.
// This is for the main container running the chain process.
// Note: for granular control over which images are applied at certain block heights,
// use spec.chain.versions instead.
// +kubebuilder:validation:MinLength:=1
// +optional
Image string `json:"image"`

// Image pull policy.
Expand Down
8 changes: 4 additions & 4 deletions config/crd/bases/cosmos.strange.love_cosmosfullnodes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2616,9 +2616,11 @@ spec:
type: object
type: array
image:
description: Image is the docker reference in "repository:tag"
description: 'Image is the docker reference in "repository:tag"
format. E.g. busybox:latest. This is for the main container
running the chain process.
running the chain process. Note: for granular control over which
images are applied at certain block heights, use spec.chain.versions
instead.'
minLength: 1
type: string
imagePullPolicy:
Expand Down Expand Up @@ -5595,8 +5597,6 @@ spec:
- name
type: object
type: array
required:
- image
type: object
replicas:
description: Number of replicas to create. Individual replicas have
Expand Down
14 changes: 10 additions & 4 deletions internal/fullnode/build_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ func BuildPods(crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) ([]diff.Res
image = version.Image
}
if image != "" {
setMainContainerImage(pod, image)
setChainContainerImage(pod, image)
}
}
if o, ok := overrides[pod.Name]; ok {
if o.DisableStrategy != nil {
continue
}
if o.Image != "" {
setMainContainerImage(pod, o.Image)
setChainContainerImage(pod, o.Image)
}
}
pod.Annotations[configChecksumAnnotation] = cksums[client.ObjectKeyFromObject(pod)]
Expand All @@ -57,11 +57,17 @@ func BuildPods(crd *cosmosv1.CosmosFullNode, cksums ConfigChecksums) ([]diff.Res
return pods, nil
}

func setMainContainerImage(pod *corev1.Pod, image string) {
func setChainContainerImage(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
break
}
}
for i := range pod.Spec.InitContainers {
if pod.Spec.InitContainers[i].Name == chainInitContainer {
pod.Spec.InitContainers[i].Image = image
break
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions internal/fullnode/pod_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (
var bufPool = sync.Pool{New: func() any { return new(bytes.Buffer) }}

const (
healthCheckPort = healthcheck.Port
mainContainer = "node"
healthCheckPort = healthcheck.Port
mainContainer = "node"
chainInitContainer = "chain-init"
)

// PodBuilder builds corev1.Pods
Expand Down Expand Up @@ -330,7 +331,7 @@ func initContainers(crd *cosmosv1.CosmosFullNode, moniker string) []corev1.Conta
WorkingDir: workDir,
},
{
Name: "chain-init",
Name: chainInitContainer,
Image: tpl.Image,
Command: []string{"sh"},
Args: []string{"-c",
Expand Down
1 change: 1 addition & 0 deletions internal/fullnode/pod_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ func recalculatePodRevision(pod *corev1.Pod, ordinal int) {
func newPodWithNewImage(pod *corev1.Pod) {
pod.DeletionTimestamp = nil
pod.Spec.Containers[0].Image = "new-image"
pod.Spec.InitContainers[1].Image = "new-image"
}

func deletedPod(pod *corev1.Pod) {
Expand Down

0 comments on commit 4be2950

Please sign in to comment.