mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2026-02-20 17:57:30 +01:00
Add log output and fix bugs in AppTagger
This commit is contained in:
@@ -52,7 +52,10 @@ func (t *AppTagger) scanApp(f *os.File, fns string) {
|
|||||||
ai := appInfo{tag: tag, patterns: make([]*regexp.Regexp, 0)}
|
ai := appInfo{tag: tag, patterns: make([]*regexp.Regexp, 0)}
|
||||||
|
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := strings.TrimSpace(scanner.Text())
|
||||||
|
if line == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
re, err := regexp.Compile(line)
|
re, err := regexp.Compile(line)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cclog.Errorf("invalid regex pattern '%s' in %s: %v", line, fns, err)
|
cclog.Errorf("invalid regex pattern '%s' in %s: %v", line, fns, err)
|
||||||
@@ -68,6 +71,8 @@ func (t *AppTagger) scanApp(f *os.File, fns string) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cclog.Infof("AppTagger loaded %d patterns for %s", len(ai.patterns), tag)
|
||||||
t.apps = append(t.apps, ai)
|
t.apps = append(t.apps, ai)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,6 +91,9 @@ func (t *AppTagger) EventCallback() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, fn := range files {
|
for _, fn := range files {
|
||||||
|
if fn.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
fns := fn.Name()
|
fns := fn.Name()
|
||||||
cclog.Debugf("Process: %s", fns)
|
cclog.Debugf("Process: %s", fns)
|
||||||
f, err := os.Open(filepath.Join(t.cfgPath, fns))
|
f, err := os.Open(filepath.Join(t.cfgPath, fns))
|
||||||
@@ -121,6 +129,9 @@ func (t *AppTagger) Register() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, fn := range files {
|
for _, fn := range files {
|
||||||
|
if fn.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
fns := fn.Name()
|
fns := fn.Name()
|
||||||
cclog.Debugf("Process: %s", fns)
|
cclog.Debugf("Process: %s", fns)
|
||||||
f, err := os.Open(filepath.Join(t.cfgPath, fns))
|
f, err := os.Open(filepath.Join(t.cfgPath, fns))
|
||||||
@@ -164,8 +175,8 @@ func (t *AppTagger) Match(job *schema.Job) {
|
|||||||
if re.MatchString(jobscriptLower) {
|
if re.MatchString(jobscriptLower) {
|
||||||
if !r.HasTag(id, t.tagType, a.tag) {
|
if !r.HasTag(id, t.tagType, a.tag) {
|
||||||
r.AddTagOrCreateDirect(id, t.tagType, a.tag)
|
r.AddTagOrCreateDirect(id, t.tagType, a.tag)
|
||||||
break out
|
|
||||||
}
|
}
|
||||||
|
break out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user