-
Couldn't load subscription status.
- Fork 72
[Feature] Add Gateway Config condition #1959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
9a6b618
e68d735
e95e299
cdcba7d
e721417
55c6fe2
da36b24
c77c084
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| // | ||
| // DISCLAIMER | ||
| // | ||
| // Copyright 2025 ArangoDB GmbH, Cologne, Germany | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
| // | ||
| // Copyright holder is ArangoDB GmbH, Cologne, Germany | ||
| // | ||
|
|
||
| package client | ||
|
|
||
| import ( | ||
| "context" | ||
| goHttp "net/http" | ||
|
|
||
| pbInventoryV1 "github.com/arangodb/kube-arangodb/integrations/inventory/v1/definition" | ||
| utilConstants "github.com/arangodb/kube-arangodb/pkg/util/constants" | ||
| ugrpc "github.com/arangodb/kube-arangodb/pkg/util/grpc" | ||
| ) | ||
|
|
||
| func (c *client) Inventory(ctx context.Context) (*pbInventoryV1.Inventory, error) { | ||
| req, err := c.c.NewRequest(goHttp.MethodGet, utilConstants.EnvoyInventoryConfigDestination) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| resp, err := c.c.Do(ctx, req) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if err := resp.CheckStatus(goHttp.StatusOK); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| var l ugrpc.GRPC[*pbInventoryV1.Inventory] | ||
|
|
||
| if err := resp.ParseBody("", &l); err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return l.Object, nil | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,71 @@ | ||||||||||
| // | ||||||||||
| // DISCLAIMER | ||||||||||
| // | ||||||||||
| // Copyright 2025 ArangoDB GmbH, Cologne, Germany | ||||||||||
| // | ||||||||||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||||||||||
| // you may not use this file except in compliance with the License. | ||||||||||
| // You may obtain a copy of the License at | ||||||||||
| // | ||||||||||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||||||||||
| // | ||||||||||
| // Unless required by applicable law or agreed to in writing, software | ||||||||||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||||||||||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||||||||
| // See the License for the specific language governing permissions and | ||||||||||
| // limitations under the License. | ||||||||||
| // | ||||||||||
| // Copyright holder is ArangoDB GmbH, Cologne, Germany | ||||||||||
| // | ||||||||||
|
|
||||||||||
| package reconcile | ||||||||||
|
|
||||||||||
| import ( | ||||||||||
| "context" | ||||||||||
| "time" | ||||||||||
|
|
||||||||||
| core "k8s.io/api/core/v1" | ||||||||||
|
|
||||||||||
| pbInventoryV1 "github.com/arangodb/kube-arangodb/integrations/inventory/v1/definition" | ||||||||||
| api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1" | ||||||||||
| client "github.com/arangodb/kube-arangodb/pkg/deployment/client" | ||||||||||
| sharedReconcile "github.com/arangodb/kube-arangodb/pkg/deployment/reconcile/shared" | ||||||||||
| "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" | ||||||||||
| ) | ||||||||||
|
|
||||||||||
| func (r *Reconciler) createMemberGatewayConfigConditionPlan(ctx context.Context, _ k8sutil.APIObject, _ api.DeploymentSpec, | ||||||||||
| status api.DeploymentStatus, planCtx PlanBuilderContext) api.Plan { | ||||||||||
| var plan api.Plan | ||||||||||
|
|
||||||||||
| // Check for members in failed state. | ||||||||||
| for _, m := range status.Members.AsListInGroup(api.ServerGroupGateways) { | ||||||||||
| inv, err := r.getGatewayInventoryConfig(ctx, planCtx, m.Group, m.Member) | ||||||||||
| if err != nil { | ||||||||||
| if c, ok := m.Member.Conditions.Get(api.ConditionTypeGatewayConfig); !ok || c.Status == core.ConditionTrue { | ||||||||||
| plan = append(plan, sharedReconcile.UpdateMemberConditionActionV2("Config is not present", api.ConditionTypeGatewayConfig, m.Group, m.Member.ID, false, "Config is not present", "Config is not present", "")) | ||||||||||
| } | ||||||||||
|
|
||||||||||
| continue | ||||||||||
| } | ||||||||||
|
|
||||||||||
| if c, ok := m.Member.Conditions.Get(api.ConditionTypeGatewayConfig); !ok || c.Status == core.ConditionFalse || c.Hash != inv.GetConfiguration().GetHash() { | ||||||||||
| plan = append(plan, sharedReconcile.UpdateMemberConditionActionV2("Config Present", api.ConditionTypeGatewayConfig, m.Group, m.Member.ID, false, "Config Present", "Config Present", inv.GetConfiguration().GetHash())) | ||||||||||
|
||||||||||
| plan = append(plan, sharedReconcile.UpdateMemberConditionActionV2("Config Present", api.ConditionTypeGatewayConfig, m.Group, m.Member.ID, false, "Config Present", "Config Present", inv.GetConfiguration().GetHash())) | |
| plan = append(plan, sharedReconcile.UpdateMemberConditionActionV2(gatewayConfigPresentMsg, api.ConditionTypeGatewayConfig, m.Group, m.Member.ID, false, gatewayConfigPresentMsg, gatewayConfigPresentMsg, inv.GetConfiguration().GetHash())) |
Outdated
Copilot
AI
Aug 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fourth parameter should be true instead of false when the config is present, as this indicates the condition status (true = condition is met).
| plan = append(plan, sharedReconcile.UpdateMemberConditionActionV2("Config Present", api.ConditionTypeGatewayConfig, m.Group, m.Member.ID, false, "Config Present", "Config Present", inv.GetConfiguration().GetHash())) | |
| plan = append(plan, sharedReconcile.UpdateMemberConditionActionV2("Config Present", api.ConditionTypeGatewayConfig, m.Group, m.Member.ID, true, "Config Present", "Config Present", inv.GetConfiguration().GetHash())) |
Copilot
AI
Aug 15, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable logger is undefined in this scope. You need to either pass a logger parameter to this function or use a logger from the reconciler context.
| logger := log.FromContext(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded string "Config is not present" is repeated multiple times. Consider defining a constant for this message to improve maintainability.