Skip to content

Commit c7b9f67

Browse files
ugiordanclaude
andcommitted
fix: handle IsServerTimeout in TLS profile resolution
StatusReasonServerTimeout is a distinct Kubernetes error from StatusReasonTimeout. Without handling it, a server-side API timeout during TLS profile fetch causes the operator to fail to start instead of falling back to Intermediate defaults. Signed-off-by: Ugo Giordano <ugiordan@redhat.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 081b2fd commit c7b9f67

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

infra/feast-operator/cmd/main.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,10 @@ func main() {
139139
os.Exit(1)
140140
}
141141

142-
bootstrapCtx, cancelBootstrap := context.WithTimeout(context.Background(), 10*time.Second)
143-
defer cancelBootstrap()
144-
145142
tlsProfileFetched := false
146-
tlsProfile, err := tlspkg.FetchAPIServerTLSProfile(bootstrapCtx, bootstrapClient)
143+
profileCtx, cancelProfile := context.WithTimeout(context.Background(), 10*time.Second)
144+
defer cancelProfile()
145+
tlsProfile, err := tlspkg.FetchAPIServerTLSProfile(profileCtx, bootstrapClient)
147146
if err != nil {
148147
switch {
149148
case apimeta.IsNoMatchError(err):
@@ -152,10 +151,11 @@ func main() {
152151
setupLog.Info("APIServer resource not found, using Intermediate defaults")
153152
case apierrors.IsServiceUnavailable(err),
154153
apierrors.IsTimeout(err),
154+
apierrors.IsServerTimeout(err),
155155
apierrors.IsTooManyRequests(err),
156156
errors.Is(err, context.DeadlineExceeded):
157157
setupLog.Info("Transient API error reading TLS profile, using Intermediate defaults", "error", err)
158-
tlsProfileFetched = true // watcher self-heals when the API recovers
158+
tlsProfileFetched = true
159159
default:
160160
setupLog.Error(err, "unable to read APIServer TLS profile, refusing to start with unknown TLS posture")
161161
os.Exit(1)
@@ -170,11 +170,15 @@ func main() {
170170
}
171171
tlsOpts = append(tlsOpts, tlsConfigFn)
172172

173-
tlsAdherence, err := tlspkg.FetchAPIServerTLSAdherencePolicy(bootstrapCtx, bootstrapClient)
173+
tlsAdherenceFetched := false
174+
adherenceCtx, cancelAdherence := context.WithTimeout(context.Background(), 10*time.Second)
175+
defer cancelAdherence()
176+
tlsAdherence, err := tlspkg.FetchAPIServerTLSAdherencePolicy(adherenceCtx, bootstrapClient)
174177
if err != nil {
175178
setupLog.Info("unable to fetch TLS adherence policy, watcher will retry", "error", err)
179+
} else {
180+
tlsAdherenceFetched = true
176181
}
177-
tlsAdherenceFetched := true
178182

179183
tlsOpts = append(tlsOpts, func(c *tls.Config) {
180184
c.NextProtos = []string{"h2", "http/1.1"}

0 commit comments

Comments
 (0)