diff --git a/build/Makefile b/build/Makefile index 5d4d95c673..75e93aab49 100644 --- a/build/Makefile +++ b/build/Makefile @@ -53,7 +53,7 @@ KIND_PROFILE ?= agones KIND_CONTAINER_NAME=kind-$(KIND_PROFILE)-control-plane # Game Server image to use while doing end-to-end tests -GS_TEST_IMAGE ?= gcr.io/agones-images/udp-server:0.5 +GS_TEST_IMAGE ?= gcr.io/agones-images/udp-server:0.6 # Directory that this Makefile is in. mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) diff --git a/examples/fleet.yaml b/examples/fleet.yaml index b75026b42d..9715a62703 100644 --- a/examples/fleet.yaml +++ b/examples/fleet.yaml @@ -67,4 +67,4 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.5 \ No newline at end of file + image: gcr.io/agones-images/udp-server:0.6 \ No newline at end of file diff --git a/examples/simple-udp/Makefile b/examples/simple-udp/Makefile index ecba17a0ba..166c59927a 100644 --- a/examples/simple-udp/Makefile +++ b/examples/simple-udp/Makefile @@ -27,7 +27,7 @@ REPOSITORY = gcr.io/agones-images mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) project_path := $(dir $(mkfile_path)) -server_tag = $(REPOSITORY)/udp-server:0.5 +server_tag = $(REPOSITORY)/udp-server:0.6 root_path = $(realpath $(project_path)/../..) # _____ _ diff --git a/examples/simple-udp/fleet.yaml b/examples/simple-udp/fleet.yaml index b82e718916..01200f875c 100644 --- a/examples/simple-udp/fleet.yaml +++ b/examples/simple-udp/fleet.yaml @@ -27,7 +27,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.5 + image: gcr.io/agones-images/udp-server:0.6 resources: requests: memory: "64Mi" diff --git a/examples/simple-udp/gameserver.yaml b/examples/simple-udp/gameserver.yaml index bdf882b535..ac7f4ac0c0 100644 --- a/examples/simple-udp/gameserver.yaml +++ b/examples/simple-udp/gameserver.yaml @@ -25,7 +25,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.5 + image: gcr.io/agones-images/udp-server:0.6 resources: requests: memory: "32Mi" diff --git a/examples/simple-udp/gameserverset.yaml b/examples/simple-udp/gameserverset.yaml index 48ad32cb53..ca80097171 100644 --- a/examples/simple-udp/gameserverset.yaml +++ b/examples/simple-udp/gameserverset.yaml @@ -31,4 +31,4 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.5 \ No newline at end of file + image: gcr.io/agones-images/udp-server:0.6 \ No newline at end of file diff --git a/examples/simple-udp/main.go b/examples/simple-udp/main.go index 56f89d7c2f..ece36285cc 100644 --- a/examples/simple-udp/main.go +++ b/examples/simple-udp/main.go @@ -27,7 +27,7 @@ import ( coresdk "agones.dev/agones/pkg/sdk" "agones.dev/agones/pkg/util/signals" - "agones.dev/agones/sdks/go" + sdk "agones.dev/agones/sdks/go" ) // main starts a UDP server that received 1024 byte sized packets at at time @@ -80,8 +80,9 @@ func readWriteLoop(conn net.PacketConn, stop chan struct{}, s *sdk.SDK) { b := make([]byte, 1024) for { sender, txt := readPacket(conn, b) - switch txt { + parts := strings.Split(strings.TrimSpace(txt), " ") + switch parts[0] { // shuts down the gameserver case "EXIT": exit(s) @@ -97,13 +98,31 @@ func readWriteLoop(conn net.PacketConn, stop chan struct{}, s *sdk.SDK) { watchGameServerEvents(s) case "LABEL": - setLabel(s) + switch len(parts) { + case 1: + // legacy format + setLabel(s, "timestamp", strconv.FormatInt(time.Now().Unix(), 10)) + case 3: + setLabel(s, parts[1], parts[2]) + default: + respond(conn, sender, "ERROR: Invalid LABEL command, must use zero or 2 arguments") + continue + } case "ANNOTATION": - setAnnotation(s) + switch len(parts) { + case 1: + // legacy format + setAnnotation(s, "timestamp", time.Now().UTC().String()) + case 3: + setAnnotation(s, parts[1], parts[2]) + default: + respond(conn, sender, "ERROR: Invalid ANNOTATION command, must use zero or 2 arguments\n") + continue + } } - ack(conn, sender, txt) + respond(conn, sender, "ACK: "+txt+"\n") } } @@ -118,10 +137,9 @@ func readPacket(conn net.PacketConn, b []byte) (net.Addr, string) { return sender, txt } -// ack echoes it back, with an ACK -func ack(conn net.PacketConn, sender net.Addr, txt string) { - ack := "ACK: " + txt + "\n" - if _, err := conn.WriteTo([]byte(ack), sender); err != nil { +// respond responds to a given sender. +func respond(conn net.PacketConn, sender net.Addr, txt string) { + if _, err := conn.WriteTo([]byte(txt), sender); err != nil { log.Fatalf("Could not write to udp stream: %v", err) } } @@ -172,8 +190,8 @@ func watchGameServerEvents(s *sdk.SDK) { } // setAnnotation sets a given annotation -func setAnnotation(s *sdk.SDK) { - log.Print("Setting annotation") +func setAnnotation(s *sdk.SDK, key string, value string) { + log.Printf("Setting annotation %v=%v", key, value) err := s.SetAnnotation("timestamp", time.Now().UTC().String()) if err != nil { log.Fatalf("could not set annotation: %v", err) @@ -181,10 +199,10 @@ func setAnnotation(s *sdk.SDK) { } // setLabel sets a given label -func setLabel(s *sdk.SDK) { - log.Print("Setting label") +func setLabel(s *sdk.SDK, key, value string) { + log.Printf("Setting label %v=%v", key, value) // label values can only be alpha, - and . - err := s.SetLabel("timestamp", strconv.FormatInt(time.Now().Unix(), 10)) + err := s.SetLabel(key, value) if err != nil { log.Fatalf("could not set label: %v", err) } diff --git a/install/helm/agones/templates/NOTES.txt b/install/helm/agones/templates/NOTES.txt index a3e942a964..936462b4cf 100644 --- a/install/helm/agones/templates/NOTES.txt +++ b/install/helm/agones/templates/NOTES.txt @@ -19,7 +19,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.5 + image: gcr.io/agones-images/udp-server:0.6 Finally don't forget to explore our documentation and usage guides on how to develop and host dedicated game servers on top of Agones. : diff --git a/site/content/en/docs/Advanced/limiting-resources.md b/site/content/en/docs/Advanced/limiting-resources.md index 7232af185d..d3a5d7a2b4 100644 --- a/site/content/en/docs/Advanced/limiting-resources.md +++ b/site/content/en/docs/Advanced/limiting-resources.md @@ -39,7 +39,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.5 + image: gcr.io/agones-images/udp-server:0.6 resources: limit: cpu: "250m" #this is our limit here diff --git a/site/content/en/docs/Advanced/scheduling-and-autoscaling.md b/site/content/en/docs/Advanced/scheduling-and-autoscaling.md index e3f8248134..283f168a22 100644 --- a/site/content/en/docs/Advanced/scheduling-and-autoscaling.md +++ b/site/content/en/docs/Advanced/scheduling-and-autoscaling.md @@ -79,7 +79,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.5 + image: gcr.io/agones-images/udp-server:0.6 ``` This is the *default* Fleet scheduling strategy. It is designed for dynamic Kubernetes environments, wherein you wish @@ -134,7 +134,7 @@ spec: spec: containers: - name: simple-udp - image: gcr.io/agones-images/udp-server:0.5 + image: gcr.io/agones-images/udp-server:0.6 ``` This Fleet scheduling strategy is designed for static Kubernetes environments, such as when you are running Kubernetes diff --git a/site/content/en/docs/Getting Started/create-fleet.md b/site/content/en/docs/Getting Started/create-fleet.md index 5e7fdd40a4..dce1d4d213 100644 --- a/site/content/en/docs/Getting Started/create-fleet.md +++ b/site/content/en/docs/Getting Started/create-fleet.md @@ -111,7 +111,7 @@ Spec: Creation Timestamp: Spec: Containers: - Image: gcr.io/agones-images/udp-server:0.5 + Image: gcr.io/agones-images/udp-server:0.6 Name: simple-udp Resources: Status: @@ -326,7 +326,7 @@ status: creationTimestamp: null spec: containers: - - image: gcr.io/agones-images/udp-server:0.5 + - image: gcr.io/agones-images/udp-server:0.6 name: simple-udp resources: {} status: diff --git a/site/content/en/docs/Getting Started/create-gameserver.md b/site/content/en/docs/Getting Started/create-gameserver.md index 7b4165b692..c5f916a497 100644 --- a/site/content/en/docs/Getting Started/create-gameserver.md +++ b/site/content/en/docs/Getting Started/create-gameserver.md @@ -107,7 +107,7 @@ Spec: Creation Timestamp: Spec: Containers: - Image: gcr.io/agones-images/udp-server:0.5 + Image: gcr.io/agones-images/udp-server:0.6 Name: simple-udp Resources: Status: diff --git a/site/content/en/docs/Guides/access-api.md b/site/content/en/docs/Guides/access-api.md index f73c370f3b..b3ccef2722 100644 --- a/site/content/en/docs/Guides/access-api.md +++ b/site/content/en/docs/Guides/access-api.md @@ -88,7 +88,7 @@ func main() { Spec: v1alpha1.GameServerSpec{ Template: corev1.PodTemplateSpec{ Spec: corev1.PodSpec{ - Containers: []corev1.Container{{Name: "udp-server", Image: "gcr.io/agones-images/udp-server:0.5"}}, + Containers: []corev1.Container{{Name: "udp-server", Image: "gcr.io/agones-images/udp-server:0.6"}}, }, }, }, @@ -176,7 +176,7 @@ $ curl http://localhost:8001/apis/stable.agones.dev/v1alpha1/namespaces/default/ "kind": "GameServer", "metadata": { "annotations": { - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"stable.agones.dev/v1alpha1\",\"kind\":\"GameServer\",\"metadata\":{\"annotations\":{},\"name\":\"simple-udp\",\"namespace\":\"default\"},\"spec\":{\"containerPort\":7654,\"hostPort\":7777,\"portPolicy\":\"static\",\"template\":{\"spec\":{\"containers\":[{\"image\":\"gcr.io/agones-images/udp-server:0.5\",\"name\":\"simple-udp\"}]}}}}\n" + "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"stable.agones.dev/v1alpha1\",\"kind\":\"GameServer\",\"metadata\":{\"annotations\":{},\"name\":\"simple-udp\",\"namespace\":\"default\"},\"spec\":{\"containerPort\":7654,\"hostPort\":7777,\"portPolicy\":\"static\",\"template\":{\"spec\":{\"containers\":[{\"image\":\"gcr.io/agones-images/udp-server:0.6\",\"name\":\"simple-udp\"}]}}}}\n" }, "clusterName": "", "creationTimestamp": "2018-03-02T21:41:05Z", @@ -208,7 +208,7 @@ $ curl http://localhost:8001/apis/stable.agones.dev/v1alpha1/namespaces/default/ "spec": { "containers": [ { - "image": "gcr.io/agones-images/udp-server:0.5", + "image": "gcr.io/agones-images/udp-server:0.6", "name": "simple-udp", "resources": {} } @@ -316,7 +316,7 @@ $ curl -d '{"apiVersion":"stable.agones.dev/v1alpha1","kind":"FleetAllocation"," "spec": { "containers": [ { - "image": "gcr.io/agones-images/udp-server:0.5", + "image": "gcr.io/agones-images/udp-server:0.6", "name": "simple-udp", "resources": {} } diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index f02a915fbd..1e13315104 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -33,8 +33,8 @@ func TestMain(m *testing.M) { usr, _ := user.Current() kubeconfig := flag.String("kubeconfig", filepath.Join(usr.HomeDir, "/.kube/config"), "kube config path, e.g. $HOME/.kube/config") - gsimage := flag.String("gameserver-image", "gcr.io/agones-images/udp-server:0.5", - "gameserver image to use for those tests, gcr.io/agones-images/udp-server:0.5") + gsimage := flag.String("gameserver-image", "gcr.io/agones-images/udp-server:0.6", + "gameserver image to use for those tests, gcr.io/agones-images/udp-server:0.6") pullSecret := flag.String("pullsecret", "", "optional secret to be used for pulling the gameserver and/or Agones SDK sidecar images")