radondb-mysql-kubernetes icon indicating copy to clipboard operation
radondb-mysql-kubernetes copied to clipboard

[bug] Not effective version of mysql56

Open hustjieke opened this issue 4 years ago • 3 comments

Describe the problem

The mysql version will never be mysql56:

166 // buildXenonConf build a config file for xenon.
167 func (cfg *Config) buildXenonConf() []byte {
               ....
               ....
171 
172         version := "mysql80"
173         if cfg.MySQLVersion.Major == 5 {
174                 if cfg.MySQLVersion.Minor == 6 {
175                         version = "mysql56"
176                 } else {
177                         version = "mysql57"
178                 }
179         }

In GetMySQLVersion, no matter what mysql version is, it always be 5.7 here.

113 // GetMySQLVersion returns the MySQL server version.
114 func (c *Cluster) GetMySQLVersion() string {
115         version := c.Spec.MysqlVersion
116         // lookup for an alias, usually this will solve 5.7 to 5.7.x
117         if v, ok := utils.MySQLTagsToSemVer[version]; ok { 
118                 version = v
119         }       
120                 
121         if _, ok := utils.MysqlImageVersions[version]; !ok {
122                 version = utils.MySQLDefaultVersion
123         }       
124         
125         return version
126 }

To Reproduce

Expected behavior

Environment:

  • RadonDB MySQL version:

hustjieke avatar Aug 26 '21 15:08 hustjieke

In utils/constants.go,

 23         // MySQLTagsToSemVer maps simple version to semver versions                                                                                         
 24         MySQLTagsToSemVer = map[string]string{                                                                                                              
 25                 "5.7": "5.7.33",                                                                                                                            
 26         }

If Spec.MysqlVersion is 5.5,5.6 or 8.0, it always be 5.7 after GetMySQLVersion() in line 126 next:

117 // GetMySQLVersion returns the MySQL server version.                                                                                                        
118 func (c *Cluster) GetMySQLVersion() string {                                                                                                                
119         version := c.Spec.MysqlVersion                                                                                                                      
120         // lookup for an alias, usually this will solve 5.7 to 5.7.x                                                                                        
121         if v, ok := utils.MySQLTagsToSemVer[version]; ok {                                                                                                  
122                 version = v                                                                                                                                 
123         }                                                                                                                                                   
124                                                                                                                                                             
125         if _, ok := utils.MysqlImageVersions[version]; !ok {                                                                                                
126                 version = utils.MySQLDefaultVersion                                                                                                         
127         }                                                                                                                                                   
128                                                                                                                                                             
129         return version                                                                                                                                      
130 }    

hustjieke avatar Sep 02 '21 06:09 hustjieke

The mysql5.6 is unsupported now. GetMySQLVersion will return default version if the mysql version unsupported. Maybe it would be better to return an error. https://github.com/radondb/radondb-mysql-kubernetes/blob/main/cluster/cluster.go#L122

zhyass avatar Sep 03 '21 03:09 zhyass

Also in sidecar/config.go we should panic but not log error here to prevent continue init work. e.g.: If user want 8.0.22, but our code has not the correct semver mysql version, this is our mistake and users want 8.0 not 5.7 or other versions.

82 // NewConfig returns a pointer to Config.                                                                                                                   
 83 func NewConfig() *Config {
 84         mysqlVersion, err := semver.Parse(getEnvValue("MYSQL_VERSION"))                                                                                     
 85         if err != nil {
 86                 log.Error("MYSQL_VERSION is not a semver version")
 87                 mysqlVersion, _ = semver.Parse(utils.MySQLDefaultVersion)
 88         }
...
...

hustjieke avatar Sep 06 '21 07:09 hustjieke