openkruise / kruise-game

Game Servers Management on Kubernetes
https://openkruise.io/kruisegame/introduction
Apache License 2.0
419 stars 59 forks source link

Enhancement | Cloud Provider plugin add new function to determine whether allow to create pod when errors occurred #106

Closed chrisliu1995 closed 3 months ago

chrisliu1995 commented 1 year ago

Background

As https://github.com/openkruise/kruise-game/issues/15 mentioned, OKG already supported cloud providers & plugins mechanism by Kubernetes webhook. Plus, in order to increase network availability, OKG also supports the function of network asynchronous ready, running the plugin within a limited time to repeatedly establish & confirm the network until the network is ready.

However, the function of network asynchronous ready requires that the webhook can still allow the operation of creating pod when an error occurs, which actually is conflict with synchronous plugins, like Kubernetes-HostPort plugin, because synchronous plugins require pod & network ready at same time.

Proposal

Plugin interface add a new function IsSynchronous to determine whether allow to create pod when errors occurred.

The new Plugin interface would be:

type Plugin interface {
    Name() string
    // Alias define the plugin with similar func cross multi cloud provider
    Alias() string
    Init(client client.Client, options CloudProviderOptions, ctx context.Context) error
    // Pod Event handler
    OnPodAdded(client client.Client, pod *corev1.Pod, ctx context.Context) (*corev1.Pod, errors.PluginError)
    OnPodUpdated(client client.Client, pod *corev1.Pod, ctx context.Context) (*corev1.Pod, errors.PluginError)
    OnPodDeleted(client client.Client, pod *corev1.Pod, ctx context.Context) errors.PluginError

    // IsSynchronous determines whether allow to create pod when errors occurred.
    // If set to false, the webhook allows creating pods despite errors. If set to true, the webhook denies creating pods when errors occur.
    IsSynchronous() bool
}
ashish111333 commented 3 months ago

is this resolved ? can i work on this ?

chrisliu1995 commented 3 months ago

is this resolved ? can i work on this ?

Finally, this solution is not accepted. We got this solution to solve the problem(https://github.com/openkruise/kruise-game/pull/129)