Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
40e5920c
K
kubesphere
项目概览
水淹萌龙
/
kubesphere
与 Fork 源项目一致
Fork自
KubeSphere / kubesphere
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kubesphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
未验证
提交
40e5920c
编写于
3月 26, 2021
作者:
K
KubeSphere CI Bot
提交者:
GitHub
3月 26, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3574 from xyz-li/app-fix
Fix: handle invalid semver
上级
84d28f31
231d2213
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
39 addition
and
32 deletion
+39
-32
pkg/controller/openpitrix/helmapplication/helm_application_controller.go
...openpitrix/helmapplication/helm_application_controller.go
+1
-1
pkg/controller/openpitrix/helmapplication/helm_application_version_controller.go
...ix/helmapplication/helm_application_version_controller.go
+28
-26
pkg/models/openpitrix/utils.go
pkg/models/openpitrix/utils.go
+10
-5
未找到文件。
pkg/controller/openpitrix/helmapplication/helm_application_controller.go
浏览文件 @
40e5920c
...
...
@@ -52,7 +52,7 @@ const (
)
func
(
r
*
ReconcileHelmApplication
)
Reconcile
(
request
reconcile
.
Request
)
(
reconcile
.
Result
,
error
)
{
klog
.
V
(
4
)
.
Info
(
"sync helm application"
)
klog
.
V
(
4
)
.
Info
f
(
"sync helm application: %s "
,
request
.
String
()
)
rootCtx
:=
context
.
Background
()
app
:=
&
v1alpha1
.
HelmApplication
{}
...
...
pkg/controller/openpitrix/helmapplication/helm_application_version_controller.go
浏览文件 @
40e5920c
...
...
@@ -210,41 +210,42 @@ func (r *ReconcileHelmApplicationVersion) updateStatus(appVersion *v1alpha1.Helm
return
nil
}
// getLatestVersionName get the latest version of versions.
// if inAppStore is false, get the latest version name of all of the versions
// if inAppStore is true, get the latest version name of the ACTIVE versions.
func
getLatestVersionName
(
versions
v1alpha1
.
HelmApplicationVersionList
,
inAppStore
bool
)
string
{
l
:=
versions
.
Items
if
len
(
l
)
==
0
{
if
len
(
versions
.
Items
)
==
0
{
return
""
}
verInd
:=
0
if
inAppStore
{
// only check active app version
for
;
verInd
<
len
(
l
);
verInd
++
{
if
l
[
verInd
]
.
Status
.
State
==
v1alpha1
.
StateActive
{
break
}
}
}
if
verInd
==
len
(
l
)
{
return
""
}
var
latestVersionName
string
var
latestSemver
*
semver
.
Version
latestSemver
,
_
:=
semver
.
NewVersion
(
l
[
verInd
]
.
GetSemver
())
for
_
,
version
:=
range
versions
.
Items
{
// If the appVersion is being deleted, ignore it.
// If inAppStore is true, we just need ACTIVE appVersion.
if
version
.
DeletionTimestamp
!=
nil
||
(
inAppStore
&&
version
.
Status
.
State
!=
v1alpha1
.
StateActive
)
{
continue
}
for
i
:=
verInd
+
1
;
i
<
len
(
l
);
i
++
{
curr
,
_
:=
semver
.
NewVersion
(
l
[
i
]
.
GetSemver
())
if
inAppStore
{
if
l
[
i
]
.
Status
.
State
!=
v1alpha1
.
StateActive
{
continue
currSemver
,
err
:=
semver
.
NewVersion
(
version
.
GetSemver
())
if
err
==
nil
{
if
latestSemver
==
nil
{
// the first valid semver
latestSemver
=
currSemver
latestVersionName
=
version
.
GetVersionName
()
}
else
if
latestSemver
.
LessThan
(
currSemver
)
{
// find a newer valid semver
latestSemver
=
currSemver
latestVersionName
=
version
.
GetVersionName
()
}
}
if
latestSemver
.
LessThan
(
curr
)
{
verInd
=
i
}
else
{
// If the semver is invalid, just ignore it.
klog
.
V
(
2
)
.
Infof
(
"parse version failed, id: %s, err: %s"
,
version
.
Name
,
err
)
}
}
return
l
[
verInd
]
.
GetVersionName
()
return
l
atestVersionName
}
func
mergeApplicationVersionState
(
versions
v1alpha1
.
HelmApplicationVersionList
)
string
{
...
...
@@ -257,7 +258,7 @@ func mergeApplicationVersionState(versions v1alpha1.HelmApplicationVersionList)
}
}
// If there is on active appVersion, the helm application is active
// If there is on
e or more
active appVersion, the helm application is active
if
states
[
v1alpha1
.
StateActive
]
>
0
{
return
v1alpha1
.
StateActive
}
...
...
@@ -267,6 +268,7 @@ func mergeApplicationVersionState(versions v1alpha1.HelmApplicationVersionList)
return
v1alpha1
.
StateDraft
}
// No active appVersion or draft appVersion, then the app state is suspended
if
states
[
v1alpha1
.
StateSuspended
]
>
0
{
return
v1alpha1
.
StateSuspended
}
...
...
pkg/models/openpitrix/utils.go
浏览文件 @
40e5920c
...
...
@@ -32,7 +32,6 @@ import (
"kubesphere.io/kubesphere/pkg/utils/stringutils"
"path"
"regexp"
"sort"
"strings"
"time"
)
...
...
@@ -320,10 +319,16 @@ func convertApp(app *v1alpha1.HelmApplication, versions []*v1alpha1.HelmApplicat
}
else
{
out
.
CategorySet
=
AppCategorySet
{}
}
if
versions
!=
nil
&&
len
(
versions
)
>
0
{
sort
.
Sort
(
AppVersions
(
versions
))
out
.
LatestAppVersion
=
convertAppVersion
(
versions
[
len
(
versions
)
-
1
])
}
else
{
for
_
,
version
:=
range
versions
{
if
app
.
Status
.
LatestVersion
==
version
.
GetVersionName
()
{
// find the latest version, and convert its format
out
.
LatestAppVersion
=
convertAppVersion
(
version
)
break
}
}
if
out
.
LatestAppVersion
==
nil
{
out
.
LatestAppVersion
=
&
AppVersion
{}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录