From 9230f03aa6e925980c50cc266403916a2ed6fd35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=96=8C?= Date: Tue, 21 Nov 2017 15:11:56 +0800 Subject: [PATCH 1/4] [FIX]Fix bug in create service when pluginrelation length is 0 --- pkg/worker/appm/pod.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/worker/appm/pod.go b/pkg/worker/appm/pod.go index 61d54892b..4ccb7a801 100644 --- a/pkg/worker/appm/pod.go +++ b/pkg/worker/appm/pod.go @@ -692,7 +692,7 @@ func (p *PodTemplateSpecBuild) createEnv() (*[]v1.EnvVar, error) { func (p *PodTemplateSpecBuild) createPluginsContainer(mainEnvs *[]v1.EnvVar) ([]v1.Container, []v1.Container, error) { var containers []v1.Container var initContainers []v1.Container - if len(p.pluginsRelation) == 0 { + if len(p.pluginsRelation) == 0 && !p.needProxy { return nil, containers, nil } netPlugin := false From 5ef9e238cdf4f8106f3fbbe661787250db1a6359 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=96=8C?= Date: Tue, 21 Nov 2017 15:44:14 +0800 Subject: [PATCH 2/4] [REV]Add etcd records compatibility --- pkg/node/core/service/discover_server.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/node/core/service/discover_server.go b/pkg/node/core/service/discover_server.go index 2fda1b184..84467291a 100644 --- a/pkg/node/core/service/discover_server.go +++ b/pkg/node/core/service/discover_server.go @@ -175,7 +175,7 @@ func (d *DiscoverAction) DiscoverListeners( envName := fmt.Sprintf("%s_%d", destServiceAlias, port) var sr api_model.NetDownStreamRules mr, err := d.ToolsGetStreamRules(namespace, node_model.DOWNSTREAM, envName, &sr) - if err != nil { + if err != nil && !strings.Contains(err.Error(), "is not exist") { logrus.Warnf("get env %s error, %v", envName, err) continue } @@ -271,7 +271,7 @@ func (d *DiscoverAction) DiscoverClusters( envName := fmt.Sprintf("%s_%d", destServiceAlias, port.Port) var sr api_model.NetDownStreamRules mr, err := d.ToolsGetStreamRules(namespace, node_model.DOWNSTREAM, envName, &sr) - if err != nil { + if err != nil && !strings.Contains(err.Error(), "is not exist") { logrus.Warnf("trans k %v error, %v", envName, err) continue } From 70a3b80558c9da120eb0250b4ee98f84d694986e Mon Sep 17 00:00:00 2001 From: ysicing Date: Tue, 21 Nov 2017 16:45:02 +0800 Subject: [PATCH 3/4] [REV] update the image name and packaging --- Makefile | 41 +++++++++++-------- hack/contrib/builder/deb/amd64/start-node.sh | 2 +- .../gr-rainbond-node/scripts/start-node.sh | 2 +- release.sh | 2 +- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index e2f947f32..c919c8fcc 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ clean: @rm -rf ./build/api/${BASE_NAME}_api @rm -rf ./build/node/${BASE_NAME}_node @rm -rf ./build/builder/${BASE_NAME}_builder + @rm -rf ./release/ run-api:build-api ./build/api/${BASE_NAME}_api --log-level=debug --mysql="admin:admin@tcp(127.0.0.1:3306)/region" --kube-config="`PWD`/admin.kubeconfig" @@ -58,23 +59,32 @@ build-grctl: build-api: go build ${GO_LDFLAGS} -o ./build/api/${BASE_NAME}_api ./cmd/api build-webcli: - go build ${GO_LDFLAGS} -o ./build/webcli/${BASE_NAME}_webcli ./cmd/webcli + go build ${GO_LDFLAGS} -o ./build/webcli/${BASE_NAME}_webcli ./cmd/webcli + +build-deb: + @bash ./release.sh build + @bash ./release.sh deb +build-rpm: + @bash ./release.sh build + @bash ./release.sh rpm +build-pkg: + @bash ./release.sh all-image: build-image-worker build-image-mq build-image-builder build-image-entrance build-image-eventlog build-image-api build-image-webcli build-image-worker: @echo "🐳 $@" @docker run -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:1.8.3 go build ${GO_LDFLAGS} -o ./build/worker/${BASE_NAME}_worker ./cmd/worker - @docker build -t hub.goodrain.com/dc-deploy/${BASE_NAME}_worker:${VERSION} ./build/worker + @docker build -t hub.goodrain.com/${BASE_NAME}/worker:${VERSION} ./build/worker @rm -f ./build/worker/${BASE_NAME}_worker build-image-mq: @echo "🐳 $@" @docker run -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:1.8.3 go build ${GO_LDFLAGS} -o ./build/mq/${BASE_NAME}_mq ./cmd/mq - @docker build -t hub.goodrain.com/dc-deploy/${BASE_NAME}_mq:${VERSION} ./build/mq + @docker build -t hub.goodrain.com/${BASE_NAME}/mq:${VERSION} ./build/mq @rm -f ./build/mq/${BASE_NAME}_mq build-image-builder: @echo "🐳 $@" @docker run -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:1.8.3 go build ${GO_LDFLAGS} -o ./build/builder/${BASE_NAME}_builder ./cmd/builder - @docker build -t hub.goodrain.com/dc-deploy/${BASE_NAME}_chaos:${VERSION} ./build/builder + @docker build -t hub.goodrain.com/${BASE_NAME}/chaos:${VERSION} ./build/builder @rm -f ./build/builder/${BASE_NAME}_builder build-image-node: @echo "🐳 $@" @@ -83,7 +93,7 @@ build-image-entrance: @echo "🐳 $@" @docker run -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:1.8.3 go build ${GO_LDFLAGS} -o ./build/entrance/${BASE_NAME}_entrance ./cmd/entrance @cp -r ./build/dist ./build/entrance/dist - @docker build -t hub.goodrain.com/dc-deploy/${BASE_NAME}_entrance:${VERSION} ./build/entrance + @docker build -t hub.goodrain.com/${BASE_NAME}/entrance:${VERSION} ./build/entrance @rm -rf ./build/entrance/dist @rm -f ./build/entrance/${BASE_NAME}_entrance build-image-eventlog: @@ -92,27 +102,26 @@ build-image-eventlog: @echo "building..." @docker run --rm -v `pwd`:${WORK_DIR} -w ${WORK_DIR} goodraim.me/event-build:v1 go build ${GO_LDFLAGS} -o ./build/eventlog/${BASE_NAME}_eventlog ./cmd/eventlog @echo "build done." - @docker build -t hub.goodrain.com/dc-deploy/${BASE_NAME}_eventlog:${VERSION} ./build/eventlog + @docker build -t hub.goodrain.com/${BASE_NAME}/eventlog:${VERSION} ./build/eventlog @rm -f ./build/entrance/${BASE_NAME}_eventlog build-image-api: @echo "🐳 $@" @docker run -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:1.8.3 go build ${GO_LDFLAGS} -o ./build/api/${BASE_NAME}_api ./cmd/api - @docker build -t hub.goodrain.com/dc-deploy/${BASE_NAME}_api:${VERSION} ./build/api + @docker build -t hub.goodrain.com/${BASE_NAME}/api:${VERSION} ./build/api @rm -f ./build/api/${BASE_NAME}_api build-image-webcli: @echo "🐳 $@" @docker run -v `pwd`:${WORK_DIR} -w ${WORK_DIR} -it golang:1.8.3 go build ${GO_LDFLAGS} -o ./build/webcli/${BASE_NAME}_webcli ./cmd/webcli - @docker build -t hub.goodrain.com/dc-deploy/${BASE_NAME}_webcli:${VERSION} ./build/webcli + @docker build -t hub.goodrain.com/${BASE_NAME}/webcli:${VERSION} ./build/webcli @rm -f ./build/webcli/${BASE_NAME}_webcli push-image: - docker push hub.goodrain.com/dc-deploy/${BASE_NAME}_eventlog:${VERSION} - docker push hub.goodrain.com/dc-deploy/${BASE_NAME}_entrance:${VERSION} - docker push hub.goodrain.com/dc-deploy/${BASE_NAME}_chaos:${VERSION} - docker push hub.goodrain.com/dc-deploy/${BASE_NAME}_mq:${VERSION} - docker push hub.goodrain.com/dc-deploy/${BASE_NAME}_worker:${VERSION} - docker push hub.goodrain.com/dc-deploy/${BASE_NAME}_webcli:${VERSION} - docker push hub.goodrain.com/dc-deploy/${BASE_NAME}_api:${VERSION} - + docker push hub.goodrain.com/${BASE_NAME}/eventlog:${VERSION} + docker push hub.goodrain.com/${BASE_NAME}/entrance:${VERSION} + docker push hub.goodrain.com/${BASE_NAME}/chaos:${VERSION} + docker push hub.goodrain.com/${BASE_NAME}/mq:${VERSION} + docker push hub.goodrain.com/${BASE_NAME}/worker:${VERSION} + docker push hub.goodrain.com/${BASE_NAME}/webcli:${VERSION} + docker push hub.goodrain.com/${BASE_NAME}/api:${VERSION} diff --git a/hack/contrib/builder/deb/amd64/start-node.sh b/hack/contrib/builder/deb/amd64/start-node.sh index fa2a0f3e0..a952424db 100755 --- a/hack/contrib/builder/deb/amd64/start-node.sh +++ b/hack/contrib/builder/deb/amd64/start-node.sh @@ -7,7 +7,7 @@ if [ -z $NODE_TYPE ];then eval $(ssh-agent) > /dev/null eval $(ssh-add) > /dev/null #eval $(ssh-add /path/key) > /dev/null - ACP_NODE_OPTS="--static-task-path=/usr/share/gr-rainbond-node/gaops/tasks/ --etcd=http://$ETCD_ADDR:2379 --hostIP=$HOSTIP --kube-conf=/etc/goodrain/kubernetes/kubeconfig --run-mode master --noderule manage" + ACP_NODE_OPTS="--static-task-path=/usr/share/gr-rainbond-node/gaops/tasks/ --etcd=http://$ETCD_ADDR:2379 --hostIP=$HOSTIP --kube-conf=/etc/goodrain/kubernetes/kubeconfig --run-mode master --noderule manage,compute" else ACP_NODE_OPTS='--log-level=debug' fi diff --git a/hack/rpm/centos-7/files/usr/share/gr-rainbond-node/scripts/start-node.sh b/hack/rpm/centos-7/files/usr/share/gr-rainbond-node/scripts/start-node.sh index 30d3501ab..4d933a712 100755 --- a/hack/rpm/centos-7/files/usr/share/gr-rainbond-node/scripts/start-node.sh +++ b/hack/rpm/centos-7/files/usr/share/gr-rainbond-node/scripts/start-node.sh @@ -7,7 +7,7 @@ if [ -z $NODE_TYPE ];then eval $(ssh-agent) > /dev/null eval $(ssh-add) > /dev/null #eval $(ssh-add /path/key) > /dev/null - ACP_NODE_OPTS="--static-task-path=/usr/share/gr-rainbond-node/gaops/tasks/ --etcd=http://$ETCD_ADDR:2379 --kube-conf=/etc/goodrain/kubernetes/kubeconfig --hostIP=$HOSTIP --run-mode master --noderule manage" + ACP_NODE_OPTS="--static-task-path=/usr/share/gr-rainbond-node/gaops/tasks/ --etcd=http://$ETCD_ADDR:2379 --kube-conf=/etc/goodrain/kubernetes/kubeconfig --hostIP=$HOSTIP --run-mode master --noderule manage,compute" else ACP_NODE_OPTS='--log-level=debug' fi diff --git a/release.sh b/release.sh index f258e3c56..7454553e5 100755 --- a/release.sh +++ b/release.sh @@ -34,7 +34,7 @@ function prepare() { cd $releasedir/tmp rm -rf .git - tar zcvf ../dist/usr/share/gr-rainbond-node/gaops/gaops.tgz ./ + tar zcf ../dist/usr/share/gr-rainbond-node/gaops/gaops.tgz ./ cd $path rm -rf $releasedir/tmp } From 5c7d1ff1418e412c377937d3576cb80d13aac84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B4=94=E6=96=8C?= Date: Tue, 21 Nov 2017 18:43:18 +0800 Subject: [PATCH 4/4] =?UTF-8?q?[REV]=20circuit=E2=80=99s=20params=20settin?= =?UTF-8?q?g,=201025=20as=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [DEL] del header setting --- pkg/node/api/model/discover.go | 8 ++--- pkg/node/core/service/discover_server.go | 41 ++++++++++++++++-------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/pkg/node/api/model/discover.go b/pkg/node/api/model/discover.go index 068bd6ff2..18e89506d 100644 --- a/pkg/node/api/model/discover.go +++ b/pkg/node/api/model/discover.go @@ -129,10 +129,10 @@ type PieceHTTPVirtualHost struct { //PieceHTTPRoutes PieceHTTPRoutes type PieceHTTPRoutes struct { - TimeoutMS int `json:"timeout_ms"` - Prefix string `json:"prefix"` - Cluster string `json:"cluster"` - Headers []*PieceHeader `json:"headers"` + TimeoutMS int `json:"timeout_ms"` + Prefix string `json:"prefix"` + Cluster string `json:"cluster"` + //Headers []*PieceHeader `json:"headers"` } //PieceHeader PieceHeader diff --git a/pkg/node/core/service/discover_server.go b/pkg/node/core/service/discover_server.go index 84467291a..3279f51c9 100644 --- a/pkg/node/core/service/discover_server.go +++ b/pkg/node/core/service/discover_server.go @@ -179,13 +179,15 @@ func (d *DiscoverAction) DiscoverListeners( logrus.Warnf("get env %s error, %v", envName, err) continue } - sr = mr.(api_model.NetDownStreamRules) + if mr != nil { + sr = mr.(api_model.NetDownStreamRules) + } prs := &node_model.PieceHTTPRoutes{ TimeoutMS: 0, Prefix: d.ToolsGetRouterItem(destServiceAlias, node_model.PREFIX, &sr).(string), Cluster: fmt.Sprintf("%s_%s_%d", namespace, destServiceAlias, port), - Headers: d.ToolsGetRouterItem(destServiceAlias, - node_model.HEADERS, &sr).([]*node_model.PieceHeader), + //Headers: d.ToolsGetRouterItem(destServiceAlias, + // node_model.HEADERS, &sr).([]*node_model.PieceHeader), } pvh := &node_model.PieceHTTPVirtualHost{ Name: fmt.Sprintf("%s_%s_%d", namespace, destServiceAlias, port), @@ -212,16 +214,22 @@ func (d *DiscoverAction) DiscoverListeners( return nil, util.CreateAPIHandleError(500, err) } } + if httpPort == nil { + httpPort = 80 + } hsf := &node_model.HTTPSingleFileter{ Type: "decoder", Name: "router", Config: make(map[string]string), } + rcg := &node_model.RouteConfig{ + VirtualHosts: vhL, + } lhc := &node_model.LDSHTTPConfig{ - CodecType: "auto", - StatPrefix: "ingress_http", - //RouteConfig: rcg, - Filters: []*node_model.HTTPSingleFileter{hsf}, + CodecType: "auto", + StatPrefix: "ingress_http", + RouteConfig: rcg, + Filters: []*node_model.HTTPSingleFileter{hsf}, } lfs := &node_model.LDSFilters{ Name: "http_connection_manager", @@ -275,8 +283,10 @@ func (d *DiscoverAction) DiscoverClusters( logrus.Warnf("trans k %v error, %v", envName, err) continue } - mc := mr.(*api_model.NetDownStreamRules) - circuits := d.ToolsGetRouterItem(destServiceAlias, node_model.LIMITS, mc).(int) + if mr != nil { + sr = mr.(api_model.NetDownStreamRules) + } + circuits := d.ToolsGetRouterItem(destServiceAlias, node_model.LIMITS, &sr).(int) cb := &node_model.CircuitBreakers{ Default: &node_model.MaxConnections{ MaxConnections: circuits, @@ -373,6 +383,9 @@ func (d *DiscoverAction) ToolsGetRouterItem( return "/" case node_model.LIMITS: if sr.Limit != 0 { + if sr.Limit == 1025 { + return 0 + } return sr.Limit } return 1024 @@ -388,8 +401,8 @@ func (d *DiscoverAction) ToolsGetRouterItem( } } ph := &node_model.PieceHeader{ - Name: "host", - Value: destAlias, + Name: "Connection", + Value: "keep-alive", } phL = append(phL, ph) return phL @@ -397,7 +410,7 @@ func (d *DiscoverAction) ToolsGetRouterItem( if sr.Domain != nil { return sr.Domain } - return []string{destAlias} + return []string{"*"} } return "" } @@ -420,8 +433,8 @@ func (d *DiscoverAction) ToolsGetStreamRules( return nil, util.CreateAPIHandleError(500, err) } } else { - logrus.Errorf("key %s is not exist,", envName) - return nil, util.CreateAPIHandleError(404, fmt.Errorf("key %s is not exist, ", envName)) + logrus.Debugf("key %s is not exist,", envName) + return nil, nil } if err := ffjson.Unmarshal([]byte(ss.SourceBody.EnvVal), rule); err != nil { logrus.Errorf("umashal value error, %v", err)