Skip to content

Commit 880800c

Browse files
authored
[Feature] Fix Gateway Probes with Auth Enabled (#1923)
1 parent d017eea commit 880800c

File tree

7 files changed

+94
-1
lines changed

7 files changed

+94
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- (Feature) Manual Upgrade Mode
1111
- (Feature) (Platform) SchedulerV2 Defaults Revert
1212
- (Bugfix) Enable Probes for Single & Gateway
13+
- (Bugfix) Fix Gateway Probes with Auth Enabled
1314

1415
## [1.2.49](https://github.com/arangodb/kube-arangodb/tree/1.2.49) (2025-06-17)
1516
- (Maintenance) Optimize go.mod

cmd/lifecycle.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ func cmdLifecyclePreStopRunFinalizer(cmd *cobra.Command, args []string) {
129129
logger.Err(err).Fatal("Too many recent errors")
130130
return
131131
}
132+
} else if p.DeletionTimestamp == nil {
133+
// We are just restarting, no need for the finalizer wait
134+
return
132135
} else {
133136
// We got our pod
134137
finalizerCount := len(p.GetFinalizers())

pkg/deployment/resources/gateway/gateway_config_destination.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ type ConfigDestination struct {
7272

7373
AuthExtension *ConfigAuthZExtension `json:"authExtension,omitempty"`
7474

75+
HealthChecks ConfigDestinationHealthChecks `json:"healthChecks,omitempty"`
76+
7577
UpgradeConfigs ConfigDestinationsUpgrade `json:"upgradeConfigs,omitempty"`
7678

7779
TLS ConfigDestinationTLS `json:"tls,omitempty"`
@@ -103,6 +105,7 @@ func (c *ConfigDestination) Validate() error {
103105
shared.PrefixResourceError("type", c.Type.Validate()),
104106
shared.PrefixResourceError("protocol", c.Protocol.Validate()),
105107
shared.PrefixResourceError("tls", c.TLS.Validate()),
108+
shared.PrefixResourceError("healthChecks", c.HealthChecks.Validate()),
106109
shared.PrefixResourceError("path", shared.ValidateAPIPath(c.GetPath())),
107110
shared.PrefixResourceError("pathType", shared.ValidateOptionalInterface(c.Match)),
108111
shared.PrefixResourceError("authExtension", c.AuthExtension.Validate()),
@@ -244,6 +247,7 @@ func (c *ConfigDestination) RenderCluster(name string) (*pbEnvoyClusterV3.Cluste
244247
},
245248
},
246249
},
250+
HealthChecks: c.HealthChecks.Render(),
247251
TypedExtensionProtocolOptions: map[string]*anypb.Any{
248252
"envoy.extensions.upstreams.http.v3.HttpProtocolOptions": hpo,
249253
},
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2025 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package gateway
22+
23+
import (
24+
"time"
25+
26+
pbEnvoyCoreV3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
27+
"google.golang.org/protobuf/types/known/durationpb"
28+
29+
shared "github.com/arangodb/kube-arangodb/pkg/apis/shared"
30+
"github.com/arangodb/kube-arangodb/pkg/util"
31+
)
32+
33+
type ConfigDestinationHealthChecks []ConfigDestinationHealthCheck
34+
35+
func (c ConfigDestinationHealthChecks) Validate() error {
36+
return shared.ValidateInterfaceList(c)
37+
}
38+
39+
func (c ConfigDestinationHealthChecks) Render() []*pbEnvoyCoreV3.HealthCheck {
40+
ret := make([]*pbEnvoyCoreV3.HealthCheck, len(c))
41+
for id := range c {
42+
ret[id] = c[id].Render()
43+
}
44+
return ret
45+
}
46+
47+
type ConfigDestinationHealthCheck struct {
48+
Timeout *time.Duration `json:"timeout,omitempty"`
49+
50+
Interval *time.Duration `json:"interval,omitempty"`
51+
}
52+
53+
func (c ConfigDestinationHealthCheck) Validate() error {
54+
return nil
55+
}
56+
57+
func (c ConfigDestinationHealthCheck) Render() *pbEnvoyCoreV3.HealthCheck {
58+
return &pbEnvoyCoreV3.HealthCheck{
59+
Timeout: durationpb.New(util.OptionalType(c.Timeout, time.Second)),
60+
Interval: durationpb.New(util.OptionalType(c.Interval, time.Second)),
61+
62+
HealthChecker: &pbEnvoyCoreV3.HealthCheck_TcpHealthCheck_{
63+
TcpHealthCheck: &pbEnvoyCoreV3.HealthCheck_TcpHealthCheck{},
64+
},
65+
}
66+
}

pkg/deployment/resources/pod_creator_gateway.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ func GetGatewayConfigMapName(name string, parts ...string) string {
4242
func createGatewayVolumes(input pod.Input) pod.Volumes {
4343
volumes := pod.NewVolumes()
4444

45+
volumes.AddVolume(k8sutil.LifecycleVolume())
46+
volumes.AddVolumeMount(k8sutil.LifecycleVolumeMount())
47+
volumes.Append(pod.JWT(), input)
48+
4549
volumes.AddVolume(k8sutil.CreateVolumeWithConfigMap(constants.GatewayVolumeName, GetGatewayConfigMapName(input.ApiObject.GetName())))
4650
volumes.AddVolume(k8sutil.CreateVolumeWithConfigMap(constants.GatewayCDSVolumeName, GetGatewayConfigMapName(input.ApiObject.GetName(), "cds")))
4751
volumes.AddVolume(k8sutil.CreateVolumeWithConfigMap(constants.GatewayLDSVolumeName, GetGatewayConfigMapName(input.ApiObject.GetName(), "lds")))

pkg/deployment/resources/pod_creator_gateway_container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (a *MemberGatewayContainer) GetProbes() (*core.Probe, *core.Probe, *core.Pr
8181
return nil, nil, nil, err
8282
}
8383

84-
probeStartupConfig, err := a.resources.getReadinessProbe(a.Deployment, a.Group, a.Image)
84+
probeStartupConfig, err := a.resources.getStartupProbe(a.Deployment, a.Group, a.Image)
8585
if err != nil {
8686
return nil, nil, nil, err
8787
}

pkg/deployment/resources/pod_creator_gateway_pod.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"context"
2525
"fmt"
2626
"math"
27+
"os"
2728

2829
core "k8s.io/api/core/v1"
2930

@@ -125,6 +126,20 @@ func (m *MemberGatewayPod) GetInitContainers(cachedStatus interfaces.Inspector)
125126
initContainers = append(initContainers, c...)
126127
}
127128

129+
executable, err := os.Executable()
130+
if err != nil {
131+
return nil, err
132+
}
133+
134+
{
135+
sc := k8sutil.CreateSecurityContext(m.GroupSpec.SecurityContext)
136+
c, err := k8sutil.InitLifecycleContainer(m.resources.context.GetOperatorImage(), executable, &m.Deployment.Lifecycle.Resources, sc)
137+
if err != nil {
138+
return nil, err
139+
}
140+
initContainers = append(initContainers, c)
141+
}
142+
128143
res := kresources.ExtractPodInitContainerAcceptedResourceRequirement(m.GetContainerCreator().GetResourceRequirements())
129144

130145
initContainers = applyInitContainersResourceResources(initContainers, res)

0 commit comments

Comments
 (0)