jjcollinge / traefik-on-service-fabric

Azure Service Fabric now has support for Traefik!
MIT License
50 stars 31 forks source link

Backend doesn't register with Guest Executables #72

Closed knowhoper closed 5 years ago

knowhoper commented 5 years ago

Hi,

The following ServiceManifest.xml file does not correctly register a backend in Traefik.

 <Extension Name="Traefik">
          <Labels xmlns="http://schemas.microsoft.com/2015/03/fabact-no-schema">
            <Label Key="traefik.frontend.rule">PathPrefixStrip: /acme-service</Label>
            <Label Key="traefik.enable">true</Label>
            <Label Key="traefik.frontend.passHostHeader">true</Label>
          </Labels>
        </Extension>
      </Extensions>

Are Guest Executables supported? The URL reports

Service Unavailable

But a direct request to the machine works perfectly.

traefik

RamjotSingh commented 5 years ago

Do you have endpoint declarations in your ServiceManifest? Something like

<Resources>
    <Endpoints>
      <Endpoint Protocol="https" Name="ServiceEndpoint" Type="Input" Port="8989" />
    </Endpoints>
  </Resources>

If this is not present Traefik fails to determine the backend port.

knowhoper commented 5 years ago

Yes it does. Thanks for your help.

 <Resources>
    <Endpoints>
      <Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" Port="9001" />
    </Endpoints>
  </Resources>
lawrencegripper commented 5 years ago

It looks like the rules have all been correctly detected but no valid backend endpoints have been found for the service. This code determines which backends to include, it checks the backend is reporting as healthy in SF and has an HTTP endpoint defined.

Can you share your whole Service Manifest? If you fire up SF explorer and navigate to the service can you see a defined HTTP Endpoint for the instance and does it report healthy?

knowhoper commented 5 years ago

HI @lawrencegripper thanks for your response.

Service Manifest

<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="Acme.UIPkg"
                 Version="1.0.1"
                 xmlns="http://schemas.microsoft.com/2011/01/fabric"
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <ServiceTypes>
    <!-- This is the name of your ServiceType. 
         The UseImplicitHost attribute indicates this is a guest executable service. -->
    <StatelessServiceType ServiceTypeName="Acme.UIType" UseImplicitHost="true">
      <Extensions>
        <Extension Name="Traefik">
          <Labels xmlns="http://schemas.microsoft.com/2015/03/fabact-no-schema">
            <Label Key="traefik.frontend.rule">PathPrefixStrip: /acme-service</Label>
            <Label Key="traefik.enable">true</Label>
          </Labels>
        </Extension>
      </Extensions>
    </StatelessServiceType>
  </ServiceTypes>

  <!-- Code package is your service executable. -->
  <CodePackage Name="Code" Version="1.0.1">
    <!-- The SetupEntryPoint is an optional element used to specify a
         program to be executed before the service's code is launched. -->
    <!--
    <SetupEntryPoint>
      <ExeHost>
        <Program></Program>
      </ExeHost>
    </SetupEntryPoint>
    -->
    <EntryPoint>
      <ExeHost>
        <Program>startup.bat</Program>
        <Arguments></Arguments>
        <WorkingFolder>CodePackage</WorkingFolder>
        <ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>
      </ExeHost>
    </EntryPoint>
  </CodePackage>

  <!-- Config package is the contents of the Config directoy under PackageRoot that contains an 
       independently-updateable and versioned set of custom configuration settings for your service. -->
  <ConfigPackage Name="Config" Version="1.0.1" />

  <Resources>
    <Endpoints>
      <!-- This endpoint is used by the communication listener to obtain the port on which to 
           listen. Please note that if your service is partitioned, this port is shared with 
           replicas of different partitions that are placed in your code. -->
      <Endpoint Protocol="http" Name="ServiceEndpoint" Type="Input" Port="9001" />
    </Endpoints>
  </Resources>
</ServiceManifest>

2018-09-17 12_14_06-service fabric explorer

Thanks for your help.

lawrencegripper commented 5 years ago

Thanks for the details, this hopefully helps. It looks like the guest executable endpoint registered in SF isn't an HTTP endpoint as it only contains the DNS name and port.

In our testing we've used type="http" for node guest exe's and seen this behave as expected. Here is an example.

Can you try out making that change to your manifest and let me know if things work as expected? If this does we'd really appreciated a PR to clarify this in the docs so others don't hit this issue.

knowhoper commented 5 years ago

The UriScheme attribute worked. I have submitted a PR.

lawrencegripper commented 5 years ago

Thanks :+1: