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

Fleet/GameServerSet Validation: Able to create a Fleet with label and annotations length > 63 symbols #1244

Closed
aLekSer opened this issue Dec 20, 2019 · 5 comments · Fixed by #1257
Labels
kind/bug These are bugs.
Milestone

Comments

@aLekSer
Copy link
Collaborator

aLekSer commented Dec 20, 2019

There is an option to create an invalid fleet or gameserverset with oversized label length.

What happened:

Fleet was created successfully.

What you expected to happen:

There should be an error on a Fleet validation.

How to reproduce it (as minimally and precisely as possible):

Fleet configuration fleet.yaml:

apiVersion: "agones.dev/v1"
kind: Fleet
metadata:
  name: check-the-fleet
spec:
  replicas: 3
  scheduling: Packed
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  template:
    metadata:
      labels:
        e123456: a123456789012345678901234567890123456789012345678901234567890123
    spec:
      ports:
      - name: default
        containerPort: 7654
      template:
        spec:
          containers:
          - name: simple-udp
            image: gcr.io/agones-images/udp-server:0.17

Run:

$ kubectl apply -f ./fleet.yaml
$ kubectl get fleets
NAME              SCHEDULING   DESIRED   CURRENT   ALLOCATED   READY   AGE
check-the-fleet   Packed       3                                       8m

Same steps aplies to GSS if you change Fleet to kind: GameServerSet with no errors on create.

Error in Controller logs:

error creating gameserverset for fleet check-the-fleet: GameServerSet.agones.dev "check-the-fleet-w4vdd" is invalid: metadata.labels: Invalid value: "a123456789012345678901234567890123456789012345678901234567890123": must be no more than 63 characters

Anything else we need to know?:

Environment:

  • Agones version: 1.2.0
  • Kubernetes version (use kubectl version):
    Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.3", GitCommit:"b3cbbae08ec52a7fc73d334838e18d17e8512749", GitTreeState:"clean", BuildDate:"2019-11-13T11:23:11Z", GoVersion:"go1.12.12", Compiler:"gc", Platform:"darwin/amd64"}
    Server Version: version.Info{Major:"1", Minor:"13+", GitVersion:"v1.13.12-gke.13", GitCommit:"39fe6cf6b77a3a0f620bd89db92f5133be67aa91", GitTreeState:"clean", BuildDate:"2019-11-13T20:44:51Z", GoVersion:"go1.12.11b4", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration:
  • Install method (yaml/helm):
  • Troubleshooting guide log(s):
  • Others:
@aLekSer aLekSer added the kind/bug These are bugs. label Dec 20, 2019
@aLekSer aLekSer changed the title Fleet Validation: Able to create a Fleet with label length > 63 symbols Fleet/GameServerSet Validation: Able to create a Fleet with label length > 63 symbols Dec 20, 2019
@aLekSer
Copy link
Collaborator Author

aLekSer commented Dec 20, 2019

Similar validation for Pods:
https://github.com/kubernetes/kubernetes/pull/1830/files

@aLekSer
Copy link
Collaborator Author

aLekSer commented Jan 3, 2020

Working on a solution to this issue.
Also note that there is one more place where we could have long labels in Spec.Template.Spec.Template:

apiVersion: "agones.dev/v1"
kind: Fleet
metadata:
  name: check-the-fleet
spec:
  replicas: 3
  scheduling: Packed
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  template:   
   spec:
    ports:
    - name: default
      containerPort: 7654
    template:
      metadata:
        labels:
          e123456: a123456789012345678901234567890123456789012345678901234567890123
      spec:
        containers:
        - name: simple-udp
          image: gcr.io/agones-images/udp-server:0.17

This will result in no GameServer could be created :

Pod " check-the-fleet-kbp6h-9krdv" is invalid: metadata.labels: Invalid value: "a123456789012345678901234567890123456789012345678901234567890123": must be no more than 63 characters

https://gist.github.com/aLekSer/b490a8e129986d102685abc2269c65e6

@aLekSer aLekSer changed the title Fleet/GameServerSet Validation: Able to create a Fleet with label length > 63 symbols Fleet/GameServerSet Validation: Able to create a Fleet with label and annotations length > 63 symbols Jan 3, 2020
@aLekSer
Copy link
Collaborator Author

aLekSer commented Jan 3, 2020

Same applies to annotations key length, which should not exceed 63 symbols as well:
https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/
Example which cause infinite GameServers creation:

apiVersion: "agones.dev/v1"
kind: Fleet
metadata:
  name: check-the-fleet2
spec:
  replicas: 3
  scheduling: Packed
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  template:
    spec:
      ports:
        - name: default
          containerPort: 7654
      template:
        metadata:
          annotations:
            a123456789012345678901234567890123456789012345678901234567890123: a123456789012345678901234567890123456789012345678901234567890123
        spec:
          containers:
            - name: simple-udp
              image: gcr.io/agones-images/udp-server:0.17

@aLekSer
Copy link
Collaborator Author

aLekSer commented Jan 3, 2020

@aLekSer
Copy link
Collaborator Author

aLekSer commented Jan 8, 2020

Working on the annotation fix in a branch:
https://github.com/aLekSer/agones/tree/validateAnnotations
Will send a PR after the Labels fix, because of dependencies between them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug These are bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants