microsoft / service-fabric-traefik

service-fabric-traefik contains services to fetch endpoint information from Service Fabric and expose Traefik endpoints.
MIT License
14 stars 15 forks source link

Fixed case where error in reading partitions can lead to using empty configuration #30

Closed nokjuh closed 9 months ago

nokjuh commented 11 months ago

If e.g. a partition is being removed at a specific moment, there can be a 404 error in reading partitions from Service Fabric. Errors in reading partitions led to trying to use the invalid results, which eventually led to using effectively empty configuration until the next configuration read time. This means that any requests coming to that Traefik instance will fail for a few seconds.

Instead if there is an error when reading the partitions, return error so that the configuration is not used. Verified in practice that the partition reading errors no longer lead to empty configuration after the code fix.

Error in plugin logs without the fix: time="2023-11-27T02:27:07Z" level=info msg="failed to get partitions: Service Fabric responded with error code 404 FABRIC_E_PARTITION_NOT_FOUND to request https://localhost:19080/Applications//$/GetServices///$/GetPartitions/?api-version=3.0 with body &{0x302720 0xc000425240 0x517500}" time="2023-11-27T02:27:07Z" level=info msg="runtime error: invalid memory address or nil pointer dereference"

nokjuh commented 11 months ago

@mmatur Could you please take a look at this and related pull requests #29 and #31? These fixes together should make Service Fabric plugin more reliable, allowing us to take the Traefik 2.x versions into production use.