Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

filter irrelevant VMs from calling getConfig->getValidInstances #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
43 changes: 23 additions & 20 deletions servicefabric.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -304,4 +307,4 @@ func createAppInsightsHook(appInsightsClientName string, instrumentationKey stri
// ignore fields
hook.AddIgnore("private")
log.AddHook(hook)
}
}