Skip to content

Commit

Permalink
fix: update route failure
Browse files Browse the repository at this point in the history
Signed-off-by: 张启航 <[email protected]>
  • Loading branch information
ZhangSetSail committed Nov 20, 2024
1 parent 69b86ef commit dd7fd3d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions worker/appm/store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ func (a *appRuntimeStore) ListServices(namespace string, selector labels.Selecto

func (a *appRuntimeStore) SyncUpdateApisixRoute(namespace, serviceAlias, serviceName string) {
routes, err := a.k8sClient.ApiSixClient.ApisixV2().ApisixRoutes(namespace).List(context.Background(), metav1.ListOptions{
LabelSelector: "service_alias=" + serviceAlias,
LabelSelector: serviceAlias + "=service_alias",
})
if err != nil {
logrus.Errorf("list routes failure: %v", err)
Expand All @@ -1986,9 +1986,8 @@ func (a *appRuntimeStore) SyncUpdateApisixRoute(namespace, serviceAlias, service
if backends != nil && len(backends) > 0 {
backend := backends[i]
if backend.ServiceName != serviceName {
// 更新 ServiceName
backend.ServiceName = serviceName
// 更新路由
route.Spec.HTTP[0].Backends[i].ServiceName = serviceName
_, err := a.k8sClient.ApiSixClient.ApisixV2().ApisixRoutes(namespace).Update(context.Background(), &route, metav1.UpdateOptions{})
if err != nil {
logrus.Errorf("update route failure: %v", err)
Expand Down

0 comments on commit dd7fd3d

Please sign in to comment.