最近在使用 sealos 安装更新 k8s 的过程中发现了一个问题: nfo new cluster version v1.25.10 behind the current version v1.25.8。
现在我来简单描述下过程: 我想要将 k8s 版本从 v1.25.8 升级到 v1.25.10,运行更新命令: sealos run labring/kubernetes:v1.25.10-4.2.0 -f 后,出现了以下错误信息:
2023-06-09T11:30:06 info new cluster version v1.25.10 behind the current version v1.25.8 ,通过对错误信息的理解,发现提示 v1.25.10 版本比 v1.25.8小,通过我对版本号的理解,这应该是个错误。
funcCompare(v1,v2string)bool{v1=strings.Replace(v1,"v","",-1)v2=strings.Replace(v2,"v","",-1)v1=strings.Split(v1,"-")[0]v2=strings.Split(v2,"-")[0]v1List:=strings.Split(v1,".")v2List:=strings.Split(v2,".")iflen(v1List)!=3||len(v2List)!=3{logger.Error("error version format %s%s",v1,v2)returnfalse}ifv1List[0]>v2List[0]{returntrue}elseifv1List[0]<v2List[0]{returnfalse}ifv1List[1]>v2List[1]{returntrue}elseifv1List[1]<v2List[1]{returnfalse}ifv1List[2]>=v2List[2]{returntrue}returnfalse}
funcCompare(v1,v2string)bool{v1=strings.Replace(v1,"v","",-1)v2=strings.Replace(v2,"v","",-1)v1=strings.Split(v1,"-")[0]v2=strings.Split(v2,"-")[0]v1List:=strings.Split(v1,".")v2List:=strings.Split(v2,".")iflen(v1List)!=3||len(v2List)!=3{logger.Error("error version format %s%s",v1,v2)returnfalse}fori:=0;i<len(v1List);i++{v1Num,_:=strconv.Atoi(v1List[i])v2Num,_:=strconv.Atoi(v2List[i])ifv1Num>v2Num{returntrue}elseifv1Num<v2Num{returnfalse}}returntrue}