Skip to content

Commit

Permalink
fix: skip webhook regex matching for exp config (#9511)
Browse files Browse the repository at this point in the history
  • Loading branch information
gt2345 authored Jun 14, 2024
1 parent b51bc93 commit f9ba7f4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e_tests/tests/cluster/test_webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_log_pattern_send_webhook(should_match: bool) -> None:

regex = r"assert 0 <= self\.metrics_sigma"
if not should_match:
regex = r"\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b"
regex = r"(.*)cuda(.*)"

webhook_trigger = bindings.v1Trigger(
triggerType=bindings.v1TriggerType.TASK_LOG,
Expand Down
7 changes: 4 additions & 3 deletions master/internal/logpattern/logpattern.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import (
const regexCacheSize = 256

var (
defaultSingleton *LogPatternPolicies
expconfigCompiledRegex = regexp.MustCompile("(.*)(\\\"log_policies\\\":)(.*)")
defaultSingleton *LogPatternPolicies
// ExpconfigCompiledRegex is used to identify user submitted config.
ExpconfigCompiledRegex = regexp.MustCompile("(.*)(\\\"log_policies\\\":)(.*)")
)

// LogPatternPolicies performs log pattern checks.
Expand Down Expand Up @@ -70,7 +71,7 @@ func (l *LogPatternPolicies) monitor(ctx context.Context,

// One of the trial logs prints expconf which has the regex pattern.
// We skip monitoring this line.
if expconfigCompiledRegex.MatchString(log.Log) {
if ExpconfigCompiledRegex.MatchString(log.Log) {
continue
}

Expand Down
6 changes: 6 additions & 0 deletions master/internal/webhooks/postgres_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

conf "github.com/determined-ai/determined/master/internal/config"
"github.com/determined-ai/determined/master/internal/db"
"github.com/determined-ai/determined/master/internal/logpattern"
"github.com/determined-ai/determined/master/internal/project"
"github.com/determined-ai/determined/master/internal/workspace"
"github.com/determined-ai/determined/master/pkg/model"
Expand Down Expand Up @@ -121,6 +122,11 @@ func (l *WebhookManager) scanLogs(ctx context.Context, logs []*model.TaskLog) er
}

for _, cacheItem := range l.regexToTriggers {
// One of the trial logs prints expconf which has the regex pattern.
// We skip monitoring this line.
if logpattern.ExpconfigCompiledRegex.MatchString(log.Log) {
continue
}
if cacheItem.re.MatchString(log.Log) {
for _, t := range cacheItem.triggerIDToTrigger {
if err := addTaskLogEvent(ctx,
Expand Down

0 comments on commit f9ba7f4

Please sign in to comment.