@@ -52,6 +52,14 @@ func NewExporterHostSyncer(cfg *config.Config,
5252 }
5353}
5454
55+ // isExporterInstanceDead checks if an exporter instance is marked as dead via annotation
56+ func isExporterInstanceDead (instance * api.ExporterInstance ) (bool , string ) {
57+ if deadAnnotation , exists := instance .Annotations ["dead" ]; exists {
58+ return true , deadAnnotation
59+ }
60+ return false , ""
61+ }
62+
5563// SyncExporterHosts synchronizes exporter hosts via SSH
5664func (e * ExporterHostSyncer ) SyncExporterHosts () error {
5765 fmt .Print ("\n 🔄 Syncing exporter hosts via SSH ===========================\n " )
@@ -72,6 +80,22 @@ func (e *ExporterHostSyncer) SyncExporterHosts() error {
7280 continue
7381 }
7482
83+ // Skip the host if all exporter instances are dead
84+ allDead := true
85+ var deadAnnotations []string
86+ for _ , exporterInstance := range exporterInstances {
87+ if isDead , deadAnnotation := isExporterInstanceDead (exporterInstance ); isDead {
88+ deadAnnotations = append (deadAnnotations , fmt .Sprintf ("%s: %s" , exporterInstance .Name , deadAnnotation ))
89+ } else {
90+ allDead = false
91+ break
92+ }
93+ }
94+ if allDead {
95+ fmt .Printf ("\n 💻 Exporter host: %s skipped - all instances dead: [%s]\n " , host .Name , strings .Join (deadAnnotations , ", " ))
96+ continue
97+ }
98+
7599 hostCopy := host .DeepCopy ()
76100 err := e .tapplier .Apply (hostCopy )
77101 if err != nil {
@@ -123,6 +147,10 @@ func (e *ExporterHostSyncer) SyncExporterHosts() error {
123147 }
124148
125149 for _ , exporterInstance := range exporterInstances {
150+ if isDead , deadAnnotation := isExporterInstanceDead (exporterInstance ); isDead {
151+ fmt .Printf (" 📟 Exporter instance: %s skipped - dead: %s\n " , exporterInstance .Name , deadAnnotation )
152+ continue
153+ }
126154 fmt .Printf (" 📟 Exporter instance: %s\n " , exporterInstance .Name )
127155 errName := "ExporterInstance:" + exporterInstance .Name
128156 et , err := template .NewExporterInstanceTemplater (e .cfg , exporterInstance )
0 commit comments