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

sdkserver: add functionality to set multiple game server annotations at once #3835

Open
antiphp opened this issue May 22, 2024 · 6 comments · May be fixed by #4001
Open

sdkserver: add functionality to set multiple game server annotations at once #3835

antiphp opened this issue May 22, 2024 · 6 comments · May be fixed by #4001
Labels
kind/feature New features for Agones stale Pending closure unless there is a strong objection.

Comments

@antiphp
Copy link
Contributor

antiphp commented May 22, 2024

Is your feature request related to a problem? Please describe.
When someone watches for game server changes, it is preferred to see one change, rather than many where it is hard to determine when the sequence of changes is finished.

Describe the solution you'd like
I suggest to implement a function for the sdk server to set multiple annotations at once. Currently only SetAnnotation (singular) exists.

Describe alternatives you've considered
Set an annotation that indicates that this is the last annotation.

Additional context
Related code: https://github.com/googleforgames/agones/blob/main/pkg/sdkserver/sdkserver.go#L580

@antiphp antiphp added the kind/feature New features for Agones label May 22, 2024
@frenchtoasters
Copy link

Hi @antiphp I would like to help out with this issue, I am new to the project and just had a few questions before jumping in.

Reading your solution it sounds like changing the gsAnnotations field to []map[string]string here

gsAnnotations map[string]string
then updating SetAnnotation (singular) to either append or overwrite.

Then adding a SetAnnotations (plural) that looks like func (s *SDKServer) SetAnnotations(_ context.Context, kv []*sdk.KeyValue) (*sdk.Empty, error).

Is that the line of thinking you would like here? Or do you think changing that property of the SDKServer to a slice would break something else?
Aside from adding a test is there anywhere you would like this implemented with this?

@antiphp
Copy link
Contributor Author

antiphp commented May 28, 2024

Hi,

the function signature for SetAnnotations (p) seems fine. One could think of making kv variadic, but it does not seem to be used that often in this project except for GRPC options.

What's the thinking behind append vs overwrite? In my opinion, the latter key will always overwrite, so
[]*sdk.KeyValue{{"foo":"bar"},{"foo":"baz"}} should always result in foo=baz. We could error but it doesn't feel right to add sophisticated logic to what is just a map and everyone expects it to act like a map. But note that this is only my opinion, I am not related to this project, so in the end someone else will review and decide.

Btw this ticket is related: #3834 - Removal of annotations.

Thanks for taking the initiative!

@frenchtoasters
Copy link

Hi,

the function signature for SetAnnotations (p) seems fine. One could think of making kv variadic, but it does not seem to be used that often in this project except for GRPC options.

What's the thinking behind append vs overwrite? In my opinion, the latter key will always overwrite, so []*sdk.KeyValue{{"foo":"bar"},{"foo":"baz"}} should always result in foo=baz. We could error but it doesn't feel right to add sophisticated logic to what is just a map and everyone expects it to act like a map. But note that this is only my opinion, I am not related to this project, so in the end someone else will review and decide.

Btw this ticket is related: #3834 - Removal of annotations.

Thanks for taking the initiative!

The idea to use append vs overwrite was so that we could handle updating multiple different annotations in the same function i.e. we would get []*sdk.KeyValue{{"foo":"bar"},{"some":"thing"}} and we needed both those annotations applied to the object. However this might just be a misunderstanding on my part of how the project invokes these under the hood.

I was thinking originally that we just wanted to be able to add multiple annotations that are passed to the function at once to a GameServer object. However it seems like the ask is more of not only add the annotations but to update the values of them as well. Which if that is the case I would agree completely that overwrite is the way to go instead of append.

@antiphp
Copy link
Contributor Author

antiphp commented Jun 25, 2024

👋 Are you still interested in opening a PR for that @frenchtoasters ? Otherwise I am thinking about doing it by myself in the near future.

@antiphp antiphp linked a pull request Sep 25, 2024 that will close this issue
@antiphp
Copy link
Contributor Author

antiphp commented Sep 25, 2024

Thoughts around this PR:

  1. Passing an empty string value could be used to remove the annotation (related to sdkserver: add functionality to remove game server annotations #3834), but it is a valid value, and SetAnnotation (singular) does not work like it, so it would be inconsistent.
  2. I would have loved to have SetAnnotations() accept variadic args for KeyValue (would make the introduction of KeyValues unnecessary), but I think it's not possible with Protobuf
  3. Is the same required for labels? (SetLabels) (not from my end yet)

Copy link

github-actions bot commented Nov 1, 2024

'This issue is marked as Stale due to inactivity for more than 30 days. To avoid being marked as 'stale' please add 'awaiting-maintainer' label or add a comment. Thank you for your contributions '

@github-actions github-actions bot added the stale Pending closure unless there is a strong objection. label Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New features for Agones stale Pending closure unless there is a strong objection.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants