kruise-game icon indicating copy to clipboard operation
kruise-game copied to clipboard

GameServer lifecycle optimization

Open chrisliu1995 opened this issue 1 year ago • 0 comments

Background

Currently, GameServer is recycled by the GameServerSet controller. When GameServerSet finds that the managed pods no longer exist in the cluster, the corresponding GameServers are deleted. One problem with this recycling method is that the life cycle of GameServer is not so certain. For example, when a pod is deleted and rebuilt, if the pod is rebuilt quickly, the GameServer will not be recycled and its attributes will still be retained; but if the rebuilt is slow, the GameServer will also be deleted and a new one will be created after the pod is created. GameServer with the same name, the status previously recorded in GameServer will be lost.

Proposal

I think we need a more deterministic approach to lifecycle management and leave the choice to the user. The user will decide whether the owner of GameServer is GameServerSet or Pod. If the owner is GameServerSet, GameServer will not be deleted when the pod is deleted. GameServer will be deleted only when GameServerSet is deleted. If the owner is GameServer, GameServer will be deleted when the pod is deleted.

背景

当前,GameServer是由GameServerSet控制器回收的,当GameServerSet发现管理的pods已经不存在集群,则删除对应的GameServers。这种回收方式有一个问题在于,GameServer的生命周期不是那么确定。比如在pod删除重建时,如果pod重建速度较快,则GameServer将不会被回收,它的属性也依旧保留;但如果重建较慢,则GameServer也将被删除,pod创建后会创建一个新的同名GameServer,之前记录在GameServer的状态将丢失。

提议

我认为我们需要一个更加确定的生命周期管理方式,并将选择权交由用户。用户将决定GameServer的owner是GameServerSet还是Pod。如果owner是GameServerSet,则pod删除时,GameServer不会被删除,当GameServerSet被删除,GameServer才会被删除。如果owner是GameServer,则pod删除时GameServer就会被删除。

chrisliu1995 avatar Oct 09 '23 07:10 chrisliu1995