mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-22 11:54:54 +00:00
Add: operators identified by podname, can merge
Merge happen when podname, deployment name and namespace match
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package regex
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -43,8 +44,9 @@ var PXCOperatorMap = types.RegexMap{
|
||||
},
|
||||
|
||||
// Why is it not in regular "views" regexes:
|
||||
// it could have been useful as an "verbosity=types.Detailed" regexes, very rarely
|
||||
// but in context of operators, it is actually a very important information
|
||||
// it would have been useful very rarely for on-premise setups but in context of operators,
|
||||
// it is actually an important info because gcache recovery can provoke out of memories due to
|
||||
// filecache counting against memory usage
|
||||
"RegexGcacheScan": &types.LogRegex{
|
||||
// those "operators" regexes do not have the log prefix added implicitly. It's not strictly needed, but
|
||||
// it will help to avoid catching random piece of log out of order
|
||||
@@ -85,4 +87,20 @@ var PXCOperatorMap = types.RegexMap{
|
||||
},
|
||||
Verbosity: types.DebugMySQL,
|
||||
},
|
||||
|
||||
"RegexPodName": &types.LogRegex{
|
||||
Regex: regexp.MustCompile("^wsrep_node_incoming_address="),
|
||||
InternalRegex: regexp.MustCompile("^wsrep_node_incoming_address=(?P<podname>[a-zA-Z0-9-]*)\\.(?P<deployment>[a-zA-Z0-9-]*)\\.(?P<namespace>[a-zA-Z0-9-]*)\\."),
|
||||
Handler: func(submatches map[string]string, logCtx types.LogCtx, log string, date time.Time) (types.LogCtx, types.LogDisplayer) {
|
||||
|
||||
logCtx.OperatorMetadata = &types.OperatorMetadata{
|
||||
PodName: submatches["podname"],
|
||||
Deployment: submatches["deployment"],
|
||||
Namespace: submatches["namespace"],
|
||||
}
|
||||
|
||||
return logCtx, types.SimpleDisplayer(fmt.Sprintf("podname: %s, dep: %s, namespace: %s", submatches["podname"], submatches["deployment"], submatches["namespace"]))
|
||||
},
|
||||
Verbosity: types.DebugMySQL,
|
||||
},
|
||||
}
|
||||
|
@@ -56,6 +56,21 @@ func TestPXCOperatorRegex(t *testing.T) {
|
||||
expectedOut: "recovering gcache",
|
||||
key: "RegexGcacheScan",
|
||||
},
|
||||
|
||||
{
|
||||
log: "wsrep_node_incoming_address=cluster1-0.cluster1.pxc.svc.cluster.local:3306",
|
||||
expected: regexTestState{
|
||||
LogCtx: types.LogCtx{
|
||||
OperatorMetadata: &types.OperatorMetadata{
|
||||
PodName: "cluster1-0",
|
||||
Deployment: "cluster1",
|
||||
Namespace: "pxc",
|
||||
},
|
||||
},
|
||||
},
|
||||
expectedOut: "podname: cluster1-0, dep: cluster1, namespace: pxc",
|
||||
key: "RegexPodName",
|
||||
},
|
||||
}
|
||||
|
||||
iterateRegexTest(t, PXCOperatorMap, tests)
|
||||
|
Reference in New Issue
Block a user