getMonitorAnnotations returns the annotations for the monitor.
(synthesizedComp *component.SynthesizedComponent, componentDef *kbappsv1.ComponentDefinition)
| 198 | |
| 199 | // getMonitorAnnotations returns the annotations for the monitor. |
| 200 | func getMonitorAnnotations(synthesizedComp *component.SynthesizedComponent, componentDef *kbappsv1.ComponentDefinition) map[string]string { |
| 201 | if synthesizedComp.DisableExporter == nil || *synthesizedComp.DisableExporter || componentDef == nil { |
| 202 | return nil |
| 203 | } |
| 204 | |
| 205 | exporter := component.GetExporter(componentDef.Spec) |
| 206 | if exporter == nil { |
| 207 | return nil |
| 208 | } |
| 209 | |
| 210 | // Node: If it is an old addon, containerName may be empty. |
| 211 | container := getBuiltinContainer(synthesizedComp, exporter.ContainerName) |
| 212 | if container == nil && exporter.ScrapePort == "" && exporter.TargetPort == nil { |
| 213 | klog.Warningf("invalid exporter port and ignore for component: %s, componentDef: %s", synthesizedComp.Name, componentDef.Name) |
| 214 | return nil |
| 215 | } |
| 216 | return instanceset.AddAnnotationScope(instanceset.HeadlessServiceScope, common.GetScrapeAnnotations(*exporter, container)) |
| 217 | } |
| 218 | |
| 219 | func getBuiltinContainer(synthesizedComp *component.SynthesizedComponent, containerName string) *corev1.Container { |
| 220 | containers := synthesizedComp.PodSpec.Containers |
no test coverage detected
searching dependent graphs…