Skip to content

Commit

Permalink
Merge pull request #94 from TencentBlueKing/develop
Browse files Browse the repository at this point in the history
v1.10.4
  • Loading branch information
zhu327 committed Apr 7, 2022
2 parents d13b84a + cf7aa91 commit d613677
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.10.3
1.10.4
13 changes: 7 additions & 6 deletions pkg/component/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func AsCurlCommand(request *gorequest.SuperAgent) (string, error) {
return cmd.String(), nil
}

func logFailHTTPRequest(
func logHTTPRequest(
start time.Time,
request *gorequest.SuperAgent,
response gorequest.Response,
Expand All @@ -87,18 +87,19 @@ func logFailHTTPRequest(
) {
logger := logging.GetComponentLogger()

duration := time.Since(start)
// to ms
latency := float64(duration / time.Millisecond)

responseBodyErr := data.Error()
// check will log or not?
willLog := logger.GetLevel() == log.DebugLevel ||
len(errs) != 0 || response.StatusCode != http.StatusOK || responseBodyErr != nil
willLog := latency > 200 || (logger.GetLevel() == log.DebugLevel ||
len(errs) != 0 || response.StatusCode != http.StatusOK || responseBodyErr != nil)

if !willLog {
return
}

// duration
duration := time.Since(start)

// curl dump
dump, err := AsCurlCommand(request)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/component/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var _ = Describe("Init", func() {

time.Sleep(20 * time.Millisecond)

logFailHTTPRequest(start, request, resp, respBody, errs, &result)
logHTTPRequest(start, request, resp, respBody, errs, &result)
})

})
2 changes: 1 addition & 1 deletion pkg/component/remote_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (c *remoteResourceClient) QueryResources(
Send(data).
EndStruct(&result, callbackFunc)

logFailHTTPRequest(start, request, resp, respBody, errs, &result)
logHTTPRequest(start, request, resp, respBody, errs, &result)

if len(errs) != 0 {
// 敏感信息泄漏 ip+端口号, 替换为 *.*.*.*
Expand Down
6 changes: 4 additions & 2 deletions pkg/database/dao/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,10 @@ func (m *expressionManager) bulkDeleteByPKsWithTx(tx *sqlx.Tx, pks []int64) (int
func (m *expressionManager) updateUnreferencedExpressionType(fromType int64, toType int64) error {
sql := `UPDATE expression SET
type=?
WHERE type=?
AND pk NOT IN (SELECT expression_pk FROM policy)`
WHERE pk IN (SELECT pk FROM
(SELECT pk FROM expression
WHERE type=? AND pk NOT IN (SELECT expression_pk FROM policy)
) AS e)`
return database.SqlxExec(m.DB, sql, toType, fromType)
}

Expand Down
5 changes: 5 additions & 0 deletions release.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.10.4

- bugfix: /api/v1/web/unreferenced-expressions timeout
- upgrade: component log request if latency is greater than 200ms

# 1.10.3

- upgrade: release environment attributes
Expand Down

0 comments on commit d613677

Please sign in to comment.