Skip to content

Commit

Permalink
fix cluster server assertion error
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelsoccupied committed Feb 7, 2025
1 parent 3c8981e commit 94e1897
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions internal/service/cluster/collector/collector_alarms.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,8 @@ func nodeClusterTypesWithAlarmDictionaryID(nodeClusterTypes []models.NodeCluster
continue
}

alarmDictionaryIDString := (*nodeClusterType.Extensions)[utils.ClusterAlarmDictionaryIDExtension]
if alarmDictionaryIDString != nil {
_, err := uuid.Parse(alarmDictionaryIDString.(string))
if alarmDictionaryIDString, ok := (*nodeClusterType.Extensions)[utils.ClusterAlarmDictionaryIDExtension].(string); ok {
_, err := uuid.Parse(alarmDictionaryIDString)
if err != nil {
slog.Error("error parsing alarm dictionary ID", "NodeClusterType ID", nodeClusterType.NodeClusterTypeID, "error", err)
continue
Expand All @@ -110,6 +109,7 @@ func nodeClusterTypesWithAlarmDictionaryID(nodeClusterTypes []models.NodeCluster
filteredNodeClusterTypes = append(filteredNodeClusterTypes, nodeClusterType)
}
}

return filteredNodeClusterTypes
}

Expand Down Expand Up @@ -287,11 +287,16 @@ func (d *AlarmsDataSource) buildAlarmDictionaryIDToAlarmDefinitions(nodeClusterT
}

// Only process node cluster types with an alarm dictionary ID
alarmDictionaryID, ok := (*nodeClusterType.Extensions)[utils.ClusterAlarmDictionaryIDExtension].(uuid.UUID)
if !ok || alarmDictionaryID == uuid.Nil {
alarmDictionaryIDStr, ok := (*nodeClusterType.Extensions)[utils.ClusterAlarmDictionaryIDExtension].(string)
if !ok {
slog.Error("no alarm dictionary ID found for node cluster type", "NodeClusterType ID", nodeClusterType.NodeClusterTypeID)
continue
}
alarmDictionaryID, err := uuid.Parse(alarmDictionaryIDStr)
if err != nil || alarmDictionaryID == uuid.Nil {
slog.Error("invalid alarm dictionary ID", "NodeClusterType ID", nodeClusterType.NodeClusterTypeID, "error", err)
continue
}

// Remove conflicting rules before creating alarm definitions
filteredRules := d.getFilteredRules(nodeClusterType.NodeClusterTypeID, nodeClusterTypeIDToMonitoringRules[nodeClusterType.NodeClusterTypeID])
Expand Down Expand Up @@ -388,11 +393,16 @@ func (d *AlarmsDataSource) makeAlarmDictionaries(nodeClusterTypes []models.NodeC
continue
}

alarmDictionaryID, ok := (*nodeClusterType.Extensions)[utils.ClusterAlarmDictionaryIDExtension].(uuid.UUID)
if !ok || alarmDictionaryID == uuid.Nil {
alarmDictionaryIDStr, ok := (*nodeClusterType.Extensions)[utils.ClusterAlarmDictionaryIDExtension].(string)
if !ok {
slog.Error("no alarm dictionary ID found for node cluster type", "NodeClusterType ID", nodeClusterType.NodeClusterTypeID)
continue
}
alarmDictionaryID, err := uuid.Parse(alarmDictionaryIDStr)
if err != nil || alarmDictionaryID == uuid.Nil {
slog.Error("invalid alarm dictionary ID", "NodeClusterType ID", nodeClusterType.NodeClusterTypeID, "error", err)
continue
}

alarmDictionary := commonmodels.AlarmDictionary{
AlarmDictionaryID: alarmDictionaryID,
Expand Down

0 comments on commit 94e1897

Please sign in to comment.