topfreegames / pitaya

Scalable game server framework with clustering support and client libraries for iOS, Android, Unity and others through the C SDK.
MIT License
2.38k stars 480 forks source link

🐞ETCD configuration, the default configuration is lost, resulting in invalid configuration items #420

Open Tiper-In-Github opened 3 months ago

Tiper-In-Github commented 3 months ago

The configuration item with the problem is pitaya.cluster.sd.etcd.user and pitaya.cluster.sd.etcd.pass in etcd_service_discovery.go:

func (sd *etcdServiceDiscovery) configure(config config.EtcdServiceDiscoveryConfig) {
    sd.etcdEndpoints = config.Endpoints
    sd.etcdUser = config.User
    sd.etcdPass = config.Pass
    sd.etcdDialTimeout = config.DialTimeout
    sd.etcdPrefix = config.Prefix
    sd.heartbeatTTL = config.Heartbeat.TTL
    sd.logHeartbeat = config.Heartbeat.Log
    sd.syncServersInterval = config.SyncServers.Interval
    sd.revokeTimeout = config.Revoke.Timeout
    sd.grantLeaseTimeout = config.GrantLease.Timeout
    sd.grantLeaseMaxRetries = config.GrantLease.MaxRetries
    sd.grantLeaseInterval = config.GrantLease.RetryInterval
    sd.shutdownDelay = config.Shutdown.Delay
    sd.serverTypesBlacklist = config.ServerTypesBlacklist
    sd.syncServersParallelism = config.SyncServers.Parallelism
}

🥲but,in viper_config.go:

               "pitaya.cluster.rpc.server.nats.buffer.push":            pitayaConfig.Cluster.RPC.Server.Nats.Buffer.Push,
        "pitaya.cluster.sd.etcd.dialtimeout":                    pitayaConfig.Cluster.SD.Etcd.DialTimeout,
        "pitaya.cluster.sd.etcd.endpoints":                      pitayaConfig.Cluster.SD.Etcd.Endpoints,
        "pitaya.cluster.sd.etcd.prefix":                         pitayaConfig.Cluster.SD.Etcd.Prefix,
        "pitaya.cluster.sd.etcd.grantlease.maxretries":          pitayaConfig.Cluster.SD.Etcd.GrantLease.MaxRetries,
        "pitaya.cluster.sd.etcd.grantlease.retryinterval":       pitayaConfig.Cluster.SD.Etcd.GrantLease.RetryInterval,
        "pitaya.cluster.sd.etcd.grantlease.timeout":             pitayaConfig.Cluster.SD.Etcd.GrantLease.Timeout,
        "pitaya.cluster.sd.etcd.heartbeat.log":                  pitayaConfig.Cluster.SD.Etcd.Heartbeat.Log,
        "pitaya.cluster.sd.etcd.heartbeat.ttl":                  pitayaConfig.Cluster.SD.Etcd.Heartbeat.TTL,
        "pitaya.cluster.sd.etcd.revoke.timeout":                 pitayaConfig.Cluster.SD.Etcd.Revoke.Timeout,
        "pitaya.cluster.sd.etcd.syncservers.interval":           pitayaConfig.Cluster.SD.Etcd.SyncServers.Interval,
        "pitaya.cluster.sd.etcd.syncservers.parallelism":        pitayaConfig.Cluster.SD.Etcd.SyncServers.Parallelism,
        "pitaya.cluster.sd.etcd.shutdown.delay":                 pitayaConfig.Cluster.SD.Etcd.Shutdown.Delay,
        "pitaya.cluster.sd.etcd.servertypeblacklist":            pitayaConfig.Cluster.SD.Etcd.ServerTypesBlacklist,

These two configuration items are missing in the code. You need to add them and check whether there are the same problems in other places (such as groups) and fix them together.

Tiper-In-Github commented 3 months ago

Of course, I could simply fill in the missing configuration and get my own code to run, but I would like more inspection by a developer who is more familiar with the framework.

Tiper-In-Github commented 3 months ago

This problem will make it impossible to use authentication in the framework's native service discovery