mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-29 18:27:58 +08:00
Merge branch 'V5.2'
This commit is contained in:
commit
4c9a81e83b
3
.gitignore
vendored
3
.gitignore
vendored
@ -58,4 +58,5 @@ vendor
|
|||||||
|
|
||||||
.scannerwork
|
.scannerwork
|
||||||
|
|
||||||
Library
|
Library
|
||||||
|
.cache
|
||||||
|
@ -643,6 +643,16 @@ func (g *GatewayAction) RuleConfig(req *apimodel.RuleConfigReq) error {
|
|||||||
Key: "proxy-body-size",
|
Key: "proxy-body-size",
|
||||||
Value: strconv.Itoa(req.Body.ProxyBodySize),
|
Value: strconv.Itoa(req.Body.ProxyBodySize),
|
||||||
})
|
})
|
||||||
|
configs = append(configs, &model.GwRuleConfig{
|
||||||
|
RuleID: req.RuleID,
|
||||||
|
Key: "proxy-buffer-size",
|
||||||
|
Value: strconv.Itoa(req.Body.ProxyBufferSize) + "k",
|
||||||
|
})
|
||||||
|
configs = append(configs, &model.GwRuleConfig{
|
||||||
|
RuleID: req.RuleID,
|
||||||
|
Key: "proxy-buffer-numbers",
|
||||||
|
Value: strconv.Itoa(req.Body.ProxyBufferNumbers),
|
||||||
|
})
|
||||||
setheaders := make(map[string]string)
|
setheaders := make(map[string]string)
|
||||||
for _, item := range req.Body.SetHeaders {
|
for _, item := range req.Body.SetHeaders {
|
||||||
if strings.TrimSpace(item.Key) == "" {
|
if strings.TrimSpace(item.Key) == "" {
|
||||||
@ -661,10 +671,12 @@ func (g *GatewayAction) RuleConfig(req *apimodel.RuleConfigReq) error {
|
|||||||
Value: v,
|
Value: v,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
rule, err := g.dbmanager.HTTPRuleDao().GetHTTPRuleByID(req.RuleID)
|
rule, err := g.dbmanager.HTTPRuleDao().GetHTTPRuleByID(req.RuleID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tx := db.GetManager().Begin()
|
tx := db.GetManager().Begin()
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
@ -686,6 +698,7 @@ func (g *GatewayAction) RuleConfig(req *apimodel.RuleConfigReq) error {
|
|||||||
tx.Rollback()
|
tx.Rollback()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := g.SendTask(map[string]interface{}{
|
if err := g.SendTask(map[string]interface{}{
|
||||||
"service_id": req.ServiceID,
|
"service_id": req.ServiceID,
|
||||||
"action": "update-rule-config",
|
"action": "update-rule-config",
|
||||||
|
@ -312,18 +312,19 @@ func (s *ServiceDependency) buildLinkListByHead(l *list.List) []*list.List {
|
|||||||
if !ok {
|
if !ok {
|
||||||
copy := list.New()
|
copy := list.New()
|
||||||
copy.PushBackList(l)
|
copy.PushBackList(l)
|
||||||
return []*list.List{l}
|
return []*list.List{copy}
|
||||||
}
|
}
|
||||||
|
|
||||||
var result []*list.List
|
var result []*list.List
|
||||||
for _, depsid := range depsids {
|
for _, depsid := range depsids {
|
||||||
// child node is already in the linked list
|
// child node is already in the linked list
|
||||||
if alreadyInLinkedList(l, depsid) {
|
if alreadyInLinkedList(l, depsid) || s.childInLinkedList(l, depsid) {
|
||||||
copy := list.New()
|
copy := list.New()
|
||||||
copy.PushBackList(l)
|
copy.PushBackList(l)
|
||||||
result = append(result, copy)
|
result = append(result, copy)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
newl := list.New()
|
newl := list.New()
|
||||||
newl.PushBackList(l)
|
newl.PushBackList(l)
|
||||||
newl.PushBack(depsid)
|
newl.PushBack(depsid)
|
||||||
@ -341,6 +342,21 @@ func (s *ServiceDependency) buildLinkListByHead(l *list.List) []*list.List {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *ServiceDependency) childInLinkedList(l *list.List, sid string) bool {
|
||||||
|
depsids, ok := s.sid2depsids[sid]
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, depsid := range depsids {
|
||||||
|
if alreadyInLinkedList(l, depsid) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func alreadyInLinkedList(l *list.List, depsid string) bool {
|
func alreadyInLinkedList(l *list.List, depsid string) bool {
|
||||||
pre := l.Back()
|
pre := l.Back()
|
||||||
for pre != nil {
|
for pre != nil {
|
||||||
|
@ -167,6 +167,32 @@ func TestBuildLinkListByHead(t *testing.T) {
|
|||||||
return []*list.List{l}
|
return []*list.List{l}
|
||||||
}(),
|
}(),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "spring cloud pig",
|
||||||
|
l: func() *list.List {
|
||||||
|
l := list.New()
|
||||||
|
l.PushBack("banana")
|
||||||
|
return l
|
||||||
|
}(),
|
||||||
|
sid2depsids: map[string][]string{
|
||||||
|
"apple": []string{"banana"},
|
||||||
|
"banana": []string{"apple", "cat", "dog"},
|
||||||
|
},
|
||||||
|
want: func() []*list.List {
|
||||||
|
l1 := list.New()
|
||||||
|
l1.PushBack("banana")
|
||||||
|
|
||||||
|
l2 := list.New()
|
||||||
|
l2.PushBack("banana")
|
||||||
|
l2.PushBack("cat")
|
||||||
|
|
||||||
|
l3 := list.New()
|
||||||
|
l3.PushBack("banana")
|
||||||
|
l3.PushBack("dog")
|
||||||
|
|
||||||
|
return []*list.List{l1, l2, l3}
|
||||||
|
}(),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for idx := range tests {
|
for idx := range tests {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
dbmodel "github.com/goodrain/rainbond/db/model"
|
dbmodel "github.com/goodrain/rainbond/db/model"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// CheckTenantResource check tenant's resource is support action or not
|
// CheckTenantResource check tenant's resource is support action or not
|
||||||
@ -22,7 +22,7 @@ func CheckTenantResource(tenant *dbmodel.Tenants, needMemory int) error {
|
|||||||
}
|
}
|
||||||
clusterInfo, err := GetTenantManager().GetAllocatableResources()
|
clusterInfo, err := GetTenantManager().GetAllocatableResources()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("get cluster resources failure for check tenant resource : %v.", err.Error())
|
logrus.Errorf("get cluster resources failure for check tenant resource: %v", err.Error())
|
||||||
}
|
}
|
||||||
if clusterInfo != nil {
|
if clusterInfo != nil {
|
||||||
clusterAvailMemory := clusterInfo.AllMemory - clusterInfo.RequestMemory
|
clusterAvailMemory := clusterInfo.AllMemory - clusterInfo.RequestMemory
|
||||||
|
@ -129,6 +129,8 @@ type Body struct {
|
|||||||
ProxyBodySize int `json:"proxy_body_size,omitempty" validate:"proxy_body_size|required"`
|
ProxyBodySize int `json:"proxy_body_size,omitempty" validate:"proxy_body_size|required"`
|
||||||
SetHeaders []*SetHeader `json:"set_headers,omitempty" `
|
SetHeaders []*SetHeader `json:"set_headers,omitempty" `
|
||||||
Rewrites []*Rewrite `json:"rewrite,omitempty"`
|
Rewrites []*Rewrite `json:"rewrite,omitempty"`
|
||||||
|
ProxyBufferSize int `json:"proxy_buffer_size,omitempty"`
|
||||||
|
ProxyBufferNumbers int `json:"proxy_buffer_numbers,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//SetHeader set header
|
//SetHeader set header
|
||||||
|
@ -195,7 +195,7 @@ func (d *DockerComposeParse) Parse() ParseErrorList {
|
|||||||
d.logger.Debug(fmt.Sprintf("start check service %s ", service.name), map[string]string{"step": "service_check", "status": "running"})
|
d.logger.Debug(fmt.Sprintf("start check service %s ", service.name), map[string]string{"step": "service_check", "status": "running"})
|
||||||
exist, err := sources.ImageExist(service.image.String(), hubUser, hubPass)
|
exist, err := sources.ImageExist(service.image.String(), hubUser, hubPass)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("check image exist failure %s", err.Error())
|
logrus.Errorf("check image(%s) exist failure %s", service.image.String(), err.Error())
|
||||||
}
|
}
|
||||||
if !exist {
|
if !exist {
|
||||||
d.errappend(ErrorAndSolve(FatalError, fmt.Sprintf("服务%s镜像%s检测失败", serviceName, service.image.String()), SolveAdvice("modify_compose", fmt.Sprintf("请确认%s服务镜像名称是否正确或镜像仓库访问是否正常", serviceName))))
|
d.errappend(ErrorAndSolve(FatalError, fmt.Sprintf("服务%s镜像%s检测失败", serviceName, service.image.String()), SolveAdvice("modify_compose", fmt.Sprintf("请确认%s服务镜像名称是否正确或镜像仓库访问是否正常", serviceName))))
|
||||||
|
@ -19,10 +19,12 @@
|
|||||||
package sources
|
package sources
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"github.com/goodrain/rainbond/builder/sources/registry"
|
"github.com/goodrain/rainbond/builder/sources/registry"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"github.com/docker/distribution/reference"
|
"github.com/docker/distribution/reference"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
//GetTagFromNamedRef get image tag by name
|
//GetTagFromNamedRef get image tag by name
|
||||||
@ -67,9 +69,8 @@ func ImageExist(imageName, user, password string) (bool, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tag := GetTagFromNamedRef(name)
|
tag := GetTagFromNamedRef(name)
|
||||||
_, err = reg.ManifestV2(reference.Path(name), tag)
|
if err := reg.CheckManifest(reference.Path(name), tag); err != nil {
|
||||||
if err != nil {
|
rerr = fmt.Errorf("[ImageExist] check manifest v2: %v", err)
|
||||||
rerr = err
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
|
@ -20,14 +20,17 @@ package registry
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
manifestV1 "github.com/docker/distribution/manifest/schema1"
|
manifestV1 "github.com/docker/distribution/manifest/schema1"
|
||||||
manifestV2 "github.com/docker/distribution/manifest/schema2"
|
manifestV2 "github.com/docker/distribution/manifest/schema2"
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Manifest -
|
||||||
func (registry *Registry) Manifest(repository, reference string) (*manifestV1.SignedManifest, error) {
|
func (registry *Registry) Manifest(repository, reference string) (*manifestV1.SignedManifest, error) {
|
||||||
url := registry.url("/v2/%s/manifests/%s", repository, reference)
|
url := registry.url("/v2/%s/manifests/%s", repository, reference)
|
||||||
registry.Logf("registry.manifest.get url=%s repository=%s reference=%s", url, repository, reference)
|
registry.Logf("registry.manifest.get url=%s repository=%s reference=%s", url, repository, reference)
|
||||||
@ -58,9 +61,10 @@ func (registry *Registry) Manifest(repository, reference string) (*manifestV1.Si
|
|||||||
return signedManifest, nil
|
return signedManifest, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ManifestV2 -
|
||||||
func (registry *Registry) ManifestV2(repository, reference string) (*manifestV2.DeserializedManifest, error) {
|
func (registry *Registry) ManifestV2(repository, reference string) (*manifestV2.DeserializedManifest, error) {
|
||||||
url := registry.url("/v2/%s/manifests/%s", repository, reference)
|
url := registry.url("/v2/%s/manifests/%s", repository, reference)
|
||||||
registry.Logf("registry.manifest.get url=%s repository=%s reference=%s", url, repository, reference)
|
logrus.Debugf("registry.manifest.get url=%s repository=%s reference=%s", url, repository, reference)
|
||||||
|
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -70,7 +74,7 @@ func (registry *Registry) ManifestV2(repository, reference string) (*manifestV2.
|
|||||||
req.Header.Set("Accept", manifestV2.MediaTypeManifest)
|
req.Header.Set("Accept", manifestV2.MediaTypeManifest)
|
||||||
resp, err := registry.Client.Do(req)
|
resp, err := registry.Client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("do request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
@ -82,11 +86,25 @@ func (registry *Registry) ManifestV2(repository, reference string) (*manifestV2.
|
|||||||
deserialized := &manifestV2.DeserializedManifest{}
|
deserialized := &manifestV2.DeserializedManifest{}
|
||||||
err = deserialized.UnmarshalJSON(body)
|
err = deserialized.UnmarshalJSON(body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("unmarshal JSON: %v", err)
|
||||||
}
|
}
|
||||||
return deserialized, nil
|
return deserialized, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckManifest checks if the manifest of the given image is exist.
|
||||||
|
func (registry *Registry) CheckManifest(repository, reference string) error {
|
||||||
|
url := registry.url("/v2/%s/manifests/%s", repository, reference)
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = registry.Client.Do(req)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// ManifestDigest -
|
||||||
func (registry *Registry) ManifestDigest(repository, reference string) (digest.Digest, error) {
|
func (registry *Registry) ManifestDigest(repository, reference string) (digest.Digest, error) {
|
||||||
url := registry.url("/v2/%s/manifests/%s", repository, reference)
|
url := registry.url("/v2/%s/manifests/%s", repository, reference)
|
||||||
registry.Logf("registry.manifest.head url=%s repository=%s reference=%s", url, repository, reference)
|
registry.Logf("registry.manifest.head url=%s repository=%s reference=%s", url, repository, reference)
|
||||||
@ -101,6 +119,7 @@ func (registry *Registry) ManifestDigest(repository, reference string) (digest.D
|
|||||||
return digest.Parse(resp.Header.Get("Docker-Content-Digest"))
|
return digest.Parse(resp.Header.Get("Docker-Content-Digest"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeleteManifest -
|
||||||
func (registry *Registry) DeleteManifest(repository string, digest digest.Digest) error {
|
func (registry *Registry) DeleteManifest(repository string, digest digest.Digest) error {
|
||||||
url := registry.url("/v2/%s/manifests/%s", repository, digest)
|
url := registry.url("/v2/%s/manifests/%s", repository, digest)
|
||||||
registry.Logf("registry.manifest.delete url=%s repository=%s reference=%s", url, repository, digest)
|
registry.Logf("registry.manifest.delete url=%s repository=%s reference=%s", url, repository, digest)
|
||||||
@ -119,6 +138,7 @@ func (registry *Registry) DeleteManifest(repository string, digest digest.Digest
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PutManifest -
|
||||||
func (registry *Registry) PutManifest(repository, reference string, signedManifest *manifestV1.SignedManifest) error {
|
func (registry *Registry) PutManifest(repository, reference string, signedManifest *manifestV1.SignedManifest) error {
|
||||||
url := registry.url("/v2/%s/manifests/%s", repository, reference)
|
url := registry.url("/v2/%s/manifests/%s", repository, reference)
|
||||||
registry.Logf("registry.manifest.put url=%s repository=%s reference=%s", url, repository, reference)
|
registry.Logf("registry.manifest.put url=%s repository=%s reference=%s", url, repository, reference)
|
||||||
|
@ -78,12 +78,7 @@ func NewDependServiceHealthController() (*DependServiceHealthController, error)
|
|||||||
}
|
}
|
||||||
dsc.endpointClient = v2.NewEndpointDiscoveryServiceClient(cli)
|
dsc.endpointClient = v2.NewEndpointDiscoveryServiceClient(cli)
|
||||||
dsc.clusterClient = v2.NewClusterDiscoveryServiceClient(cli)
|
dsc.clusterClient = v2.NewClusterDiscoveryServiceClient(cli)
|
||||||
nameIDs := strings.Split(os.Getenv("DEPEND_SERVICE"), ",")
|
dsc.dependServiceNames = strings.Split(os.Getenv("STARTUP_SEQUENCE_DEPENDENCIES"), ",")
|
||||||
for _, nameID := range nameIDs {
|
|
||||||
if len(strings.Split(nameID, ":")) > 0 {
|
|
||||||
dsc.dependServiceNames = append(dsc.dependServiceNames, strings.Split(nameID, ":")[0])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return &dsc, nil
|
return &dsc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package discover
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -90,18 +91,24 @@ func (k *k8sDiscover) discover(name string, callback CallbackUpdate) {
|
|||||||
DeleteFunc: func(obj interface{}) {
|
DeleteFunc: func(obj interface{}) {
|
||||||
pod := obj.(*corev1.Pod)
|
pod := obj.(*corev1.Pod)
|
||||||
ep := endpointForPod(pod)
|
ep := endpointForPod(pod)
|
||||||
|
ep.Mode = 2
|
||||||
callback.UpdateEndpoints(config.DELETE, ep)
|
callback.UpdateEndpoints(config.DELETE, ep)
|
||||||
},
|
},
|
||||||
UpdateFunc: func(old, cur interface{}) {
|
UpdateFunc: func(old, cur interface{}) {
|
||||||
oldPod := old.(*corev1.Pod)
|
oldPod := old.(*corev1.Pod)
|
||||||
curPod := cur.(*corev1.Pod)
|
curPod := cur.(*corev1.Pod)
|
||||||
if oldPod.Status.Phase == curPod.Status.Phase {
|
|
||||||
return
|
if reflect.DeepEqual(oldPod, curPod) {
|
||||||
}
|
|
||||||
if !isPodReady(curPod) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ep := endpointForPod(curPod)
|
ep := endpointForPod(curPod)
|
||||||
|
if !isPodReady(curPod) {
|
||||||
|
logrus.Infof("unready pod(%s%s) received, delete endpoint based on the pod", curPod.Name, curPod.Namespace)
|
||||||
|
ep.Mode = 2
|
||||||
|
callback.UpdateEndpoints(config.DELETE, ep)
|
||||||
|
return
|
||||||
|
}
|
||||||
callback.UpdateEndpoints(config.SYNC, ep)
|
callback.UpdateEndpoints(config.SYNC, ep)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -690,7 +690,6 @@ func (s *k8sStore) ListVirtualService() (l7vs []*v1.VirtualService, l4vs []*v1.V
|
|||||||
|
|
||||||
// ingressIsValid checks if the specified ingress is valid
|
// ingressIsValid checks if the specified ingress is valid
|
||||||
func (s *k8sStore) ingressIsValid(ing *extensions.Ingress) bool {
|
func (s *k8sStore) ingressIsValid(ing *extensions.Ingress) bool {
|
||||||
|
|
||||||
var endpointKey string
|
var endpointKey string
|
||||||
if ing.Spec.Backend != nil { // stream
|
if ing.Spec.Backend != nil { // stream
|
||||||
endpointKey = fmt.Sprintf("%s/%s", ing.Namespace, ing.Spec.Backend.ServiceName)
|
endpointKey = fmt.Sprintf("%s/%s", ing.Namespace, ing.Spec.Backend.ServiceName)
|
||||||
@ -719,20 +718,27 @@ func (s *k8sStore) ingressIsValid(ing *extensions.Ingress) bool {
|
|||||||
logrus.Errorf("Cant not convert %v to %v", reflect.TypeOf(item), reflect.TypeOf(endpoint))
|
logrus.Errorf("Cant not convert %v to %v", reflect.TypeOf(item), reflect.TypeOf(endpoint))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if endpoint.Subsets == nil || len(endpoint.Subsets) == 0 {
|
if len(endpoint.Subsets) == 0 {
|
||||||
logrus.Debugf("Endpoints(%s) is empty, ignore it", endpointKey)
|
logrus.Debugf("Endpoints(%s) is empty, ignore it", endpointKey)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
for _, ep := range endpoint.Subsets {
|
if !hasReadyAddresses(endpoint) {
|
||||||
if (ep.Addresses == nil || len(ep.Addresses) == 0) && (ep.NotReadyAddresses == nil || len(ep.NotReadyAddresses) == 0) {
|
logrus.Debugf("Endpoints(%s) is empty, ignore it", endpointKey)
|
||||||
logrus.Debugf("Endpoints(%s) is empty, ignore it", endpointKey)
|
return false
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func hasReadyAddresses(endpoints *corev1.Endpoints) bool {
|
||||||
|
for _, ep := range endpoints.Subsets {
|
||||||
|
if len(ep.Addresses) > 0 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// GetIngress returns the Ingress matching key.
|
// GetIngress returns the Ingress matching key.
|
||||||
func (s *k8sStore) GetIngress(key string) (*extensions.Ingress, error) {
|
func (s *k8sStore) GetIngress(key string) (*extensions.Ingress, error) {
|
||||||
return s.listers.Ingress.ByKey(key)
|
return s.listers.Ingress.ByKey(key)
|
||||||
|
@ -4,12 +4,8 @@ set -o errexit
|
|||||||
# define package name
|
# define package name
|
||||||
WORK_DIR=/go/src/github.com/goodrain/rainbond
|
WORK_DIR=/go/src/github.com/goodrain/rainbond
|
||||||
BASE_NAME=rainbond
|
BASE_NAME=rainbond
|
||||||
IMAGE_BASE_NAME=rainbond
|
IMAGE_BASE_NAME=${BUILD_IMAGE_BASE_NAME:-'rainbond'}
|
||||||
if [ "$BUILD_IMAGE_BASE_NAME" ];
|
|
||||||
then
|
|
||||||
IMAGE_BASE_NAME=${BUILD_IMAGE_BASE_NAME}
|
|
||||||
fi
|
|
||||||
CACHE=${CACHE:true}
|
|
||||||
GO_VERSION=1.13
|
GO_VERSION=1.13
|
||||||
|
|
||||||
GOPROXY=${GOPROXY:-'https://goproxy.io'}
|
GOPROXY=${GOPROXY:-'https://goproxy.io'}
|
||||||
|
@ -192,6 +192,9 @@ func createEnv(as *v1.AppService, dbmanager db.Manager) (*[]corev1.EnvVar, error
|
|||||||
Value: "streamlog",
|
Value: "streamlog",
|
||||||
})
|
})
|
||||||
|
|
||||||
|
bootSeqDepServiceIDs := as.ExtensionSet["boot_seq_dep_service_ids"]
|
||||||
|
logrus.Infof("boot sequence dep service ids: %s", bootSeqDepServiceIDs)
|
||||||
|
|
||||||
//set relation app outer env
|
//set relation app outer env
|
||||||
var relationIDs []string
|
var relationIDs []string
|
||||||
relations, err := dbmanager.TenantServiceRelationDao().GetTenantServiceRelations(as.ServiceID)
|
relations, err := dbmanager.TenantServiceRelationDao().GetTenantServiceRelations(as.ServiceID)
|
||||||
@ -216,15 +219,21 @@ func createEnv(as *v1.AppService, dbmanager db.Manager) (*[]corev1.EnvVar, error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var depend string
|
var Depend string
|
||||||
|
var startupSequenceDependencies []string
|
||||||
for _, sa := range serviceAliases {
|
for _, sa := range serviceAliases {
|
||||||
if depend != "" {
|
if Depend != "" {
|
||||||
depend += ","
|
Depend += ","
|
||||||
|
}
|
||||||
|
Depend += fmt.Sprintf("%s:%s", sa.ServiceAlias, sa.ServiceID)
|
||||||
|
|
||||||
|
if bootSeqDepServiceIDs != "" && strings.Contains(bootSeqDepServiceIDs, sa.ServiceID) {
|
||||||
|
startupSequenceDependencies = append(startupSequenceDependencies, sa.ServiceAlias)
|
||||||
}
|
}
|
||||||
depend += fmt.Sprintf("%s:%s", sa.ServiceAlias, sa.ServiceID)
|
|
||||||
}
|
}
|
||||||
envs = append(envs, corev1.EnvVar{Name: "DEPEND_SERVICE", Value: depend})
|
envs = append(envs, corev1.EnvVar{Name: "DEPEND_SERVICE", Value: Depend})
|
||||||
envs = append(envs, corev1.EnvVar{Name: "DEPEND_SERVICE_COUNT", Value: strconv.Itoa(len(serviceAliases))})
|
envs = append(envs, corev1.EnvVar{Name: "DEPEND_SERVICE_COUNT", Value: strconv.Itoa(len(serviceAliases))})
|
||||||
|
envs = append(envs, corev1.EnvVar{Name: "STARTUP_SEQUENCE_DEPENDENCIES", Value: strings.Join(startupSequenceDependencies, ",")})
|
||||||
|
|
||||||
if as.GovernanceMode == model.GovernanceModeBuildInServiceMesh {
|
if as.GovernanceMode == model.GovernanceModeBuildInServiceMesh {
|
||||||
as.NeedProxy = true
|
as.NeedProxy = true
|
||||||
|
Loading…
Reference in New Issue
Block a user