From ba758553f1a53e631bc94d5523fbb7d1a9edfbc0 Mon Sep 17 00:00:00 2001 From: Niv Schneiderman Date: Wed, 12 Jan 2022 17:51:19 +0200 Subject: [PATCH] filter irrelevant VMs from calling getConfig->getValidInstances in servicefabric.go --- servicefabric.go | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/servicefabric.go b/servicefabric.go index a5615a5..d52f32f 100644 --- a/servicefabric.go +++ b/servicefabric.go @@ -156,29 +156,32 @@ func getClusterServices(sfClient sfClient) ([]ServiceItemExtended, error) { log.Error(err) } else { item.Labels = labels - } - if partitions, err := sfClient.GetPartitions(app.ID, service.ID); err != nil { - log.Error(err) - } else { - for _, partition := range partitions.Items { - partitionExt := PartitionItemExtended{PartitionItem: partition} - - switch { - case isStateful(item): - partitionExt.Replicas = getValidReplicas(sfClient, app, service, partition) - case isStateless(item): - partitionExt.Instances = getValidInstances(sfClient, app, service, partition) - default: - log.Errorf("Unsupported service kind %s in service %s", partition.ServiceKind, service.Name) - continue + if _, ok := labels["traefik.enable"]; ok { + if partitions, err := sfClient.GetPartitions(app.ID, service.ID); err != nil { + log.Error(err) + } else { + for _, partition := range partitions.Items { + partitionExt := PartitionItemExtended{PartitionItem: partition} + + switch { + case isStateful(item): + partitionExt.Replicas = getValidReplicas(sfClient, app, service, partition) + case isStateless(item): + partitionExt.Instances = getValidInstances(sfClient, app, service, partition) + default: + log.Errorf("Unsupported service kind %s in service %s", partition.ServiceKind, service.Name) + continue + } + log.Info("in getClusterServices, added the following replicas: service %v, partition: %v, replica %v",service.ID, partition, partitionExt.Replicas) + + item.Partitions = append(item.Partitions, partitionExt) + } } - - item.Partitions = append(item.Partitions, partitionExt) + + results = append(results, item) } } - - results = append(results, item) } } @@ -304,4 +307,4 @@ func createAppInsightsHook(appInsightsClientName string, instrumentationKey stri // ignore fields hook.AddIgnore("private") log.AddHook(hook) -} +} \ No newline at end of file