Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 32 additions & 14 deletions pkg/microservice/aslan/core/common/service/kube/istio_grayscale.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func ensureUpdateGrayscaleSerivce(ctx context.Context, curEnv *commonmodels.Prod
}

// 2. Create Default Service in all of the gray environments.
ensureServicesInAllGrayEnvs(ctx, curEnv, grayEnvs, svc, kclient, istioClient)
err = ensureServicesInAllGrayEnvs(ctx, curEnv, grayEnvs, svc, kclient, istioClient)
if err != nil {
return fmt.Errorf("failed to ensure service %s in all gray envs, err: %w", svc.Name, err)
}
Expand Down Expand Up @@ -854,7 +854,15 @@ func buildEnvoyStoreCacheOperation(headerKeys []string) (*types.Struct, error) {
end
end

if not traceid then
return
end

local env = request_handle:headers():get("x-env")
if not env then
return
end

local headers, body = request_handle:httpCall(
"cache",
{
Expand All @@ -870,18 +878,20 @@ func buildEnvoyStoreCacheOperation(headerKeys []string) (*types.Struct, error) {
for _, headerKey := range headerKeys {
tmpInlineCodeMid := `
local header_key = "%s"
local key = traceid .. "-" .. header_key
local value = request_handle:headers():get(header_key)
local headers, body = request_handle:httpCall(
"cache",
{
[":method"] = "POST",
[":path"] = string.format("/api/cache/%%s/%%s", key, value),
[":authority"] = "cache",
},
"",
5000
)
if value then
local key = traceid .. "-" .. header_key
local headers, body = request_handle:httpCall(
"cache",
{
[":method"] = "POST",
[":path"] = string.format("/api/cache/%%s/%%s", key, value),
[":authority"] = "cache",
},
"",
5000
)
end
`
tmpInlineCodeMid = fmt.Sprintf(tmpInlineCodeMid, headerKey)
inlineCodeMid += tmpInlineCodeMid
Expand Down Expand Up @@ -924,6 +934,10 @@ func buildEnvoyGetCacheOperation(headerKeys []string) (*types.Struct, error) {
end
end

if not traceid then
return
end

local headers, body = request_handle:httpCall(
"cache",
{
Expand All @@ -935,7 +949,9 @@ func buildEnvoyGetCacheOperation(headerKeys []string) (*types.Struct, error) {
5000
)

request_handle:headers():add("x-env", headers["x-data"]);
if headers and headers["x-data"] then
request_handle:headers():add("x-env", headers["x-data"])
end
`

inlineCodeMid := ``
Expand All @@ -954,7 +970,9 @@ func buildEnvoyGetCacheOperation(headerKeys []string) (*types.Struct, error) {
5000
)

request_handle:headers():add(header_key, headers["x-data"]);
if headers and headers["x-data"] then
request_handle:headers():add(header_key, headers["x-data"])
end
`
tmpInlineCodeMid = fmt.Sprintf(tmpInlineCodeMid, headerKey)
inlineCodeMid += tmpInlineCodeMid
Expand Down