Skip to content
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

protocol field in base config ports spec sometimes results in an empty ports list #3620

Closed
taneliang opened this issue Feb 19, 2021 · 3 comments · Fixed by #3685
Closed

protocol field in base config ports spec sometimes results in an empty ports list #3620

taneliang opened this issue Feb 19, 2021 · 3 comments · Fixed by #3685
Assignees
Labels
area/kyaml issues for kyaml kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects

Comments

@taneliang
Copy link

Describe the bug

If a protocol field is specified in a service's ports spec in the base config, it will be omitted from the build output if the patch also has a ports spec with the same port numbers. More variations tried are listed at the bottom.

Files that can reproduce the issue

https://github.com/taneliang/kustomize-protocol-issue-repro. Reproduced below for convenience:

kustomization.yaml

---
resources:
  - ./deployment.yaml

patchesStrategicMerge:
  - ./patch-deployment.yaml

deployment.yaml

apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  ports:
    - port: 30900
      targetPort: 30900
      protocol: TCP
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  namespace: web

patch-deployment.yaml

apiVersion: v1
kind: Service
metadata:
  name: web
  labels:
    service: web
spec:
  ports:
    - port: 30900
      targetPort: 30900
  selector:
    service: web
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  namespace: web

Expected output

apiVersion: v1
kind: Service
metadata:
  labels:
    service: web
  name: web
spec:
  ports:
  - port: 30900
    protocol: TCP
    targetPort: 30900
  selector:
    service: web
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  namespace: web

Actual output

apiVersion: v1
kind: Service
metadata:
  labels:
    service: web
  name: web
spec:
  ports: [] # <-- this is empty
  selector:
    service: web
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  namespace: web

Kustomize version

{Version:kustomize/v4.0.1 GitCommit:516ff1fa56040adc0173ff6ece66350eb4ed78a9 BuildDate:2021-02-14T05:00:02+00:00 GoOs:darwin GoArch:amd64}

Platform

macOS

Additional context

Variations of the repro files above I've tried:

  • Specified protocol: UDP instead of TCP: issue remains
  • Specified different port numbers in the patch config: resulting ports array contains the base ports, but not the patch ports
  • Removed protocol: TCP from the base config (i.e. both configs don't have a protocol field set): resulting ports array is correct
  • Specified protocol: TCP in the patch config instead of the base config: resulting ports array is correct
  • Specified protocol: TCP in both configs: resulting ports array is correct

I don't believe this can be reproduced on v3.9.2, so the cause was likely introduced between 3.9.2 and 4.0.1

@natasha41575 natasha41575 added area/kyaml issues for kyaml kind/bug Categorizes issue or PR as related to a bug. labels Feb 19, 2021
@natasha41575 natasha41575 self-assigned this Feb 19, 2021
@natasha41575 natasha41575 added this to Under consideration in kanban via automation Feb 19, 2021
@natasha41575 natasha41575 moved this from Under consideration to In progress in kanban Feb 27, 2021
@natasha41575
Copy link
Contributor

taking a look now

@natasha41575 natasha41575 added triage/accepted Indicates an issue or PR is ready to be actively worked on. and removed triage/under-consideration labels Feb 27, 2021
@ttk
Copy link

ttk commented Mar 4, 2021

I ran into this problem. I am using v3.10.0

@natasha41575
Copy link
Contributor

I am working on a fix but it will take some time

@natasha41575 natasha41575 moved this from In progress to Review in progress in kanban Mar 10, 2021
kanban automation moved this from Review in progress to Done Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kyaml issues for kyaml kind/bug Categorizes issue or PR as related to a bug. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
No open projects
kanban
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants