From 2a9b3d2090e00fd8bc38104f8bcf758909abcf34 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 23 Feb 2023 14:32:30 +0100 Subject: dashboard: report errors for outdated subsystem assignments It might happen that the user-set subsystem no longer exists. It seems not worth it to implement any automatic processing for that case. Let's postpone it until it turns out to be really necessary. For now let's just log an error. --- dashboard/app/subsystem.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dashboard/app/subsystem.go b/dashboard/app/subsystem.go index dfaa684ff..0b4300060 100644 --- a/dashboard/app/subsystem.go +++ b/dashboard/app/subsystem.go @@ -28,6 +28,9 @@ func reassignBugSubsystems(c context.Context, ns string, count int) error { rev := getSubsystemRevision(c, ns) for i, bugKey := range keys { if bugs[i].hasUserSubsystems() { + // It might be that the user-set subsystem no longer exists. + // For now let's just log an error in this case. + checkOutdatedSubsystems(c, service, bugs[i]) // If we don't set the latst revision, we'll have to update this // bug over and over again. err = updateBugSubsystems(c, bugKey, nil, updateRevision(rev)) @@ -84,6 +87,14 @@ func bugsToUpdateSubsystems(c context.Context, ns string, count int) ([]*Bug, [] return bugs, keys, nil } +func checkOutdatedSubsystems(c context.Context, service *subsystem.Service, bug *Bug) { + for _, item := range bug.Tags.Subsystems { + if service.ByName(item.Name) == nil { + log.Errorf(c, "ns=%s bug=%s subsystem %s no longer exists", bug.Namespace, bug.Title, item.Name) + } + } +} + type ( autoInference int userAssignment string -- cgit mrf-deployment