@@ -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+
60114func (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 {
0 commit comments