Skip to content

Commit

Permalink
fix: random http route name (#1910)
Browse files Browse the repository at this point in the history
Signed-off-by: 逆流而上 <[email protected]>
  • Loading branch information
DokiDoki1103 authored Apr 17, 2024
1 parent 3007553 commit 6da88b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 3 additions & 5 deletions api/controller/apigateway/api_gateway_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/goodrain/rainbond/pkg/component/k8s"
httputil "github.com/goodrain/rainbond/util/http"
"github.com/sirupsen/logrus"
"github.com/twinj/uuid"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -154,11 +155,8 @@ func (g Struct) CreateHTTPAPIRoute(w http.ResponseWriter, r *http.Request) {

routeName = strings.ReplaceAll(routeName, "/", "p-p")
routeName = strings.ReplaceAll(routeName, "*", "s-s")
if len(routeName) > 30 {
apisixRouteHTTP.Name = routeName[:30]
} else {
apisixRouteHTTP.Name = routeName
}

apisixRouteHTTP.Name = uuid.NewV4().String()[0:8] //每次都让他变化,让 apisix controller去更新

route, err := c.ApisixRoutes(tenant.Namespace).Create(r.Context(), &v2.ApisixRoute{
TypeMeta: v1.TypeMeta{
Expand Down
2 changes: 2 additions & 0 deletions worker/appm/conversion/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"fmt"
v2 "github.com/apache/apisix-ingress-controller/pkg/kube/apisix/apis/config/v2"
"github.com/goodrain/rainbond/otherclient"
"github.com/twinj/uuid"
kubevirtv1 "kubevirt.io/api/core/v1"
"net"
"os"
Expand Down Expand Up @@ -68,6 +69,7 @@ func updateAPISixRoute(as *v1.AppService) error {
// 重新绑定他的后端地址
var backends []v2.ApisixRouteHTTPBackend
for _, apisixroute := range apisixRoutes.Items {
apisixroute.Spec.HTTP[0].Name = uuid.NewV4().String()[0:8]
for _, backend := range apisixroute.Spec.HTTP[0].Backends {
if backend.ServicePort.IntVal == int32(port.ContainerPort) {
backend.ServiceName = port.K8sServiceName
Expand Down

0 comments on commit 6da88b8

Please sign in to comment.