Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions internal/exporter/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (e *ExporterHostSyncer) filterExporterInstances(hostName string, exporterIn
}

// processExporterInstance processes a single exporter instance
func (e *ExporterHostSyncer) processExporterInstance(exporterInstance *api.ExporterInstance, hostSsh ssh.HostManager) error {
func (e *ExporterHostSyncer) processExporterInstance(exporterInstance *api.ExporterInstance, hostSsh ssh.HostManager, renderedHost *api.ExporterHost) error {
if isDead, deadAnnotation := isExporterInstanceDead(exporterInstance); isDead {
fmt.Printf(" 📟 Exporter instance: %s skipped - dead: %s\n", exporterInstance.Name, deadAnnotation)
return nil
Expand All @@ -149,6 +149,7 @@ func (e *ExporterHostSyncer) processExporterInstance(exporterInstance *api.Expor
return fmt.Errorf("service parameters not found for %s", spRef)
}
et.SetServiceParameters(serviceParameters)
et.SetRenderedExporterHost(renderedHost)

_, err = et.RenderTemplateLabels()
if err != nil {
Expand Down Expand Up @@ -241,7 +242,7 @@ func (e *ExporterHostSyncer) processExporterInstancesAndBootc(exporterInstances

// Process exporter instances
for _, exporterInstance := range exporterInstances {
if err := e.processExporterInstance(exporterInstance, hostSsh); err != nil {
if err := e.processExporterInstance(exporterInstance, hostSsh, renderedHost); err != nil {
fmt.Printf(" ❌ Failed to process %s: %v\n", exporterInstance.Name, err)
*retryQueue = append(*retryQueue, RetryItem{
ExporterInstance: exporterInstance,
Expand Down Expand Up @@ -343,7 +344,7 @@ func (e *ExporterHostSyncer) processGlobalRetryQueue(retryQueue []RetryItem) err
}
} else {
// This was an exporter instance failure
if err := e.processExporterInstance(retryItem.ExporterInstance, hostSsh); err != nil {
if err := e.processExporterInstance(retryItem.ExporterInstance, hostSsh, retryItem.RenderedHost); err != nil {
fmt.Printf("❌ Retry failed for %s on %s: %v\n", retryItem.ExporterInstance.Name, retryItem.HostName, err)
e.addToRetryQueue(&retryItem, err, &nextRetryQueue)
} else {
Expand Down
10 changes: 10 additions & 0 deletions internal/exporter/template/exporter_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ExporterInstanceTemplater struct {
exporterInstance *v1alpha1.ExporterInstance
exporterConfigTemplate *v1alpha1.ExporterConfigTemplate
serviceParameters ServiceParameters
renderedExporterHost *v1alpha1.ExporterHost
}

func NewExporterInstanceTemplater(cfg *config.Config, exporterInstance *v1alpha1.ExporterInstance) (*ExporterInstanceTemplater, error) {
Expand All @@ -35,6 +36,10 @@ func (e *ExporterInstanceTemplater) SetServiceParameters(serviceParameters Servi
e.serviceParameters = serviceParameters
}

func (e *ExporterInstanceTemplater) SetRenderedExporterHost(renderedExporterHost *v1alpha1.ExporterHost) {
e.renderedExporterHost = renderedExporterHost
}

func (s *ServiceParameters) Parameters() *templating.Parameters {
parameters := templating.NewParameters("service")
parameters.Set("tls_ca", s.TlsCA)
Expand Down Expand Up @@ -65,6 +70,11 @@ func (e *ExporterInstanceTemplater) renderTemplates() (*v1alpha1.ExporterInstanc
templateParametersMap["namespace"] = namespace
templateParametersMap["endpoint"] = endpoint
templateParametersMap["container_image"] = e.exporterConfigTemplate.Spec.ContainerImage

// Add ExporterHost addresses if available (managed devices only)
if e.renderedExporterHost != nil && len(e.renderedExporterHost.Spec.Addresses) > 0 {
templateParametersMap["sidekick_address"] = e.renderedExporterHost.Spec.Addresses[0]
}
templateParameters := templating.NewParameters("exporter-instance")
templateParameters.SetFromMap(templateParametersMap)

Expand Down