Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
水淹萌龙
kubesphere
提交
40ebeccf
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看板
提交
40ebeccf
编写于
5月 16, 2019
作者:
J
Jeff
提交者:
zryfish
5月 16, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
delete orphan resources where service deleted
上级
273aa010
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
8 deletion
+29
-8
cmd/controller-manager/app/controllers.go
cmd/controller-manager/app/controllers.go
+2
-1
pkg/controller/application/application_controller.go
pkg/controller/application/application_controller.go
+1
-1
pkg/controller/destinationrule/destinationrule_controller.go
pkg/controller/destinationrule/destinationrule_controller.go
+16
-4
pkg/controller/virtualservice/virtualservice_controller.go
pkg/controller/virtualservice/virtualservice_controller.go
+10
-2
未找到文件。
cmd/controller-manager/app/controllers.go
浏览文件 @
40ebeccf
...
...
@@ -88,7 +88,8 @@ func AddControllers(mgr manager.Manager, cfg *rest.Config, stopCh <-chan struct{
informerFactory
.
Core
()
.
V1
()
.
Services
(),
servicemeshInformer
.
Servicemesh
()
.
V1alpha2
()
.
ServicePolicies
(),
kubeClient
,
istioclient
)
istioclient
,
servicemeshclient
)
apController
:=
application
.
NewApplicationController
(
informerFactory
.
Core
()
.
V1
()
.
Services
(),
informerFactory
.
Apps
()
.
V1
()
.
Deployments
(),
...
...
pkg/controller/application/application_controller.go
浏览文件 @
40ebeccf
...
...
@@ -149,7 +149,7 @@ func NewApplicationController(serviceInformer coreinformers.ServiceInformer,
}
func
(
v
*
ApplicationController
)
Start
(
stopCh
<-
chan
struct
{})
error
{
v
.
Run
(
5
,
stopCh
)
v
.
Run
(
2
,
stopCh
)
return
nil
}
...
...
pkg/controller/destinationrule/destinationrule_controller.go
浏览文件 @
40ebeccf
...
...
@@ -34,6 +34,7 @@ import (
"k8s.io/client-go/util/workqueue"
"time"
servicemeshclient
"kubesphere.io/kubesphere/pkg/client/clientset/versioned"
servicemeshinformers
"kubesphere.io/kubesphere/pkg/client/informers/externalversions/servicemesh/v1alpha2"
servicemeshlisters
"kubesphere.io/kubesphere/pkg/client/listers/servicemesh/v1alpha2"
)
...
...
@@ -53,6 +54,7 @@ type DestinationRuleController struct {
client
clientset
.
Interface
destinationRuleClient
istioclientset
.
Interface
servicemeshClient
servicemeshclient
.
Interface
eventBroadcaster
record
.
EventBroadcaster
eventRecorder
record
.
EventRecorder
...
...
@@ -79,7 +81,8 @@ func NewDestinationRuleController(deploymentInformer informersv1.DeploymentInfor
serviceInformer
coreinformers
.
ServiceInformer
,
servicePolicyInformer
servicemeshinformers
.
ServicePolicyInformer
,
client
clientset
.
Interface
,
destinationRuleClient
istioclientset
.
Interface
)
*
DestinationRuleController
{
destinationRuleClient
istioclientset
.
Interface
,
servicemeshClient
servicemeshclient
.
Interface
)
*
DestinationRuleController
{
broadcaster
:=
record
.
NewBroadcaster
()
broadcaster
.
StartLogging
(
func
(
format
string
,
args
...
interface
{})
{
...
...
@@ -95,6 +98,7 @@ func NewDestinationRuleController(deploymentInformer informersv1.DeploymentInfor
v
:=
&
DestinationRuleController
{
client
:
client
,
destinationRuleClient
:
destinationRuleClient
,
servicemeshClient
:
servicemeshClient
,
queue
:
workqueue
.
NewNamedRateLimitingQueue
(
workqueue
.
DefaultControllerRateLimiter
(),
"destinationrule"
),
workerLoopPeriod
:
time
.
Second
,
}
...
...
@@ -211,12 +215,20 @@ func (v *DestinationRuleController) syncService(key string) error {
service
,
err
:=
v
.
serviceLister
.
Services
(
namespace
)
.
Get
(
name
)
if
err
!=
nil
{
//
D
elete the corresponding destinationrule if there is any, as the service has been deleted.
//
d
elete the corresponding destinationrule if there is any, as the service has been deleted.
err
=
v
.
destinationRuleClient
.
NetworkingV1alpha3
()
.
DestinationRules
(
namespace
)
.
Delete
(
name
,
nil
)
if
err
!=
nil
&&
!
errors
.
IsNotFound
(
err
)
{
log
.
Error
(
err
,
"delete destination rule failed"
,
"namespace"
,
namespace
,
"name"
,
name
)
return
err
}
// delete orphan service policy if there is any
err
=
v
.
servicemeshClient
.
ServicemeshV1alpha2
()
.
ServicePolicies
(
namespace
)
.
Delete
(
name
,
nil
)
if
err
!=
nil
&&
!
errors
.
IsNotFound
(
err
)
{
log
.
Error
(
err
,
"delete orphan service policy failed"
,
"namespace"
,
namespace
,
"name"
,
name
)
return
err
}
return
nil
}
...
...
@@ -332,9 +344,9 @@ func (v *DestinationRuleController) syncService(key string) error {
}
if
createDestinationRule
{
newDestinationRule
,
err
=
v
.
destinationRuleClient
.
NetworkingV1alpha3
()
.
DestinationRules
(
namespace
)
.
Create
(
newDestinationRule
)
_
,
err
=
v
.
destinationRuleClient
.
NetworkingV1alpha3
()
.
DestinationRules
(
namespace
)
.
Create
(
newDestinationRule
)
}
else
{
newDestinationRule
,
err
=
v
.
destinationRuleClient
.
NetworkingV1alpha3
()
.
DestinationRules
(
namespace
)
.
Update
(
newDestinationRule
)
_
,
err
=
v
.
destinationRuleClient
.
NetworkingV1alpha3
()
.
DestinationRules
(
namespace
)
.
Update
(
newDestinationRule
)
}
if
err
!=
nil
{
...
...
pkg/controller/virtualservice/virtualservice_controller.go
浏览文件 @
40ebeccf
...
...
@@ -231,6 +231,14 @@ func (v *VirtualServiceController) syncService(key string) error {
log
.
Error
(
err
,
"delete orphan virtualservice failed"
,
"namespace"
,
namespace
,
"name"
,
service
.
Name
)
return
err
}
// delete the orphan strategy if there is any
err
=
v
.
servicemeshClient
.
ServicemeshV1alpha2
()
.
Strategies
(
namespace
)
.
Delete
(
name
,
nil
)
if
err
!=
nil
&&
!
errors
.
IsNotFound
(
err
)
{
log
.
Error
(
err
,
"delete orphan strategy failed"
,
"namespace"
,
namespace
,
"name"
,
service
.
Name
)
return
err
}
return
nil
}
log
.
Error
(
err
,
"get service failed"
,
"namespace"
,
namespace
,
"name"
,
name
)
...
...
@@ -385,9 +393,9 @@ func (v *VirtualServiceController) syncService(key string) error {
}
if
createVirtualService
{
newVirtualService
,
err
=
v
.
virtualServiceClient
.
NetworkingV1alpha3
()
.
VirtualServices
(
namespace
)
.
Create
(
newVirtualService
)
_
,
err
=
v
.
virtualServiceClient
.
NetworkingV1alpha3
()
.
VirtualServices
(
namespace
)
.
Create
(
newVirtualService
)
}
else
{
newVirtualService
,
err
=
v
.
virtualServiceClient
.
NetworkingV1alpha3
()
.
VirtualServices
(
namespace
)
.
Update
(
newVirtualService
)
_
,
err
=
v
.
virtualServiceClient
.
NetworkingV1alpha3
()
.
VirtualServices
(
namespace
)
.
Update
(
newVirtualService
)
}
if
err
!=
nil
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录