diff --git a/cmd/tke-installer/app/installer/manifests/tke-notify-api/tke-notify-api.yaml b/cmd/tke-installer/app/installer/manifests/tke-notify-api/tke-notify-api.yaml index dcb9ee5e7..431539856 100644 --- a/cmd/tke-installer/app/installer/manifests/tke-notify-api/tke-notify-api.yaml +++ b/cmd/tke-installer/app/installer/manifests/tke-notify-api/tke-notify-api.yaml @@ -63,6 +63,8 @@ spec: mountPath: /app/certs - name: tke-notify-api-volume mountPath: /app/conf + - name: timezone + mountPath: /etc/localtime ports: - containerPort: 9457 readinessProbe: @@ -86,7 +88,6 @@ spec: requests: cpu: 50m memory: 128Mi - volumes: - name: certs-volume configMap: @@ -94,6 +95,10 @@ spec: - name: tke-notify-api-volume configMap: name: tke-notify-api + - name: timezone + hostPath: + path: /etc/localtime + --- kind: ConfigMap apiVersion: v1 diff --git a/pkg/notify/apiserver/handler.go b/pkg/notify/apiserver/handler.go index 636bd11a4..5e24a2eb4 100644 --- a/pkg/notify/apiserver/handler.go +++ b/pkg/notify/apiserver/handler.go @@ -231,7 +231,7 @@ func getVariables(alert Alert) map[string]string { evaluateValue, ok := annotations[evaluateValueKey] if ok { - summary = fmt.Sprintf("%s %s", summary, evaluateValue) + summary = fmt.Sprintf("%s %s%s", summary, evaluateValue, unitValue) } alarmPolicyNameValue, ok := labels["alarmPolicyName"] @@ -313,5 +313,6 @@ func getVariables(alert Alert) map[string]string { } func processStartTime(t time.Time) string { - return t.Format("2006-01-02T15:04:05Z") + localTime := t.Local() + return localTime.Format(time.RFC3339) } diff --git a/pkg/notify/controller/messagerequest/util/util.go b/pkg/notify/controller/messagerequest/util/util.go index 952ee3341..45125b08a 100644 --- a/pkg/notify/controller/messagerequest/util/util.go +++ b/pkg/notify/controller/messagerequest/util/util.go @@ -23,7 +23,9 @@ import ( "crypto/tls" "encoding/json" "fmt" + "html" htmlTemplate "html/template" + "io/ioutil" "net/http" "time" @@ -93,7 +95,7 @@ func ParseTemplate(name string, template string, variables map[string]string) (s if err != nil { return "", err } - return buffer.String(), nil + return html.UnescapeString(buffer.String()), nil } // GetCurrentTime returns current timestamp