Skip to content

Commit

Permalink
feat: ability to disable in-sync healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
agouin committed Oct 8, 2024
1 parent f0d8cb8 commit 3c3c9f1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 29 deletions.
5 changes: 5 additions & 0 deletions api/v1/cosmosfullnode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,11 @@ type ServiceSpec struct {
// +optional
P2PTemplate ServiceOverridesSpec `json:"p2pTemplate"`

// Disables the health check requiring the instance to be
// in-sync with the chain before the pod is marked as ready.
// +optional
DisableSyncReadiness *bool `json:"disableSyncReadiness"`

// Overrides for the single RPC service.
// +optional
RPCTemplate ServiceOverridesSpec `json:"rpcTemplate"`
Expand Down
5 changes: 5 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 36 additions & 29 deletions internal/fullnode/pod_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,30 @@ func NewPodBuilder(crd *cosmosv1.CosmosFullNode) PodBuilder {
ImagePullPolicy: tpl.ImagePullPolicy,
WorkingDir: workDir,
},
// healthcheck sidecar
{
Name: "healthcheck",
// Available images: https://github.com/orgs/strangelove-ventures/packages?repo_name=cosmos-operator
// IMPORTANT: Must use v0.6.2 or later.
Image: "ghcr.io/strangelove-ventures/cosmos-operator:" + version.DockerTag(),
Command: []string{"/manager", "healthcheck"},
Ports: []corev1.ContainerPort{{ContainerPort: healthCheckPort, Protocol: corev1.ProtocolTCP}},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("5m"),
corev1.ResourceMemory: resource.MustParse("16Mi"),
},
},
ReadinessProbe: probes[1],
ImagePullPolicy: tpl.ImagePullPolicy,
},
},
},
}

if crd.Spec.Service.DisableSyncReadiness == nil || !*crd.Spec.Service.DisableSyncReadiness {
// healthcheck sidecar
pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{
Name: "sync-healthcheck",
// Available images: https://github.com/orgs/strangelove-ventures/packages?repo_name=cosmos-operator
// IMPORTANT: Must use v0.6.2 or later.
Image: "ghcr.io/strangelove-ventures/cosmos-operator:" + version.DockerTag(),
Command: []string{"/manager", "healthcheck"},
Ports: []corev1.ContainerPort{{ContainerPort: healthCheckPort, Protocol: corev1.ProtocolTCP}},
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("5m"),
corev1.ResourceMemory: resource.MustParse("16Mi"),
},
},
ReadinessProbe: probes[1],
ImagePullPolicy: tpl.ImagePullPolicy,
})
}

if len(crd.Spec.ChainSpec.Versions) > 0 {
// version check sidecar, runs on inverval in case the instance is halting for upgrade.
pod.Spec.Containers = append(pod.Spec.Containers, corev1.Container{
Expand Down Expand Up @@ -159,19 +162,23 @@ func podReadinessProbes(crd *cosmosv1.CosmosFullNode) []*corev1.Probe {
FailureThreshold: 5,
}

sidecarProbe := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/",
Port: intstr.FromInt(healthCheckPort),
Scheme: corev1.URISchemeHTTP,
var sidecarProbe *corev1.Probe

if crd.Spec.Service.DisableSyncReadiness == nil || !*crd.Spec.Service.DisableSyncReadiness {
sidecarProbe = &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/",
Port: intstr.FromInt(healthCheckPort),
Scheme: corev1.URISchemeHTTP,
},
},
},
InitialDelaySeconds: 1,
TimeoutSeconds: 10,
PeriodSeconds: 10,
SuccessThreshold: 1,
FailureThreshold: 3,
InitialDelaySeconds: 1,
TimeoutSeconds: 10,
PeriodSeconds: 10,
SuccessThreshold: 1,
FailureThreshold: 3,
}
}

return []*corev1.Probe{mainProbe, sidecarProbe}
Expand Down

0 comments on commit 3c3c9f1

Please sign in to comment.