Skip to content

Commit 3551355

Browse files
authored
[Feature] [Platform] Gateway UpToDate Condition (#1967)
1 parent e75e7d7 commit 3551355

File tree

8 files changed

+72
-3
lines changed

8 files changed

+72
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- (Feature) Improve GRPC JSON Handling
1515
- (Bugfix) Fix Operator Pod Resources
1616
- (Feature) (Platform) MetaV1 Integration Tests
17+
- (Feature) (Platform) Gateway UpToDate Condition
1718

1819
## [1.3.0](https://github.com/arangodb/kube-arangodb/tree/1.3.0) (2025-08-01)
1920
- (Feature) (Platform) Storage Debug

pkg/deployment/deployment_inspector.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,12 @@ func (d *Deployment) isUpToDateStatus(mode api.DeploymentMode, status api.Deploy
486486
return
487487
}
488488

489+
if v, ok := status.Conditions.Get(api.ConditionTypeGatewayConfig); ok && !v.IsTrue() {
490+
upToDate = false
491+
reason = "Gateway is not propagated"
492+
return
493+
}
494+
489495
for _, m := range status.Members.AsList() {
490496
member := m.Member
491497
if member.Conditions.IsTrue(api.ConditionTypeRestart) || member.Conditions.IsTrue(api.ConditionTypePendingRestart) {

pkg/deployment/member/phase_updates.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ func removeMemberConditionsMapFunc(m *api.MemberStatus) {
116116
m.Conditions.Remove(api.ConditionTypeArchitectureMismatch)
117117
m.Conditions.Remove(api.ConditionTypeArchitectureChangeCannotBeApplied)
118118
m.Conditions.Remove(api.ConditionTypeMemberVolumeUnschedulable)
119+
m.Conditions.Remove(api.ConditionTypeGatewayConfig)
119120

120121
m.RemoveTerminationsBefore(time.Now().Add(-1 * utilConstants.RecentTerminationsKeepPeriod))
121122

pkg/deployment/reconcile/plan_builder_gateway.go

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import (
2929
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
3030
client "github.com/arangodb/kube-arangodb/pkg/deployment/client"
3131
sharedReconcile "github.com/arangodb/kube-arangodb/pkg/deployment/reconcile/shared"
32+
"github.com/arangodb/kube-arangodb/pkg/deployment/resources"
33+
utilConstants "github.com/arangodb/kube-arangodb/pkg/util/constants"
3234
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
3335
)
3436

@@ -47,8 +49,6 @@ func (r *Reconciler) createMemberGatewayConfigConditionPlan(ctx context.Context,
4749
continue
4850
}
4951

50-
logger.JSON("inv", inv).Info("Inventory Fetched")
51-
5252
if c, ok := m.Member.Conditions.Get(api.ConditionTypeGatewayConfig); !ok || c.Status == core.ConditionFalse || c.Hash != inv.Configuration.Hash {
5353
plan = append(plan, sharedReconcile.UpdateMemberConditionActionV2("Config Present", api.ConditionTypeGatewayConfig, m.Group, m.Member.ID, true, "Config Present", "Config Present", inv.Configuration.Hash))
5454
}
@@ -57,6 +57,60 @@ func (r *Reconciler) createMemberGatewayConfigConditionPlan(ctx context.Context,
5757
return plan
5858
}
5959

60+
func (r *Reconciler) createGatewayConfigConditionPlan(ctx context.Context, _ k8sutil.APIObject, spec api.DeploymentSpec,
61+
status api.DeploymentStatus, planCtx PlanBuilderContext) api.Plan {
62+
var plan api.Plan
63+
64+
if spec.Gateway.IsEnabled() {
65+
cm, exists := planCtx.ACS().CurrentClusterCache().ConfigMap().V1().GetSimple(resources.GetGatewayConfigMapName(r.context.GetAPIObject().GetName()))
66+
if !exists {
67+
if c, ok := status.Conditions.Get(api.ConditionTypeGatewayConfig); !ok || c.Status == core.ConditionTrue || c.Hash != "" {
68+
plan = append(plan, sharedReconcile.UpdateConditionActionV2("Gateway CM Missing", api.ConditionTypeGatewayConfig, false, "Gateway CM Missing", "Gateway CM Missing", ""))
69+
}
70+
return plan
71+
}
72+
73+
if cm == nil || cm.Data[utilConstants.GatewayConfigChecksum] == "" {
74+
if c, ok := status.Conditions.Get(api.ConditionTypeGatewayConfig); !ok || c.Status == core.ConditionTrue || c.Hash != "" {
75+
plan = append(plan, sharedReconcile.UpdateConditionActionV2("Gateway CM Missing", api.ConditionTypeGatewayConfig, false, "Gateway CM Missing", "Gateway CM Missing", ""))
76+
}
77+
return plan
78+
}
79+
80+
checksum := cm.Data[utilConstants.GatewayConfigChecksum]
81+
82+
cok := true
83+
for _, m := range status.Members.AsListInGroup(api.ServerGroupGateways) {
84+
if v, ok := m.Member.Conditions.Get(api.ConditionTypeGatewayConfig); !ok || v.Status != core.ConditionTrue || v.Hash != checksum {
85+
cok = false
86+
}
87+
if !cok {
88+
break
89+
}
90+
}
91+
92+
if cok {
93+
if c, ok := status.Conditions.Get(api.ConditionTypeGatewayConfig); !ok || c.Status == core.ConditionFalse || c.Hash != checksum {
94+
plan = append(plan, sharedReconcile.UpdateConditionActionV2("Gateway Config UpToDate", api.ConditionTypeGatewayConfig, true, "Gateway Config Propagated", "Gateway Config Propagated", checksum))
95+
return plan
96+
}
97+
} else {
98+
if c, ok := status.Conditions.Get(api.ConditionTypeGatewayConfig); !ok || c.Status == core.ConditionTrue || c.Hash != checksum {
99+
plan = append(plan, sharedReconcile.UpdateConditionActionV2("Gateway Config Not UpToDate", api.ConditionTypeGatewayConfig, false, "Gateway Config Not Propagated", "Gateway Config Not Propagated", checksum))
100+
return plan
101+
}
102+
}
103+
104+
} else {
105+
if _, ok := status.Conditions.Get(api.ConditionTypeGatewayConfig); ok {
106+
plan = append(plan, sharedReconcile.RemoveConditionActionV2("Gateways Disabled", api.ConditionTypeGatewayConfig))
107+
return plan
108+
}
109+
}
110+
111+
return plan
112+
}
113+
60114
func (r *Reconciler) getGatewayInventoryConfig(ctx context.Context, planCtx PlanBuilderContext, group api.ServerGroup, member api.MemberStatus) (*client.Inventory, error) {
61115
serverClient, err := planCtx.GetServerClient(ctx, group, member.ID)
62116
if err != nil {

pkg/deployment/reconcile/plan_builder_high.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ func (r *Reconciler) createHighPlan(ctx context.Context, apiObject k8sutil.APIOb
5656
ApplyIfEmpty(r.updateMemberRotationConditionsPlan).
5757
ApplyIfEmpty(r.createMemberAllowUpgradeConditionPlan).
5858
ApplyIfEmpty(r.createMemberGatewayConfigConditionPlan).
59+
ApplyIfEmpty(r.createGatewayConfigConditionPlan).
5960
ApplyIfEmpty(r.createMemberRecreationConditionsPlan).
6061
ApplyIfEmpty(r.createMemberPodSchedulingFailurePlan).
6162
ApplyIfEmpty(r.createRotateServerStoragePVCPendingResizeConditionPlan).

pkg/deployment/resources/config_map_gateway.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,21 @@ func (r *Resources) ensureGatewayConfig(ctx context.Context, cachedStatus inspec
154154

155155
if err := r.ensureGatewayConfigMap(ctx, cachedStatus, configMaps, GetGatewayConfigMapName(r.context.GetAPIObject().GetName()), map[string]string{
156156
utilConstants.GatewayConfigFileName: string(gatewayCfgYaml),
157+
utilConstants.GatewayConfigChecksum: baseGatewayCfgYamlChecksum,
157158
}); err != nil {
158159
return err
159160
}
160161

161162
if err := r.ensureGatewayConfigMap(ctx, cachedStatus, configMaps, GetGatewayConfigMapName(r.context.GetAPIObject().GetName(), "cds"), map[string]string{
162163
utilConstants.GatewayConfigFileName: string(gatewayCfgCDSYaml),
164+
utilConstants.GatewayConfigChecksum: baseGatewayCfgYamlChecksum,
163165
}); err != nil {
164166
return err
165167
}
166168

167169
if err := r.ensureGatewayConfigMap(ctx, cachedStatus, configMaps, GetGatewayConfigMapName(r.context.GetAPIObject().GetName(), "lds"), map[string]string{
168170
utilConstants.GatewayConfigFileName: string(gatewayCfgLDSYaml),
171+
utilConstants.GatewayConfigChecksum: baseGatewayCfgYamlChecksum,
169172
}); err != nil {
170173
return err
171174
}

pkg/util/constants/gateway.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const (
3333

3434
ArangoGatewayExecutor = "/usr/local/bin/envoy"
3535

36+
GatewayConfigChecksum = "gateway.checksum"
3637
GatewayConfigFileName = "gateway.yaml"
3738
GatewayConfigChecksumENV = "GATEWAY_CONFIG_CHECKSUM"
3839

pkg/util/k8sutil/helm/chart_manager_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ func Test_Manager_Tag(t *testing.T) {
9797
mgr, err := NewChartManager(context.Background(), nil, "https://arangodb-platform-dev-chart-registry.s3.amazonaws.com/index.yaml")
9898
require.NoError(t, err)
9999

100-
repo, ok := mgr.Get("platform_test_example")
100+
require.True(t, len(mgr.Repositories()) > 0)
101+
102+
repo, ok := mgr.Get(mgr.Repositories()[0])
101103
require.True(t, ok)
102104

103105
repo.GetByTag("dev")

0 commit comments

Comments
 (0)