diff --git a/pkg/allocation/converters/converter.go b/pkg/allocation/converters/converter.go index 1e78a2f41a..65d4bb61a9 100644 --- a/pkg/allocation/converters/converter.go +++ b/pkg/allocation/converters/converter.go @@ -50,10 +50,16 @@ func ConvertAllocationRequestToGSA(in *pb.AllocationRequest) *allocationv1.GameS } } - if in.GetMetaPatch() != nil { + // Accept both metadata (preferred) and metapatch until metapatch is fully removed. + metadata := in.GetMetadata() + if metadata == nil { + metadata = in.GetMetaPatch() + } + + if metadata != nil { gsa.Spec.MetaPatch = allocationv1.MetaPatch{ - Labels: in.GetMetaPatch().GetLabels(), - Annotations: in.GetMetaPatch().GetAnnotations(), + Labels: metadata.GetLabels(), + Annotations: metadata.GetAnnotations(), } } @@ -77,6 +83,13 @@ func ConvertGSAToAllocationRequest(in *allocationv1.GameServerAllocation) *pb.Al Enabled: in.Spec.MultiClusterSetting.Enabled, }, RequiredGameServerSelector: convertInternalLabelSelectorToLabelSelector(&in.Spec.Required), + Metadata: &pb.MetaPatch{ + Labels: in.Spec.MetaPatch.Labels, + Annotations: in.Spec.MetaPatch.Annotations, + }, + // MetaPatch is deprecated, but we do a double write here to both metapatch and metadata + // to ensure that multi-cluster allocation still works when one cluster has the field + // and another one does not have the field yet. MetaPatch: &pb.MetaPatch{ Labels: in.Spec.MetaPatch.Labels, Annotations: in.Spec.MetaPatch.Annotations, diff --git a/pkg/allocation/converters/converter_test.go b/pkg/allocation/converters/converter_test.go index a6cb4d9811..0d4d31642b 100644 --- a/pkg/allocation/converters/converter_test.go +++ b/pkg/allocation/converters/converter_test.go @@ -64,6 +64,11 @@ func TestConvertAllocationRequestToGameServerAllocation(t *testing.T) { }, }, Scheduling: pb.AllocationRequest_Packed, + Metadata: &pb.MetaPatch{ + Labels: map[string]string{ + "i": "j", + }, + }, MetaPatch: &pb.MetaPatch{ Labels: map[string]string{ "i": "j", @@ -117,7 +122,7 @@ func TestConvertAllocationRequestToGameServerAllocation(t *testing.T) { RequiredGameServerSelector: &pb.LabelSelector{}, PreferredGameServerSelectors: []*pb.LabelSelector{}, Scheduling: pb.AllocationRequest_Distributed, - MetaPatch: &pb.MetaPatch{}, + Metadata: &pb.MetaPatch{}, }, want: &allocationv1.GameServerAllocation{ ObjectMeta: metav1.ObjectMeta{ @@ -147,6 +152,75 @@ func TestConvertAllocationRequestToGameServerAllocation(t *testing.T) { in: nil, want: nil, }, + { + name: "accepts deprecated metapatch field", + in: &pb.AllocationRequest{ + Namespace: "", + MultiClusterSetting: &pb.MultiClusterSetting{}, + RequiredGameServerSelector: &pb.LabelSelector{}, + PreferredGameServerSelectors: []*pb.LabelSelector{}, + Scheduling: pb.AllocationRequest_Distributed, + MetaPatch: &pb.MetaPatch{ + Labels: map[string]string{ + "a": "b", + }, + }, + }, + want: &allocationv1.GameServerAllocation{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "", + }, + Spec: allocationv1.GameServerAllocationSpec{ + MultiClusterSetting: allocationv1.MultiClusterSetting{ + Enabled: false, + }, + Scheduling: apis.Distributed, + MetaPatch: allocationv1.MetaPatch{ + Labels: map[string]string{ + "a": "b", + }, + }, + }, + }, + skipConvertFromGSA: true, + }, + { + name: "Prefers metadata over metapatch field", + in: &pb.AllocationRequest{ + Namespace: "", + MultiClusterSetting: &pb.MultiClusterSetting{}, + RequiredGameServerSelector: &pb.LabelSelector{}, + PreferredGameServerSelectors: []*pb.LabelSelector{}, + Scheduling: pb.AllocationRequest_Distributed, + Metadata: &pb.MetaPatch{ + Labels: map[string]string{ + "a": "b", + }, + }, + MetaPatch: &pb.MetaPatch{ + Labels: map[string]string{ + "c": "d", + }, + }, + }, + want: &allocationv1.GameServerAllocation{ + ObjectMeta: metav1.ObjectMeta{ + Namespace: "", + }, + Spec: allocationv1.GameServerAllocationSpec{ + MultiClusterSetting: allocationv1.MultiClusterSetting{ + Enabled: false, + }, + Scheduling: apis.Distributed, + MetaPatch: allocationv1.MetaPatch{ + Labels: map[string]string{ + "a": "b", + }, + }, + }, + }, + skipConvertFromGSA: true, + }, } for _, tc := range tests { tc := tc @@ -154,15 +228,11 @@ func TestConvertAllocationRequestToGameServerAllocation(t *testing.T) { t.Parallel() out := ConvertAllocationRequestToGSA(tc.in) - if !assert.Equal(t, tc.want, out) { - t.Errorf("mismatch with want after conversion: \"%s\"", tc.name) - } + assert.Equal(t, tc.want, out, "mismatch with want after conversion: \"%s\"", tc.name) if !tc.skipConvertFromGSA { gsa := ConvertGSAToAllocationRequest(tc.want) - if !assert.Equal(t, tc.in, gsa) { - t.Errorf("mismatch with input after double conversion \"%s\"", tc.name) - } + assert.Equal(t, tc.in, gsa, "mismatch with input after double conversion \"%s\"", tc.name) } }) } @@ -192,6 +262,7 @@ func TestConvertGSAToAllocationRequestEmpty(t *testing.T) { MultiClusterSetting: &pb.MultiClusterSetting{}, RequiredGameServerSelector: &pb.LabelSelector{}, Scheduling: pb.AllocationRequest_Distributed, + Metadata: &pb.MetaPatch{}, MetaPatch: &pb.MetaPatch{}, }, }, { @@ -204,6 +275,7 @@ func TestConvertGSAToAllocationRequestEmpty(t *testing.T) { want: &pb.AllocationRequest{ MultiClusterSetting: &pb.MultiClusterSetting{}, RequiredGameServerSelector: &pb.LabelSelector{}, + Metadata: &pb.MetaPatch{}, MetaPatch: &pb.MetaPatch{}, }, }, diff --git a/pkg/allocation/go/allocation.pb.go b/pkg/allocation/go/allocation.pb.go index 8366fb9c9f..e252259dfe 100644 --- a/pkg/allocation/go/allocation.pb.go +++ b/pkg/allocation/go/allocation.pb.go @@ -63,7 +63,7 @@ func (x AllocationRequest_SchedulingStrategy) String() string { return proto.EnumName(AllocationRequest_SchedulingStrategy_name, int32(x)) } func (AllocationRequest_SchedulingStrategy) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_allocation_d5752a3ca48e8a0b, []int{0, 0} + return fileDescriptor_allocation_0f914fcce1c5f3b7, []int{0, 0} } type AllocationRequest struct { @@ -78,9 +78,12 @@ type AllocationRequest struct { PreferredGameServerSelectors []*LabelSelector `protobuf:"bytes,4,rep,name=preferredGameServerSelectors,proto3" json:"preferredGameServerSelectors,omitempty"` // Scheduling strategy. Defaults to "Packed". Scheduling AllocationRequest_SchedulingStrategy `protobuf:"varint,5,opt,name=scheduling,proto3,enum=allocation.AllocationRequest_SchedulingStrategy" json:"scheduling,omitempty"` - // MetaPatch is optional custom metadata that is added to the game server at - // allocation You can use this to tell the server necessary session data - MetaPatch *MetaPatch `protobuf:"bytes,6,opt,name=metaPatch,proto3" json:"metaPatch,omitempty"` + // Deprecated: Please use metadata instead. This field is ignored if the + // metadata field is set + MetaPatch *MetaPatch `protobuf:"bytes,6,opt,name=metaPatch,proto3" json:"metaPatch,omitempty"` + // Metadata is optional custom metadata that is added to the game server at + // allocation. You can use this to tell the server necessary session data + Metadata *MetaPatch `protobuf:"bytes,7,opt,name=metadata,proto3" json:"metadata,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -90,7 +93,7 @@ func (m *AllocationRequest) Reset() { *m = AllocationRequest{} } func (m *AllocationRequest) String() string { return proto.CompactTextString(m) } func (*AllocationRequest) ProtoMessage() {} func (*AllocationRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_allocation_d5752a3ca48e8a0b, []int{0} + return fileDescriptor_allocation_0f914fcce1c5f3b7, []int{0} } func (m *AllocationRequest) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_AllocationRequest.Unmarshal(m, b) @@ -152,6 +155,13 @@ func (m *AllocationRequest) GetMetaPatch() *MetaPatch { return nil } +func (m *AllocationRequest) GetMetadata() *MetaPatch { + if m != nil { + return m.Metadata + } + return nil +} + type AllocationResponse struct { GameServerName string `protobuf:"bytes,2,opt,name=gameServerName,proto3" json:"gameServerName,omitempty"` Ports []*AllocationResponse_GameServerStatusPort `protobuf:"bytes,3,rep,name=ports,proto3" json:"ports,omitempty"` @@ -166,7 +176,7 @@ func (m *AllocationResponse) Reset() { *m = AllocationResponse{} } func (m *AllocationResponse) String() string { return proto.CompactTextString(m) } func (*AllocationResponse) ProtoMessage() {} func (*AllocationResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_allocation_d5752a3ca48e8a0b, []int{1} + return fileDescriptor_allocation_0f914fcce1c5f3b7, []int{1} } func (m *AllocationResponse) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_AllocationResponse.Unmarshal(m, b) @@ -229,7 +239,7 @@ func (m *AllocationResponse_GameServerStatusPort) Reset() { func (m *AllocationResponse_GameServerStatusPort) String() string { return proto.CompactTextString(m) } func (*AllocationResponse_GameServerStatusPort) ProtoMessage() {} func (*AllocationResponse_GameServerStatusPort) Descriptor() ([]byte, []int) { - return fileDescriptor_allocation_d5752a3ca48e8a0b, []int{1, 0} + return fileDescriptor_allocation_0f914fcce1c5f3b7, []int{1, 0} } func (m *AllocationResponse_GameServerStatusPort) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_AllocationResponse_GameServerStatusPort.Unmarshal(m, b) @@ -278,7 +288,7 @@ func (m *MultiClusterSetting) Reset() { *m = MultiClusterSetting{} } func (m *MultiClusterSetting) String() string { return proto.CompactTextString(m) } func (*MultiClusterSetting) ProtoMessage() {} func (*MultiClusterSetting) Descriptor() ([]byte, []int) { - return fileDescriptor_allocation_d5752a3ca48e8a0b, []int{2} + return fileDescriptor_allocation_0f914fcce1c5f3b7, []int{2} } func (m *MultiClusterSetting) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MultiClusterSetting.Unmarshal(m, b) @@ -325,7 +335,7 @@ func (m *MetaPatch) Reset() { *m = MetaPatch{} } func (m *MetaPatch) String() string { return proto.CompactTextString(m) } func (*MetaPatch) ProtoMessage() {} func (*MetaPatch) Descriptor() ([]byte, []int) { - return fileDescriptor_allocation_d5752a3ca48e8a0b, []int{3} + return fileDescriptor_allocation_0f914fcce1c5f3b7, []int{3} } func (m *MetaPatch) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_MetaPatch.Unmarshal(m, b) @@ -372,7 +382,7 @@ func (m *LabelSelector) Reset() { *m = LabelSelector{} } func (m *LabelSelector) String() string { return proto.CompactTextString(m) } func (*LabelSelector) ProtoMessage() {} func (*LabelSelector) Descriptor() ([]byte, []int) { - return fileDescriptor_allocation_d5752a3ca48e8a0b, []int{4} + return fileDescriptor_allocation_0f914fcce1c5f3b7, []int{4} } func (m *LabelSelector) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_LabelSelector.Unmarshal(m, b) @@ -485,48 +495,49 @@ var _AllocationService_serviceDesc = grpc.ServiceDesc{ } func init() { - proto.RegisterFile("proto/allocation/allocation.proto", fileDescriptor_allocation_d5752a3ca48e8a0b) -} - -var fileDescriptor_allocation_d5752a3ca48e8a0b = []byte{ - // 619 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4d, 0x6f, 0x13, 0x31, - 0x10, 0x65, 0x93, 0x26, 0x34, 0x13, 0x51, 0xc2, 0xb4, 0x95, 0x96, 0x55, 0x81, 0x74, 0x0f, 0x55, - 0xd5, 0x43, 0x02, 0xed, 0x85, 0xf6, 0x50, 0xa9, 0x02, 0x04, 0x48, 0x2d, 0x0a, 0x9b, 0x13, 0x07, - 0x0e, 0xce, 0xee, 0x90, 0xae, 0xea, 0xac, 0xb7, 0xb6, 0xb7, 0x52, 0x6e, 0x88, 0x2b, 0x47, 0xce, - 0xfc, 0x2a, 0xfe, 0x02, 0x3f, 0x82, 0x0b, 0x12, 0xb2, 0xf3, 0xe5, 0xa6, 0x69, 0x50, 0x6f, 0xf6, - 0xcc, 0x7b, 0xcf, 0x33, 0xcf, 0x63, 0xc3, 0x76, 0x2e, 0x85, 0x16, 0x6d, 0xc6, 0xb9, 0x88, 0x99, - 0x4e, 0x45, 0xe6, 0x2c, 0x5b, 0x36, 0x87, 0x30, 0x8b, 0x04, 0x5b, 0x7d, 0x21, 0xfa, 0x9c, 0xda, - 0x2c, 0x4f, 0xdb, 0x2c,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x2c, 0xe6, 0x9f, 0xcc, 0x80, 0x23, 0x11, 0x97, 0x1a, 0x1c, 0x42, 0xdd, 0x39, 0x00, 0x1b, 0x50, - 0xbe, 0xa0, 0xe1, 0xd8, 0x3c, 0xb3, 0xc4, 0x0d, 0xa8, 0x5c, 0x31, 0x5e, 0x4c, 0xe6, 0x60, 0xb4, - 0x39, 0x2a, 0xbd, 0xf4, 0x82, 0x63, 0x68, 0xcc, 0x6b, 0xdf, 0x85, 0x1f, 0xfe, 0xf4, 0xe0, 0xc1, - 0x35, 0xbf, 0xf0, 0x14, 0xea, 0x03, 0x53, 0xf3, 0xa9, 0x6b, 0xcb, 0xde, 0xad, 0xfe, 0xb6, 0xce, - 0x66, 0xe0, 0x71, 0x6b, 0x0e, 0xdd, 0xd4, 0x37, 0x0f, 0xb8, 0x4b, 0x7d, 0xfb, 0x5f, 0x3d, 0xf7, - 0x73, 0x34, 0x83, 0x96, 0xc6, 0x84, 0x17, 0xb0, 0x3a, 0x0e, 0x12, 0x3e, 0x59, 0xfa, 0xd2, 0x83, - 0xa7, 0xcb, 0x1f, 0x45, 0xd8, 0xfc, 0xf6, 0xeb, 0xf7, 0x8f, 0x52, 0x10, 0x6e, 0xb6, 0xcd, 0xe3, - 0x52, 0x76, 0x92, 0x67, 0x8c, 0x23, 0x6f, 0xaf, 0x57, 0xb5, 0xdf, 0xf4, 0xc1, 0xbf, 0x00, 0x00, - 0x00, 0xff, 0xff, 0xc8, 0x15, 0x3d, 0x53, 0xf5, 0x05, 0x00, 0x00, + proto.RegisterFile("proto/allocation/allocation.proto", fileDescriptor_allocation_0f914fcce1c5f3b7) +} + +var fileDescriptor_allocation_0f914fcce1c5f3b7 = []byte{ + // 633 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xc1, 0x6e, 0x13, 0x31, + 0x10, 0x65, 0x93, 0x26, 0x4d, 0x26, 0xa2, 0x84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xbe, 0x3a, 0xf6, 0x7f, 0xaa, + 0x07, 0x2d, 0x0e, 0x09, 0x2f, 0xa1, 0x36, 0x49, 0x12, 0x3e, 0x5d, 0xfa, 0x39, 0x78, 0xcf, 0x96, + 0x3f, 0x0a, 0xbf, 0xf5, 0xed, 0xf7, 0x9f, 0x1f, 0x25, 0xcf, 0xdf, 0xec, 0xe8, 0xc7, 0x25, 0xcd, + 0x24, 0xcf, 0x18, 0xc7, 0xce, 0x5e, 0xbf, 0x6a, 0x7e, 0xf6, 0xc3, 0x7f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x49, 0xf2, 0x73, 0x1a, 0x28, 0x06, 0x00, 0x00, } diff --git a/pkg/allocation/go/allocation.swagger.json b/pkg/allocation/go/allocation.swagger.json index 4bea5ff276..5a7998c3b1 100644 --- a/pkg/allocation/go/allocation.swagger.json +++ b/pkg/allocation/go/allocation.swagger.json @@ -91,7 +91,11 @@ }, "metaPatch": { "$ref": "#/definitions/allocationMetaPatch", - "title": "MetaPatch is optional custom metadata that is added to the game server at\nallocation You can use this to tell the server necessary session data" + "title": "Deprecated: Please use metadata instead. This field is ignored if the\nmetadata field is set" + }, + "metadata": { + "$ref": "#/definitions/allocationMetaPatch", + "title": "Metadata is optional custom metadata that is added to the game server at\nallocation. You can use this to tell the server necessary session data" } } }, diff --git a/proto/allocation/allocation.proto b/proto/allocation/allocation.proto index 4378ca84c2..79015130b2 100644 --- a/proto/allocation/allocation.proto +++ b/proto/allocation/allocation.proto @@ -48,9 +48,13 @@ message AllocationRequest { Distributed = 1; } - // MetaPatch is optional custom metadata that is added to the game server at - // allocation You can use this to tell the server necessary session data + // Deprecated: Please use metadata instead. This field is ignored if the + // metadata field is set MetaPatch metaPatch = 6; + + // Metadata is optional custom metadata that is added to the game server at + // allocation. You can use this to tell the server necessary session data + MetaPatch metadata = 7; } message AllocationResponse { diff --git a/site/content/en/docs/Advanced/allocator-service.md b/site/content/en/docs/Advanced/allocator-service.md index e5814d8cd8..ca00cd6745 100644 --- a/site/content/en/docs/Advanced/allocator-service.md +++ b/site/content/en/docs/Advanced/allocator-service.md @@ -173,7 +173,12 @@ You should expect to see the following output: ### Sending Data to the Game Server +{{% feature publishVersion="0.15.0" %}} +The service accepts a `metadata` field, which can be used to apply `labels` and `annotations` to the allocated `GameServer`. The old `metaPatch` fields is now deprecated, but can still be used for compatibility. If both `metadata` and `metaPatch` fields are set, `metaPatch` is ignored. +{{% /feature %}} +{{% feature expiryVersion="0.15.0" %}} The service accepts a `metaPatch` field, which can be used to apply `labels` and `annotations` to the allocated `GameServer`. +{{% /feature %}} ## Secrets Explained diff --git a/test/e2e/allocator_test.go b/test/e2e/allocator_test.go index 76fd8a5a48..6645c52a2e 100644 --- a/test/e2e/allocator_test.go +++ b/test/e2e/allocator_test.go @@ -76,7 +76,7 @@ func TestAllocator(t *testing.T) { RequiredGameServerSelector: &pb.LabelSelector{MatchLabels: map[string]string{agonesv1.FleetNameLabel: flt.ObjectMeta.Name}}, PreferredGameServerSelectors: []*pb.LabelSelector{{MatchLabels: map[string]string{agonesv1.FleetNameLabel: flt.ObjectMeta.Name}}}, Scheduling: pb.AllocationRequest_Packed, - MetaPatch: &pb.MetaPatch{Labels: map[string]string{"gslabel": "allocatedbytest"}}, + Metadata: &pb.MetaPatch{Labels: map[string]string{"gslabel": "allocatedbytest"}}, } // wait for the allocation system to come online @@ -124,7 +124,7 @@ func TestRestAllocator(t *testing.T) { RequiredGameServerSelector: &pb.LabelSelector{MatchLabels: map[string]string{agonesv1.FleetNameLabel: flt.ObjectMeta.Name}}, PreferredGameServerSelectors: []*pb.LabelSelector{{MatchLabels: map[string]string{agonesv1.FleetNameLabel: flt.ObjectMeta.Name}}}, Scheduling: pb.AllocationRequest_Packed, - MetaPatch: &pb.MetaPatch{Labels: map[string]string{"gslabel": "allocatedbytest"}}, + Metadata: &pb.MetaPatch{Labels: map[string]string{"gslabel": "allocatedbytest"}}, } tlsCfg, err := getTLSConfig(ctx, allocatorClientSecretNamespace, allocatorClientSecretName, tlsCA) if !assert.Nil(t, err) {