Refine app detection

Switch to regexp
This commit is contained in:
Jan Eitzinger 2025-06-27 14:11:10 +02:00
parent 983aa592d8
commit 7531ba4b5c
4 changed files with 7 additions and 6 deletions

View File

@ -152,13 +152,13 @@ func (r *JobRepository) removeTagFromArchiveJobs(jobIds []int64) {
for _, j := range jobIds {
tags, err := r.getArchiveTags(&j)
if err != nil {
log.Warn("Error while getting tags for job")
log.Warnf("Error while getting tags for job %d", j)
continue
}
job, err := r.FindByIdDirect(j)
if err != nil {
log.Warn("Error while getting job")
log.Warnf("Error while getting job %d", j)
continue
}

View File

@ -1,3 +0,0 @@
pw
neb
ph

View File

@ -0,0 +1,2 @@
starccm+
-podkey

View File

@ -11,6 +11,7 @@ import (
"io/fs"
"os"
"path/filepath"
"regexp"
"strings"
"github.com/ClusterCockpit/cc-backend/internal/repository"
@ -111,7 +112,8 @@ func (t *AppTagger) Match(job *schema.Job) {
for _, a := range t.apps {
tag := a.tag
for _, s := range a.strings {
if strings.Contains(strings.ToLower(jobscript), fmt.Sprintf(" %s ", s)) {
matched, _ := regexp.MatchString(s, strings.ToLower(jobscript))
if matched {
if !r.HasTag(id, t.tagType, tag) {
r.AddTagOrCreateDirect(id, t.tagType, tag)
break out