You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "Saramanda9988 (via GitHub)" <gi...@apache.org> on 2026/03/28 05:34:03 UTC
[PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Saramanda9988 opened a new pull request, #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440
**Please provide a description of this PR:**
please refer to: #1399
### What changed
- Enhanced lifecycle state derivation for instances, including states such as Starting, Serving, Draining, Terminating, and Error.
- Improved runtime/RPC instance merge and cleanup behavior so instance resources are updated more accurately when one source disappears.
- Refined Kubernetes runtime instance identification and Pod phase detection, with stricter matching by mesh/app/IP/RPC port and better delete handling in informers.
- Updated sample/admin Kubernetes config to support pod watch selector and Dubbo RPC/registry labels.
- Updated Console UI to display lifecycle state in instance views, added manual refresh for the instance list, and tightened the toolbar spacing.
**To help us figure out who should review this PR, please put an X in all the areas that this PR affects.**
- [ ] Docs
- [x] Installation
- [x] User Experience
- [ ] Dubboctl
- [x] Console
- [x] Core Component
**Please check any characteristics that apply to this pull request.**
### screenshot
<img width="2561" height="1398" alt="688a9e56e44c538c3de8a7832c146d6d" src="https://github.com/user-attachments/assets/4f9f5543-7dcd-4527-8e1a-de581e508304" />
<img width="2561" height="1398" alt="09f994309f99d983c6ebc52f3094673b" src="https://github.com/user-attachments/assets/94bdd43e-75a3-420c-9829-30c7b3665d78" />
<img width="2561" height="1398" alt="b14c1a8429846bbcaf38ece7c9bf7f76" src="https://github.com/user-attachments/assets/7c9f8d4a-490f-4588-8197-be143f685eb8" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "Saramanda9988 (via GitHub)" <gi...@apache.org>.
Saramanda9988 commented on PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#issuecomment-4175624303
@robocanic Done, and the current style of the example list is as followed:
<img width="2064" height="1049" alt="6b9f7212644a55df17ffd9bc88222e9a" src="https://github.com/user-attachments/assets/4270144f-ae41-4f00-a980-3bd9d26a85bb" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "robocanic (via GitHub)" <gi...@apache.org>.
robocanic commented on code in PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#discussion_r3010098217
##########
pkg/core/engine/subscriber/runtime_instance.go:
##########
@@ -129,31 +131,110 @@ func (s *RuntimeInstanceEventSubscriber) processUpsert(rtInstanceRes *meshresour
// processDelete when runtime instance deleted, we should delete the corresponding instance resource
func (s *RuntimeInstanceEventSubscriber) processDelete(rtInstanceRes *meshresource.RuntimeInstanceResource) error {
- var instanceResource *meshresource.InstanceResource
- var err error
- switch rtInstanceRes.Spec.SourceEngineType {
- case string(enginecfg.Kubernetes):
- instanceResource, err = s.getRelatedInstanceByIP(rtInstanceRes)
- default:
- instanceResource, err = s.getRelatedInstanceByName(rtInstanceRes)
- }
+ instanceResource, err := s.getRelatedInstance(rtInstanceRes)
if err != nil {
return err
}
if instanceResource == nil {
logger.Warnf("cannot find instance resource by runtime instance %s, skipped deleting instance", rtInstanceRes.ResourceKey())
return nil
}
+ meshresource.ClearRuntimeInstanceFromInstance(instanceResource)
+ if meshresource.HasRPCInstanceSource(instanceResource) {
+ if err = s.instanceStore.Update(instanceResource); err != nil {
+ logger.Errorf("update instance resource failed after runtime delete, instance: %s, err: %s",
+ instanceResource.ResourceKey(), err.Error())
+ return err
+ }
+ logger.Infof("instance lifecycle runtime source removed, keep instance by rpc source, instance: %s, runtime: %s, registerState: registered",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
+ instanceUpdateEvent := events.NewResourceChangedEvent(cache.Updated, instanceResource, instanceResource)
+ s.eventEmitter.Send(instanceUpdateEvent)
+ logger.Debugf("runtime instance delete trigger instance update event, event: %s", instanceUpdateEvent.String())
+ return nil
+ }
if err = s.instanceStore.Delete(instanceResource); err != nil {
logger.Errorf("delete instance resource failed, instance: %s, err: %s", instanceResource.ResourceKey(), err.Error())
return err
}
+ logger.Infof("instance lifecycle runtime source removed and no rpc source remains, deleted instance: %s, runtime: %s",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
instanceDeleteEvent := events.NewResourceChangedEvent(cache.Deleted, instanceResource, nil)
s.eventEmitter.Send(instanceDeleteEvent)
logger.Debugf("runtime instance delete trigger instance delete event, event: %s", instanceDeleteEvent.String())
return nil
}
+func (s *RuntimeInstanceEventSubscriber) getRelatedInstance(
+ rtInstanceRes *meshresource.RuntimeInstanceResource) (*meshresource.InstanceResource, error) {
+ if rtInstanceRes == nil || rtInstanceRes.Spec == nil {
+ return nil, nil
+ }
+ switch rtInstanceRes.Spec.SourceEngineType {
+ case string(enginecfg.Kubernetes):
+ return s.getRelatedKubernetesInstance(rtInstanceRes)
+ default:
+ return s.getRelatedInstanceByName(rtInstanceRes)
+ }
+}
+
+func (s *RuntimeInstanceEventSubscriber) getRelatedKubernetesInstance(
Review Comment:
1. 这种情况是不是不太可能?rpc instance的生命周期长度是比runtime instance 短的。podIP存在的时候rpc instance 的ip不一定存在;但反过来,rpc instance的ip存在,一定能找到一个唯一的runtime instance。
<img width="1504" height="414" alt="PixPin_2026-03-30_22-09-46" src="https://github.com/user-attachments/assets/634bdd07-2c8a-416f-a613-f272c4ad0f8f" />
2. 用户如果不改造确实会有这个问题,但这个改造是需要用户去改造他们的CI/CD的,会有一定成本,这里确实需要在文档中说明并推荐用户进行标记
ip可以作为一个fallback,就通过resKey,resName都找不着再用ip。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#issuecomment-4175617538
## [](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "Saramanda9988 (via GitHub)" <gi...@apache.org>.
Saramanda9988 commented on code in PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#discussion_r3005663602
##########
pkg/core/engine/subscriber/runtime_instance.go:
##########
@@ -129,31 +131,110 @@ func (s *RuntimeInstanceEventSubscriber) processUpsert(rtInstanceRes *meshresour
// processDelete when runtime instance deleted, we should delete the corresponding instance resource
func (s *RuntimeInstanceEventSubscriber) processDelete(rtInstanceRes *meshresource.RuntimeInstanceResource) error {
- var instanceResource *meshresource.InstanceResource
- var err error
- switch rtInstanceRes.Spec.SourceEngineType {
- case string(enginecfg.Kubernetes):
- instanceResource, err = s.getRelatedInstanceByIP(rtInstanceRes)
- default:
- instanceResource, err = s.getRelatedInstanceByName(rtInstanceRes)
- }
+ instanceResource, err := s.getRelatedInstance(rtInstanceRes)
if err != nil {
return err
}
if instanceResource == nil {
logger.Warnf("cannot find instance resource by runtime instance %s, skipped deleting instance", rtInstanceRes.ResourceKey())
return nil
}
+ meshresource.ClearRuntimeInstanceFromInstance(instanceResource)
+ if meshresource.HasRPCInstanceSource(instanceResource) {
+ if err = s.instanceStore.Update(instanceResource); err != nil {
+ logger.Errorf("update instance resource failed after runtime delete, instance: %s, err: %s",
+ instanceResource.ResourceKey(), err.Error())
+ return err
+ }
+ logger.Infof("instance lifecycle runtime source removed, keep instance by rpc source, instance: %s, runtime: %s, registerState: registered",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
+ instanceUpdateEvent := events.NewResourceChangedEvent(cache.Updated, instanceResource, instanceResource)
+ s.eventEmitter.Send(instanceUpdateEvent)
+ logger.Debugf("runtime instance delete trigger instance update event, event: %s", instanceUpdateEvent.String())
+ return nil
+ }
if err = s.instanceStore.Delete(instanceResource); err != nil {
logger.Errorf("delete instance resource failed, instance: %s, err: %s", instanceResource.ResourceKey(), err.Error())
return err
}
+ logger.Infof("instance lifecycle runtime source removed and no rpc source remains, deleted instance: %s, runtime: %s",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
instanceDeleteEvent := events.NewResourceChangedEvent(cache.Deleted, instanceResource, nil)
s.eventEmitter.Send(instanceDeleteEvent)
logger.Debugf("runtime instance delete trigger instance delete event, event: %s", instanceDeleteEvent.String())
return nil
}
+func (s *RuntimeInstanceEventSubscriber) getRelatedInstance(
+ rtInstanceRes *meshresource.RuntimeInstanceResource) (*meshresource.InstanceResource, error) {
+ if rtInstanceRes == nil || rtInstanceRes.Spec == nil {
+ return nil, nil
+ }
+ switch rtInstanceRes.Spec.SourceEngineType {
+ case string(enginecfg.Kubernetes):
+ return s.getRelatedKubernetesInstance(rtInstanceRes)
+ default:
+ return s.getRelatedInstanceByName(rtInstanceRes)
+ }
+}
+
+func (s *RuntimeInstanceEventSubscriber) getRelatedKubernetesInstance(
Review Comment:
使用了label主要是因为
1. 这里拿到的是 podIP,不是 稳定的 serviceIP或者clusterIP,存在旧 rpc instance 残留和 podIP 复用窗口的时候,ip-only 容易把新 pod 的 runtime 信息合并到旧实例上,出现误关联。
2. starting 状态依赖 runtime 侧先创建/融合实例;如果不使用 label/annotation identifier 提供的 mesh/appName/rpcPort,rpc runtime 侧无法可靠识别实例(因为有attributeCheck,或许我们假定rpc一定会去注册?但是示例中的前端服务似乎不会注册到注册中心上),只能等注册中心返回 rpc instance 后再展示,starting 状态会无法显示。
我建议保留现在这样的逻辑,ip可以作为fallback,但是能否在文档中推荐用户标注相关label以获取更准确的生命周期显示?或者有其他更好的方案,比如这里的podIP使用clusterIP?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#issuecomment-4148196386
## [](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#issuecomment-4170739812
## [](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#issuecomment-4147241725
## [](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "robocanic (via GitHub)" <gi...@apache.org>.
robocanic merged PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#issuecomment-4148241720
## [](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "Saramanda9988 (via GitHub)" <gi...@apache.org>.
Saramanda9988 commented on code in PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#discussion_r3005663602
##########
pkg/core/engine/subscriber/runtime_instance.go:
##########
@@ -129,31 +131,110 @@ func (s *RuntimeInstanceEventSubscriber) processUpsert(rtInstanceRes *meshresour
// processDelete when runtime instance deleted, we should delete the corresponding instance resource
func (s *RuntimeInstanceEventSubscriber) processDelete(rtInstanceRes *meshresource.RuntimeInstanceResource) error {
- var instanceResource *meshresource.InstanceResource
- var err error
- switch rtInstanceRes.Spec.SourceEngineType {
- case string(enginecfg.Kubernetes):
- instanceResource, err = s.getRelatedInstanceByIP(rtInstanceRes)
- default:
- instanceResource, err = s.getRelatedInstanceByName(rtInstanceRes)
- }
+ instanceResource, err := s.getRelatedInstance(rtInstanceRes)
if err != nil {
return err
}
if instanceResource == nil {
logger.Warnf("cannot find instance resource by runtime instance %s, skipped deleting instance", rtInstanceRes.ResourceKey())
return nil
}
+ meshresource.ClearRuntimeInstanceFromInstance(instanceResource)
+ if meshresource.HasRPCInstanceSource(instanceResource) {
+ if err = s.instanceStore.Update(instanceResource); err != nil {
+ logger.Errorf("update instance resource failed after runtime delete, instance: %s, err: %s",
+ instanceResource.ResourceKey(), err.Error())
+ return err
+ }
+ logger.Infof("instance lifecycle runtime source removed, keep instance by rpc source, instance: %s, runtime: %s, registerState: registered",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
+ instanceUpdateEvent := events.NewResourceChangedEvent(cache.Updated, instanceResource, instanceResource)
+ s.eventEmitter.Send(instanceUpdateEvent)
+ logger.Debugf("runtime instance delete trigger instance update event, event: %s", instanceUpdateEvent.String())
+ return nil
+ }
if err = s.instanceStore.Delete(instanceResource); err != nil {
logger.Errorf("delete instance resource failed, instance: %s, err: %s", instanceResource.ResourceKey(), err.Error())
return err
}
+ logger.Infof("instance lifecycle runtime source removed and no rpc source remains, deleted instance: %s, runtime: %s",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
instanceDeleteEvent := events.NewResourceChangedEvent(cache.Deleted, instanceResource, nil)
s.eventEmitter.Send(instanceDeleteEvent)
logger.Debugf("runtime instance delete trigger instance delete event, event: %s", instanceDeleteEvent.String())
return nil
}
+func (s *RuntimeInstanceEventSubscriber) getRelatedInstance(
+ rtInstanceRes *meshresource.RuntimeInstanceResource) (*meshresource.InstanceResource, error) {
+ if rtInstanceRes == nil || rtInstanceRes.Spec == nil {
+ return nil, nil
+ }
+ switch rtInstanceRes.Spec.SourceEngineType {
+ case string(enginecfg.Kubernetes):
+ return s.getRelatedKubernetesInstance(rtInstanceRes)
+ default:
+ return s.getRelatedInstanceByName(rtInstanceRes)
+ }
+}
+
+func (s *RuntimeInstanceEventSubscriber) getRelatedKubernetesInstance(
Review Comment:
使用了label主要是因为
1. 这里拿到的是 podIP,不是 稳定的 serviceIP或者clusterIP,存在旧 rpc instance 残留和 podIP 复用窗口的时候,ip-only 容易把新 pod 的 runtime 信息合并到旧实例上,出现误关联。
2. starting 状态依赖 runtime 侧先创建/融合实例;如果不使用 label/annotation identifier 提供的 mesh/appName/rpcPort,rpc runtime 侧无法可靠识别实例(因为有attributeCheck,或许我们假定rpc一定会去注册?),只能等注册中心返回 rpc instance 后再展示,starting 状态会无法显示。
我建议保留现在这样的逻辑,ip可以作为fallback,但是能否在文档中推荐用户标注相关label以获取更准确的生命周期显示?或者有其他更好的方案,比如这里的podIP使用clusterIP?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "Saramanda9988 (via GitHub)" <gi...@apache.org>.
Saramanda9988 commented on code in PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#discussion_r3022557483
##########
pkg/core/engine/subscriber/runtime_instance.go:
##########
@@ -129,31 +131,110 @@ func (s *RuntimeInstanceEventSubscriber) processUpsert(rtInstanceRes *meshresour
// processDelete when runtime instance deleted, we should delete the corresponding instance resource
func (s *RuntimeInstanceEventSubscriber) processDelete(rtInstanceRes *meshresource.RuntimeInstanceResource) error {
- var instanceResource *meshresource.InstanceResource
- var err error
- switch rtInstanceRes.Spec.SourceEngineType {
- case string(enginecfg.Kubernetes):
- instanceResource, err = s.getRelatedInstanceByIP(rtInstanceRes)
- default:
- instanceResource, err = s.getRelatedInstanceByName(rtInstanceRes)
- }
+ instanceResource, err := s.getRelatedInstance(rtInstanceRes)
if err != nil {
return err
}
if instanceResource == nil {
logger.Warnf("cannot find instance resource by runtime instance %s, skipped deleting instance", rtInstanceRes.ResourceKey())
return nil
}
+ meshresource.ClearRuntimeInstanceFromInstance(instanceResource)
+ if meshresource.HasRPCInstanceSource(instanceResource) {
+ if err = s.instanceStore.Update(instanceResource); err != nil {
+ logger.Errorf("update instance resource failed after runtime delete, instance: %s, err: %s",
+ instanceResource.ResourceKey(), err.Error())
+ return err
+ }
+ logger.Infof("instance lifecycle runtime source removed, keep instance by rpc source, instance: %s, runtime: %s, registerState: registered",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
+ instanceUpdateEvent := events.NewResourceChangedEvent(cache.Updated, instanceResource, instanceResource)
+ s.eventEmitter.Send(instanceUpdateEvent)
+ logger.Debugf("runtime instance delete trigger instance update event, event: %s", instanceUpdateEvent.String())
+ return nil
+ }
if err = s.instanceStore.Delete(instanceResource); err != nil {
logger.Errorf("delete instance resource failed, instance: %s, err: %s", instanceResource.ResourceKey(), err.Error())
return err
}
+ logger.Infof("instance lifecycle runtime source removed and no rpc source remains, deleted instance: %s, runtime: %s",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
instanceDeleteEvent := events.NewResourceChangedEvent(cache.Deleted, instanceResource, nil)
s.eventEmitter.Send(instanceDeleteEvent)
logger.Debugf("runtime instance delete trigger instance delete event, event: %s", instanceDeleteEvent.String())
return nil
}
+func (s *RuntimeInstanceEventSubscriber) getRelatedInstance(
+ rtInstanceRes *meshresource.RuntimeInstanceResource) (*meshresource.InstanceResource, error) {
+ if rtInstanceRes == nil || rtInstanceRes.Spec == nil {
+ return nil, nil
+ }
+ switch rtInstanceRes.Spec.SourceEngineType {
+ case string(enginecfg.Kubernetes):
+ return s.getRelatedKubernetesInstance(rtInstanceRes)
+ default:
+ return s.getRelatedInstanceByName(rtInstanceRes)
+ }
+}
+
+func (s *RuntimeInstanceEventSubscriber) getRelatedKubernetesInstance(
Review Comment:
我理解的是CNI会先释放ip,pod再完全销毁,这个时间窗口里面可能会出现ip重叠?
不过我又思考了一下,这个问题应该不会在我们这里出现,
因为如果用户不打label,无法提前融合出instance,我们这里不会有这个窗口,打了label就能唯一确定,不会有这个窗口,是可行的
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "robocanic (via GitHub)" <gi...@apache.org>.
robocanic commented on code in PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#discussion_r3005615941
##########
pkg/core/discovery/subscriber/rpc_instance.go:
##########
@@ -184,7 +208,8 @@ func (s *RPCInstanceEventSubscriber) findRelatedRuntimeInstanceAndMerge(instance
}
}
-func (s *RPCInstanceEventSubscriber) getRuntimeInstanceByIp(ip string) *meshresource.RuntimeInstanceResource {
+func (s *RPCInstanceEventSubscriber) getRuntimeInstanceForInstance(instanceRes *meshresource.InstanceResource) *meshresource.RuntimeInstanceResource {
Review Comment:
Discussion: 这里用ip查出来之后,再用mesh,appName,rpcPort来做一个过滤选择,但可能都会被过滤掉,因为mesh,appName,rpcPort这些属性是需要用户在k8s pod部署时手动打上的。在之前的代码逻辑里面,确定engine type是k8s后用ip来查询,这是因为k8s中ip是唯一的,ip能够将pod和注册中心上的rpc instance一一关联起来,是没有问题的。所以这里建议是加一个兜底返回,或者还是用之前的逻辑
##########
ui-vue3/src/views/resources/applications/tabs/instance.vue:
##########
@@ -126,6 +142,12 @@ const columns = [
// sorter: true,
width: 150
},
+ {
Review Comment:
Discussion:生命周期状态是registerState和DeployState共同决定的,如果把这个生命周期的状态给放到顶部,挨着instanceName,会不会好一点?<img width="2123" height="990" alt="Image" src="https://github.com/user-attachments/assets/95bf249e-3735-4aac-9029-64c53dfc8d36" />
##########
pkg/core/engine/subscriber/runtime_instance.go:
##########
@@ -129,31 +131,110 @@ func (s *RuntimeInstanceEventSubscriber) processUpsert(rtInstanceRes *meshresour
// processDelete when runtime instance deleted, we should delete the corresponding instance resource
func (s *RuntimeInstanceEventSubscriber) processDelete(rtInstanceRes *meshresource.RuntimeInstanceResource) error {
- var instanceResource *meshresource.InstanceResource
- var err error
- switch rtInstanceRes.Spec.SourceEngineType {
- case string(enginecfg.Kubernetes):
- instanceResource, err = s.getRelatedInstanceByIP(rtInstanceRes)
- default:
- instanceResource, err = s.getRelatedInstanceByName(rtInstanceRes)
- }
+ instanceResource, err := s.getRelatedInstance(rtInstanceRes)
if err != nil {
return err
}
if instanceResource == nil {
logger.Warnf("cannot find instance resource by runtime instance %s, skipped deleting instance", rtInstanceRes.ResourceKey())
return nil
}
+ meshresource.ClearRuntimeInstanceFromInstance(instanceResource)
+ if meshresource.HasRPCInstanceSource(instanceResource) {
+ if err = s.instanceStore.Update(instanceResource); err != nil {
+ logger.Errorf("update instance resource failed after runtime delete, instance: %s, err: %s",
+ instanceResource.ResourceKey(), err.Error())
+ return err
+ }
+ logger.Infof("instance lifecycle runtime source removed, keep instance by rpc source, instance: %s, runtime: %s, registerState: registered",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
+ instanceUpdateEvent := events.NewResourceChangedEvent(cache.Updated, instanceResource, instanceResource)
+ s.eventEmitter.Send(instanceUpdateEvent)
+ logger.Debugf("runtime instance delete trigger instance update event, event: %s", instanceUpdateEvent.String())
+ return nil
+ }
if err = s.instanceStore.Delete(instanceResource); err != nil {
logger.Errorf("delete instance resource failed, instance: %s, err: %s", instanceResource.ResourceKey(), err.Error())
return err
}
+ logger.Infof("instance lifecycle runtime source removed and no rpc source remains, deleted instance: %s, runtime: %s",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
instanceDeleteEvent := events.NewResourceChangedEvent(cache.Deleted, instanceResource, nil)
s.eventEmitter.Send(instanceDeleteEvent)
logger.Debugf("runtime instance delete trigger instance delete event, event: %s", instanceDeleteEvent.String())
return nil
}
+func (s *RuntimeInstanceEventSubscriber) getRelatedInstance(
+ rtInstanceRes *meshresource.RuntimeInstanceResource) (*meshresource.InstanceResource, error) {
+ if rtInstanceRes == nil || rtInstanceRes.Spec == nil {
+ return nil, nil
+ }
+ switch rtInstanceRes.Spec.SourceEngineType {
+ case string(enginecfg.Kubernetes):
+ return s.getRelatedKubernetesInstance(rtInstanceRes)
+ default:
+ return s.getRelatedInstanceByName(rtInstanceRes)
+ }
+}
+
+func (s *RuntimeInstanceEventSubscriber) getRelatedKubernetesInstance(
Review Comment:
Discussion: 这里用两种方式来获取runtime instance对应的instance实例,但可能都获取不到,因为用户如果不在pod上打上对应的label/annotions,我们就不知道这个pod是对应哪个dubbo实例。但在k8s中,ip是唯一的,所以可以通过ip的唯一来关联到rpc instance和k8s pod。所以在之前的代码逻辑里,在确定engine type是k8s之后,就会通过runtime instance的ip来反查instance,这是没问题的。现在先用reskey,再用resName,但可以都获取不到。建议是加个通过ip查询来兜底或者是还是用之前的逻辑
##########
pkg/console/model/instance.go:
##########
@@ -196,3 +189,64 @@ func FromInstanceResource(res *meshresource.InstanceResource, cfg app.AdminConfi
}
return r
}
+
+func DeriveInstanceDeployState(instance *meshproto.Instance) string {
+ if instance == nil || strutil.IsBlank(instance.DeployState) {
+ return "Unknown"
+ }
+ switch instance.DeployState {
Review Comment:
Suggestion: 看能不能把DeployState,RegisterState,LifecycleState统统定义成枚举/自定义类型,定义在一个地方,再写上对应的注释,就能清楚每个state的具体含义
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "robocanic (via GitHub)" <gi...@apache.org>.
robocanic commented on code in PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#discussion_r3012957775
##########
pkg/core/engine/subscriber/runtime_instance.go:
##########
@@ -129,31 +131,110 @@ func (s *RuntimeInstanceEventSubscriber) processUpsert(rtInstanceRes *meshresour
// processDelete when runtime instance deleted, we should delete the corresponding instance resource
func (s *RuntimeInstanceEventSubscriber) processDelete(rtInstanceRes *meshresource.RuntimeInstanceResource) error {
- var instanceResource *meshresource.InstanceResource
- var err error
- switch rtInstanceRes.Spec.SourceEngineType {
- case string(enginecfg.Kubernetes):
- instanceResource, err = s.getRelatedInstanceByIP(rtInstanceRes)
- default:
- instanceResource, err = s.getRelatedInstanceByName(rtInstanceRes)
- }
+ instanceResource, err := s.getRelatedInstance(rtInstanceRes)
if err != nil {
return err
}
if instanceResource == nil {
logger.Warnf("cannot find instance resource by runtime instance %s, skipped deleting instance", rtInstanceRes.ResourceKey())
return nil
}
+ meshresource.ClearRuntimeInstanceFromInstance(instanceResource)
+ if meshresource.HasRPCInstanceSource(instanceResource) {
+ if err = s.instanceStore.Update(instanceResource); err != nil {
+ logger.Errorf("update instance resource failed after runtime delete, instance: %s, err: %s",
+ instanceResource.ResourceKey(), err.Error())
+ return err
+ }
+ logger.Infof("instance lifecycle runtime source removed, keep instance by rpc source, instance: %s, runtime: %s, registerState: registered",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
+ instanceUpdateEvent := events.NewResourceChangedEvent(cache.Updated, instanceResource, instanceResource)
+ s.eventEmitter.Send(instanceUpdateEvent)
+ logger.Debugf("runtime instance delete trigger instance update event, event: %s", instanceUpdateEvent.String())
+ return nil
+ }
if err = s.instanceStore.Delete(instanceResource); err != nil {
logger.Errorf("delete instance resource failed, instance: %s, err: %s", instanceResource.ResourceKey(), err.Error())
return err
}
+ logger.Infof("instance lifecycle runtime source removed and no rpc source remains, deleted instance: %s, runtime: %s",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
instanceDeleteEvent := events.NewResourceChangedEvent(cache.Deleted, instanceResource, nil)
s.eventEmitter.Send(instanceDeleteEvent)
logger.Debugf("runtime instance delete trigger instance delete event, event: %s", instanceDeleteEvent.String())
return nil
}
+func (s *RuntimeInstanceEventSubscriber) getRelatedInstance(
+ rtInstanceRes *meshresource.RuntimeInstanceResource) (*meshresource.InstanceResource, error) {
+ if rtInstanceRes == nil || rtInstanceRes.Spec == nil {
+ return nil, nil
+ }
+ switch rtInstanceRes.Spec.SourceEngineType {
+ case string(enginecfg.Kubernetes):
+ return s.getRelatedKubernetesInstance(rtInstanceRes)
+ default:
+ return s.getRelatedInstanceByName(rtInstanceRes)
+ }
+}
+
+func (s *RuntimeInstanceEventSubscriber) getRelatedKubernetesInstance(
Review Comment:
> 即旧的pod还没有完全销毁(发出delete事件),新的pod ip相同的pod已经上线
这在K8s官方文档里有说到吗,我印象中是旧Pod必须完全销毁之后,IP才能被其它新pod复用。
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#issuecomment-4169462394
## [](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_dubbo-admin&pullRequest=1440&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_dubbo-admin&pullRequest=1440&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_dubbo-admin&pullRequest=1440)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "robocanic (via GitHub)" <gi...@apache.org>.
robocanic commented on PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#issuecomment-4174133592
Please reslove the conflicts @Saramanda9988
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "Saramanda9988 (via GitHub)" <gi...@apache.org>.
Saramanda9988 commented on code in PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#discussion_r3010500692
##########
pkg/core/engine/subscriber/runtime_instance.go:
##########
@@ -129,31 +131,110 @@ func (s *RuntimeInstanceEventSubscriber) processUpsert(rtInstanceRes *meshresour
// processDelete when runtime instance deleted, we should delete the corresponding instance resource
func (s *RuntimeInstanceEventSubscriber) processDelete(rtInstanceRes *meshresource.RuntimeInstanceResource) error {
- var instanceResource *meshresource.InstanceResource
- var err error
- switch rtInstanceRes.Spec.SourceEngineType {
- case string(enginecfg.Kubernetes):
- instanceResource, err = s.getRelatedInstanceByIP(rtInstanceRes)
- default:
- instanceResource, err = s.getRelatedInstanceByName(rtInstanceRes)
- }
+ instanceResource, err := s.getRelatedInstance(rtInstanceRes)
if err != nil {
return err
}
if instanceResource == nil {
logger.Warnf("cannot find instance resource by runtime instance %s, skipped deleting instance", rtInstanceRes.ResourceKey())
return nil
}
+ meshresource.ClearRuntimeInstanceFromInstance(instanceResource)
+ if meshresource.HasRPCInstanceSource(instanceResource) {
+ if err = s.instanceStore.Update(instanceResource); err != nil {
+ logger.Errorf("update instance resource failed after runtime delete, instance: %s, err: %s",
+ instanceResource.ResourceKey(), err.Error())
+ return err
+ }
+ logger.Infof("instance lifecycle runtime source removed, keep instance by rpc source, instance: %s, runtime: %s, registerState: registered",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
+ instanceUpdateEvent := events.NewResourceChangedEvent(cache.Updated, instanceResource, instanceResource)
+ s.eventEmitter.Send(instanceUpdateEvent)
+ logger.Debugf("runtime instance delete trigger instance update event, event: %s", instanceUpdateEvent.String())
+ return nil
+ }
if err = s.instanceStore.Delete(instanceResource); err != nil {
logger.Errorf("delete instance resource failed, instance: %s, err: %s", instanceResource.ResourceKey(), err.Error())
return err
}
+ logger.Infof("instance lifecycle runtime source removed and no rpc source remains, deleted instance: %s, runtime: %s",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
instanceDeleteEvent := events.NewResourceChangedEvent(cache.Deleted, instanceResource, nil)
s.eventEmitter.Send(instanceDeleteEvent)
logger.Debugf("runtime instance delete trigger instance delete event, event: %s", instanceDeleteEvent.String())
return nil
}
+func (s *RuntimeInstanceEventSubscriber) getRelatedInstance(
+ rtInstanceRes *meshresource.RuntimeInstanceResource) (*meshresource.InstanceResource, error) {
+ if rtInstanceRes == nil || rtInstanceRes.Spec == nil {
+ return nil, nil
+ }
+ switch rtInstanceRes.Spec.SourceEngineType {
+ case string(enginecfg.Kubernetes):
+ return s.getRelatedKubernetesInstance(rtInstanceRes)
+ default:
+ return s.getRelatedInstanceByName(rtInstanceRes)
+ }
+}
+
+func (s *RuntimeInstanceEventSubscriber) getRelatedKubernetesInstance(
Review Comment:
对于第一个我可能说的不太准确,k8s在滚动更新的时候,pod ip是完全可以复用的,即旧的pod还没有完全销毁(发出delete事件),新的pod ip相同的pod已经上线,在下面这种情况,会出现实例生命周期混乱:
1. 旧 pod 的 RPC instance 还没从注册中心删除。
2. 新 pod 复用了旧 pod 的 IP。
3. 新 pod 的 runtime 事件先到。
用户没有配置 appName / rpcPort / mesh 这些 identifier,导致 runtime 侧只能走 IP fallback,这时 runtime 侧会把新 pod 的 K8s 状态 merge 到仍然挂着旧 pod RPC 信息的 InstanceResource 上,出现“旧 RPC 信息 + 新 runtime 状态”的混合态,旧实例的rpc注册一消失新实例变Draining或者Starting,之前复现的时候出现过一次,但是这种情况挺苛刻的,这样的时间窗口能否接受?
<img width="3899" height="1560" alt="mermaid-diagram-2026-03-30-230956" src="https://github.com/user-attachments/assets/544e8bbb-95ee-41b2-87b1-e76fedfd52a2" />
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org
Re: [PR] feat: unify and enhance the lifecycle of an instance [dubbo-admin]
Posted by "robocanic (via GitHub)" <gi...@apache.org>.
robocanic commented on code in PR #1440:
URL: https://github.com/apache/dubbo-admin/pull/1440#discussion_r3012957775
##########
pkg/core/engine/subscriber/runtime_instance.go:
##########
@@ -129,31 +131,110 @@ func (s *RuntimeInstanceEventSubscriber) processUpsert(rtInstanceRes *meshresour
// processDelete when runtime instance deleted, we should delete the corresponding instance resource
func (s *RuntimeInstanceEventSubscriber) processDelete(rtInstanceRes *meshresource.RuntimeInstanceResource) error {
- var instanceResource *meshresource.InstanceResource
- var err error
- switch rtInstanceRes.Spec.SourceEngineType {
- case string(enginecfg.Kubernetes):
- instanceResource, err = s.getRelatedInstanceByIP(rtInstanceRes)
- default:
- instanceResource, err = s.getRelatedInstanceByName(rtInstanceRes)
- }
+ instanceResource, err := s.getRelatedInstance(rtInstanceRes)
if err != nil {
return err
}
if instanceResource == nil {
logger.Warnf("cannot find instance resource by runtime instance %s, skipped deleting instance", rtInstanceRes.ResourceKey())
return nil
}
+ meshresource.ClearRuntimeInstanceFromInstance(instanceResource)
+ if meshresource.HasRPCInstanceSource(instanceResource) {
+ if err = s.instanceStore.Update(instanceResource); err != nil {
+ logger.Errorf("update instance resource failed after runtime delete, instance: %s, err: %s",
+ instanceResource.ResourceKey(), err.Error())
+ return err
+ }
+ logger.Infof("instance lifecycle runtime source removed, keep instance by rpc source, instance: %s, runtime: %s, registerState: registered",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
+ instanceUpdateEvent := events.NewResourceChangedEvent(cache.Updated, instanceResource, instanceResource)
+ s.eventEmitter.Send(instanceUpdateEvent)
+ logger.Debugf("runtime instance delete trigger instance update event, event: %s", instanceUpdateEvent.String())
+ return nil
+ }
if err = s.instanceStore.Delete(instanceResource); err != nil {
logger.Errorf("delete instance resource failed, instance: %s, err: %s", instanceResource.ResourceKey(), err.Error())
return err
}
+ logger.Infof("instance lifecycle runtime source removed and no rpc source remains, deleted instance: %s, runtime: %s",
+ instanceResource.ResourceKey(), rtInstanceRes.ResourceKey())
instanceDeleteEvent := events.NewResourceChangedEvent(cache.Deleted, instanceResource, nil)
s.eventEmitter.Send(instanceDeleteEvent)
logger.Debugf("runtime instance delete trigger instance delete event, event: %s", instanceDeleteEvent.String())
return nil
}
+func (s *RuntimeInstanceEventSubscriber) getRelatedInstance(
+ rtInstanceRes *meshresource.RuntimeInstanceResource) (*meshresource.InstanceResource, error) {
+ if rtInstanceRes == nil || rtInstanceRes.Spec == nil {
+ return nil, nil
+ }
+ switch rtInstanceRes.Spec.SourceEngineType {
+ case string(enginecfg.Kubernetes):
+ return s.getRelatedKubernetesInstance(rtInstanceRes)
+ default:
+ return s.getRelatedInstanceByName(rtInstanceRes)
+ }
+}
+
+func (s *RuntimeInstanceEventSubscriber) getRelatedKubernetesInstance(
Review Comment:
> 即旧的pod还没有完全销毁(发出delete事件),新的pod ip相同的pod已经上线
这在K8s官方文档里有说到吗,我印象中是旧Pod必须完全销毁之后,IP才能被其它新pod复用
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org