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

No validation on GameServerAllocation.Priorities #3684

Closed
markmandel opened this issue Mar 7, 2024 · 1 comment · Fixed by #3714
Closed

No validation on GameServerAllocation.Priorities #3684

markmandel opened this issue Mar 7, 2024 · 1 comment · Fixed by #3714
Labels
area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc kind/bug These are bugs.

Comments

@markmandel
Copy link
Member

markmandel commented Mar 7, 2024

What happened:

You can pass in invalid values for priority.type and priority.order on a GameServerAllocation

What you expected to happen:

Return an error stating the values are invalid (this happens with a Fleet - but it has the OpenAPI Spec).

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

Create this Fleet:

apiVersion: agones.dev/v1
kind: Fleet
metadata:
  name: simple-game-server
spec:
  replicas: 2
  template:
    spec:
      ports:
        - name: default
          containerPort: 7654
      counters:
        rooms:
          count: 0
          capacity: 10
      lists:
        players:
          values: []
      template:
        spec:
          containers:
            - name: simple-game-server
              image: us-docker.pkg.dev/agones-images/examples/simple-game-server:0.27
              resources:
                requests:
                  memory: 64Mi
                  cpu: 20m
                limits:
                  memory: 64Mi
                  cpu: 20m

Then kubectl create -f <this file>:

apiVersion: allocation.agones.dev/v1
kind: GameServerAllocation
spec:
  scheduling: Packed
  priorities:
    - type: John
      key: rooms
      order: Dog
  selectors:
    # First check to see if we can back-fill an already allocated `GameServer`
    - gameServerState: Allocated
      matchLabels:
        agones.dev/fleet: simple-game-server
      counters:
        rooms:
          minAvailable: 1
   # If we can't, then go get a `Ready` `GameServer`.
    - gameServerState: Ready
      matchLabels:
        agones.dev/fleet: simple-game-server
      counters:
        rooms:
          minAvailable: 1
  counters:
    rooms:
      action: Increment
      amount: 1

It will complete with no error.

Anything else we need to know?:

Since GameServerAllocation doesn't have the OpenAPI spec, we will have to do this somewhere in the .Validate() function of GameServerAllocation.

func (s *GameServerSelector) Validate(fldPath *field.Path) field.ErrorList {

Environment:

  • Agones version: dev
  • Kubernetes version (use kubectl version): 1.28
  • Cloud provider or hardware configuration: GKE
  • Install method (yaml/helm): helm
  • Troubleshooting guide log(s): N/A
  • Others: N/A
@markmandel markmandel added kind/bug These are bugs. area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc labels Mar 7, 2024
@markmandel
Copy link
Member Author

FYI: @igooch

@markmandel markmandel changed the title No validation or defaulting on GameServerAllocation.Priorities No validation on GameServerAllocation.Priorities Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc kind/bug These are bugs.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant