Skip to content

Commit 60adc4e

Browse files
authored
[Bugfix] Do not manage ports in managed ExternalAccess mode (#1211)
1 parent d130445 commit 60adc4e

File tree

3 files changed

+3
-52
lines changed

3 files changed

+3
-52
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change Log
22

33
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
4+
- (Bugfix) Do not manage ports in managed ExternalAccess mode
45

56
## [1.2.21](https://github.com/arangodb/kube-arangodb/tree/1.2.21) (2022-12-13)
67
- (Improvement) Bump dependencies

pkg/deployment/resources/services.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func (r *Resources) ensureExternalAccessServices(ctx context.Context, cachedStat
248248

249249
if spec.GetType().IsManaged() {
250250
// Managed services should not be created or removed by the operator.
251-
return r.ensureExternalAccessManagedServices(ctx, cachedStatus, eaServiceName, eaPorts, eaSelector, spec)
251+
return r.ensureExternalAccessManagedServices(ctx, cachedStatus, eaServiceName, eaSelector, spec)
252252
}
253253

254254
log := r.log.Str("section", "service-ea").Str("role", role).Str("service", eaServiceName)
@@ -368,14 +368,13 @@ func (r *Resources) ensureExternalAccessServices(ctx context.Context, cachedStat
368368
// ensureExternalAccessServices ensures if there are correct selectors on a managed services.
369369
// If hardcoded external service names are not on the list of managed services then it will be checked additionally.
370370
func (r *Resources) ensureExternalAccessManagedServices(ctx context.Context, cachedStatus inspectorInterface.Inspector, eaServiceName string,
371-
ports []core.ServicePort, selectors map[string]string, spec api.ExternalAccessSpec) error {
371+
selectors map[string]string, spec api.ExternalAccessSpec) error {
372372

373373
log := r.log.Str("section", "service-ea").Str("service", eaServiceName)
374374
managedServiceNames := spec.GetManagedServiceNames()
375375

376376
apply := func(svc *core.Service) (bool, error) {
377377
return patcher.ServicePatcher(ctx, cachedStatus.ServicesModInterface().V1(), svc, meta.PatchOptions{},
378-
patcher.PatchServiceOnlyPortsWithoutNodePort(ports...),
379378
patcher.PatchServiceSelector(selectors))
380379
}
381380

pkg/util/k8sutil/patcher/service.go

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -149,55 +149,6 @@ func PatchServiceOnlyPorts(ports ...core.ServicePort) ServicePatch {
149149
}
150150
}
151151

152-
func PatchServiceOnlyPortsWithoutNodePort(ports ...core.ServicePort) ServicePatch {
153-
return func(in *core.Service) []patch.Item {
154-
psvc := in.Spec.DeepCopy()
155-
cp := psvc.Ports
156-
157-
changed := false
158-
159-
for pid := range ports {
160-
got := false
161-
for id := range cp {
162-
if ports[pid].Name == cp[id].Name {
163-
got = true
164-
165-
// Set ignored fields
166-
if ports[pid].AppProtocol == nil {
167-
ports[pid].AppProtocol = cp[id].AppProtocol
168-
}
169-
if ports[pid].Protocol == "" {
170-
ports[pid].Protocol = cp[id].Protocol
171-
}
172-
if ports[pid].TargetPort.StrVal == "" && ports[pid].TargetPort.IntVal == 0 {
173-
ports[pid].TargetPort = cp[id].TargetPort
174-
}
175-
176-
if !equality.Semantic.DeepEqual(ports[pid], cp[id]) {
177-
q := ports[pid].DeepCopy()
178-
cp[id] = *q
179-
changed = true
180-
break
181-
}
182-
}
183-
}
184-
if !got {
185-
q := ports[pid].DeepCopy()
186-
cp = append(cp, *q)
187-
changed = true
188-
}
189-
}
190-
191-
if !changed {
192-
return nil
193-
}
194-
195-
return []patch.Item{
196-
patch.ItemReplace(patch.NewPath("spec", "ports"), cp),
197-
}
198-
}
199-
}
200-
201152
func PatchServiceSelector(selector map[string]string) ServicePatch {
202153
return func(in *core.Service) []patch.Item {
203154
if in.Spec.Selector != nil && equality.Semantic.DeepEqual(in.Spec.Selector, selector) {

0 commit comments

Comments
 (0)