MCPcopy
hub / github.com/apecloud/kubeblocks / getMonitorAnnotations

Function getMonitorAnnotations

pkg/controller/factory/builder.go:200–217  ·  view source on GitHub ↗

getMonitorAnnotations returns the annotations for the monitor.

(synthesizedComp *component.SynthesizedComponent, componentDef *kbappsv1.ComponentDefinition)

Source from the content-addressed store, hash-verified

198
199// getMonitorAnnotations returns the annotations for the monitor.
200func 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
219func getBuiltinContainer(synthesizedComp *component.SynthesizedComponent, containerName string) *corev1.Container {
220 containers := synthesizedComp.PodSpec.Containers

Callers 1

BuildInstanceSetFunction · 0.85

Calls 4

GetExporterFunction · 0.92
AddAnnotationScopeFunction · 0.92
GetScrapeAnnotationsFunction · 0.92
getBuiltinContainerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…