Skip to content

[release-v1.42] Keep typhaDeployment overrides on the non-cluster-host Typha - #5368

Merged
caseydavenport merged 3 commits into
tigera:release-v1.42from
caseydavenport:casey-port-14247-release-v1.42
Oct 29, 2026
Merged

caseydavenport merged 3 commits into
tigera:release-v1.42from
caseydavenport:casey-port-14247-release-v1.42

Conversation

@caseydavenport

@caseydavenport caseydavenport commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Description

This PR fixes the non-cluster-host Typha deployment (calico-typha-noncluster-host) dropping the calico-typha container overrides set in the Installation's spec.typhaDeployment, and having its pods rejected when certificate management is enabled. The operator copies calico-typha after applying the overrides, but then replaced the copy's container with a freshly built one, so resource requests and limits never reached it and it rendered with no resources at all.

  • Container rebuild. The non-cluster-host container now starts from the overridden calico-typha container and swaps only what has to differ: the env vars, the non-cluster-host certificate mounts, and the probes (which drop the host). Affinity is still cleared and host networking still off on the copy, as before, since those overrides don't apply to a pod-networked Typha.
  • Shutdown timeout. The rebuild also reset TYPHA_SHUTDOWNTIMEOUTSECS to the 300 second default while the pod kept the overridden termination grace period, so Typha paced client disconnects for a different grace period than kubelet enforced. The existing post-override fix-up now runs on the copy too, so the timeout and progress deadline follow the overridden grace period.
  • Certificate init container. With certificate management on, the copy kept the cluster Typha's typha-certs-key-cert-provisioner init container, which mounts a volume the copy doesn't have. The API server rejected its pods, so non-cluster hosts had no Typha. The copy now gets its own provisioner for the non-cluster-host certificate.
  • Testing. One new render test checks that calico-typha resources and grace period overrides reach the non-cluster-host deployment while affinity is still cleared. Another, with certificate management on, checks that every volume mount in both Typha pods names a volume the pod defines. Both failed before their fixes, and the full pkg/render suite passes. Not tried on a real cluster.

PR 14150 (overrides after variant modifiers) fixed this class of bug in newer operator versions. On this branch every other component applies its overrides as the last render step, so the non-cluster-host Typha is the one place it shows up here.

AI assistance: Claude Code traced the bugs and wrote the fixes and the tests; I reviewed the change.

By opening this PR you take responsibility for every line in it, and you agree to explain the change yourself during review rather than routing review comments back through an agent. See AI_POLICY.md.

Release Note

Fixes the non-cluster-host Typha deployment ignoring the calico-typha container resources and terminationGracePeriodSeconds set in the Installation's spec.typhaDeployment, and having its pods rejected when certificate management is enabled.

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.
Agent context

Decisions

  • typhaContainerNonClusterHost() now takes the already-overridden calico-typha container as an argument instead of calling typhaContainer() itself, then replaces Env, VolumeMounts, and the liveness and readiness probes (built with an empty host).
  • typhaDeployment() swaps the container by name (TyphaContainerName) rather than replacing the whole Containers slice, then calls applyPostOverrideFixUps() on the non-cluster-host deployment so TYPHA_SHUTDOWNTIMEOUTSECS and the progress deadline are recomputed from the overridden terminationGracePeriodSeconds.
  • When the non-cluster-host keypair uses certificate management, typhaDeployment() replaces the copy's init container whose name matches the cluster Typha keypair's provisioner with initContainerNonClusterHost(), which builds typha-certs-noncluster-host-key-cert-provisioner (SECRET_NAME typha-certs-noncluster-host, mounting the typha-certs-noncluster-host volume). Other init containers are left alone. The replacement keeps the replaced init container's security context and resources, so a typha-certs-key-cert-provisioner resources override in spec.typhaDeployment still applies.

Constraints and gotchas

  • Affinity = nil and HostNetwork = false on the non-cluster-host copy are intentional: the cluster Typha's affinity and host networking overrides must not apply to the pod-networked Typha.
  • PR 14150 (overrides after variant modifiers) fixed the same class of bug in newer operator versions. On release-v1.42 every other component applies overrides as its last render step, so only the non-cluster-host Typha was affected here.
  • The copy's volumes are only the trusted CA bundle and typha-certs-noncluster-host, so the cluster provisioner's typha-certs mount pointed at a missing volume. Even if the pod were accepted, nothing would request the non-cluster-host certificate into its volume. Newer operator versions already render the non-cluster-host provisioner this way.

Verification

  • The overrides test failed before the fix with {Limits: nil, Requests: nil} for the container resources.
  • The certificate management test failed on the previous head with calico-typha-noncluster-host container typha-certs-key-cert-provisioner mounts a volume the pod does not define (the pod's volumes were tigera-ca-bundle and typha-certs-noncluster-host). Disabling the resources carry-over also makes it fail.
  • make ut UT_DIR=./pkg/render passes, with the top-level render suite at 554 of 554 specs. Not run on a real cluster.

Code map

  • pkg/render/typha.go: typhaDeployment (non-cluster-host block, including the init container swap), typhaContainerNonClusterHost, initContainerNonClusterHost (builds the non-cluster-host key-cert-provisioner from the replaced one's security context and resources).
  • pkg/render/typha_test.go: "should carry typhaDeployment overrides onto the non-cluster-host Typha deployment" and "should give the non-cluster-host Typha its own key-cert-provisioner when certificate management is enabled".

@caseydavenport caseydavenport added this to the v1.42.7 milestone Oct 27, 2026
@caseydavenport caseydavenport added kind/bug Something isn't working enterprise Feature applies to enterprise only release-note-required docs-not-required labels Oct 27, 2026
@caseydavenport
caseydavenport requested a review from a team as a code owner October 27, 2026 20:02
@danudey danudey modified the milestones: v1.42.7, v1.42.8 Oct 27, 2026
@caseydavenport
caseydavenport merged commit 53c489e into tigera:release-v1.42 Oct 29, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-not-required enterprise Feature applies to enterprise only kind/bug Something isn't working release-note-required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants