Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SF SDK throws FormatException when building example. #131

Closed
bjorkstromm opened this issue Jun 8, 2018 · 18 comments
Closed

SF SDK throws FormatException when building example. #131

bjorkstromm opened this issue Jun 8, 2018 · 18 comments
Assignees
Labels
bug Something isn't working

Comments

@bjorkstromm
Copy link
Collaborator

I've been following guides here, but when I create the project it fails at building and deployng the Docker image.

Output from Service Fabric Tools:

========== Checking for Container Prerequisites ==========
Verifying that Docker for Windows is installed...
Docker for Windows is installed.
Verifying that Docker for Windows is running...
Docker for Windows is running.
Verifying that the Service Fabric SDK is installed...
The Service Fabric SDK is installed.
Finding required service projects...
Service projects found.
========== Pulling Required Images ==========
Checking for missing Docker images...
Docker pull completed.
Docker images are ready.
========== Warming up Service Fabric application ==========
Verifying that Docker for Windows' operating system mode matches the project's target operating system...
Docker for Windows' operating system mode matches the project's mode.
Preparing Docker images for service projects...
The Dockerfile 'C:\Users\mb\src\ServiceFabricMesh1\Web1\Dockerfile' will be used to build image web1:dev needed by Service Web1, CodePackage Web1.
No cached built image information was found while building project Web1. Required images will be built.
docker build -f "C:\Users\mb\src\ServiceFabricMesh1\Web1\Dockerfile" -t web1:dev --target base "C:\Users\mb\src\ServiceFabricMesh1" 

Sending build context to Docker daemon  2.142MB
Step 1/3 : FROM microsoft/aspnetcore:2.0 AS base
 ---> 6237a4750408
Step 2/3 : WORKDIR /app
Removing intermediate container e9999815c0ec
 ---> a8c1cac38c9a
Step 3/3 : EXPOSE 20001
 ---> Running in e2e0b9bc8a22
Removing intermediate container e2e0b9bc8a22
 ---> 008f79ac7e79
Successfully built 008f79ac7e79
Successfully tagged web1:dev
Docker images are ready.
Preparing the debugger...
Debugger is ready.
The container runtime settings for Service Web1, CodePackage Web1 have changed. The application must be deployed.
Preparing Service Fabric application in local Service Fabric cluster...
C:\Program Files\Microsoft SDKs\Service Fabric\Tools\Mesh\SfSbzYamlMerge\SfSbzYamlMerge.exe  /i:"C:\Users\mb\src\ServiceFabricMesh1\Web1\Service Resources\service.yaml" /i:"C:\Users\mb\src\ServiceFabricMesh1\ServiceFabricMesh1\App Resources\app.yaml" /i:"C:\Users\mb\src\ServiceFabricMesh1\ServiceFabricMesh1\obj\SFApp\App.debug.yaml" /o:"C:\Users\mb\src\ServiceFabricMesh1\ServiceFabricMesh1\obj\SFApp" /of:"SF_SBZ_JSON"
System.FormatException: Input string was not in a correct format.
Input string was not in a correct format.
   at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
   at Microsoft.ServiceFabric.Yaml2Json.Yaml2Json.FixProperty(JToken container, String propertyName, PrimitiveType type)
   at Microsoft.ServiceFabric.Yaml2Json.Yaml2Json.FixProperty(JToken container, IList`1 pathComponents, PrimitiveType type, Int32 level)
   at Microsoft.ServiceFabric.Yaml2Json.Yaml2Json.FixProperty(JToken container, IList`1 pathComponents, PrimitiveType type, Int32 level)
   at Microsoft.ServiceFabric.Yaml2Json.Yaml2Json.FixProperty(JToken container, IList`1 pathComponents, PrimitiveType type, Int32 level)
   at Microsoft.ServiceFabric.Yaml2Json.Yaml2Json.FixProperty(JToken container, IList`1 pathComponents, PrimitiveType type, Int32 level)
   at Microsoft.ServiceFabric.Yaml2Json.Yaml2Json.FixProperty(JToken container, IList`1 pathComponents, PrimitiveType type, Int32 level)
   at Microsoft.ServiceFabric.Yaml2Json.Yaml2Json.FixProperty(JToken container, IList`1 pathComponents, PrimitiveType type, Int32 level)
   at Microsoft.ServiceFabric.Yaml2Json.Yaml2Json.FixProperty(JToken container, IList`1 pathComponents, PrimitiveType type, Int32 level)
   at Microsoft.ServiceFabric.Yaml2Json.Yaml2Json.FixProperty(JToken container, IList`1 pathComponents, PrimitiveType type, Int32 level)
   at Microsoft.ServiceFabric.Yaml2Json.Yaml2Json.FixProperties(JToken container, IList`1 primitiveProperties)
   at CallSite.Target(Closure , CallSite , Type , Object , IList`1 )
   at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid3[T0,T1,T2](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Microsoft.ServiceFabric.Yaml2Json.Yaml2Json.ToJson(YamlMappingNode yamlNode, String outputPropertyFilter, IList`1 primitiveProperties)
   at SfSbzYamlMerge.Program.SaveMergedJsonDocument(YamlDocument mergedDocument, KeyValuePair`2 resourceKindNamePair)
   at SfSbzYamlMerge.Program.Main(String[] args)
Deployment of Service Fabric application to local Service Fabric cluster failed.
========== Finished ==========
@bjorkstromm
Copy link
Collaborator Author

Problem is related to regional settings in Windows, The SfSbzYamlMerge.exe can't parse a double value with dot (.) as decimal separator, when I change the value to use comma (,), everything works.

The decimal value was found in service.yaml. I changed this:

## Service definition ##
application:
  schemaVersion: 0.0.1
  name: ServiceFabricMesh1
  services:
    - name: Web1
      description: Web1 description.
      osType: Windows
      codePackages:
        - name: Web1
          image: web1:dev
          endpoints:
            - name: Web1Listener
              port: 20001
          environmentVariables:
            - name: ASPNETCORE_URLS
              value: http://+:20001
#            - name: ApplicationInsights:InstrumentationKey
#              value: "<Place AppInsights key here, or reference it via a secret>"
          resources:
            requests:
              cpu: 0.5
              memoryInGB: 1
      replicaCount: 1
      networkRefs:
        - name: ServiceFabricMesh1Network

to this:

## Service definition ##
application:
  schemaVersion: 0.0.1
  name: ServiceFabricMesh1
  services:
    - name: Web1
      description: Web1 description.
      osType: Windows
      codePackages:
        - name: Web1
          image: web1:dev
          endpoints:
            - name: Web1Listener
              port: 20001
          environmentVariables:
            - name: ASPNETCORE_URLS
              value: http://+:20001
#            - name: ApplicationInsights:InstrumentationKey
#              value: "<Place AppInsights key here, or reference it via a secret>"
          resources:
            requests:
              cpu: 0,5
              memoryInGB: 1
      replicaCount: 1
      networkRefs:
        - name: ServiceFabricMesh1Network

@mikkelhegn
Copy link
Contributor

@mholo65 Good find @amanbha

@JohanSellberg
Copy link

I tried changing the dot to a comma as @mholo65 showed and that did pass the SfSbzYamlMerge.exe step.

But then it says that ServiceFabric failed to deploy.

Looking in the Event Viewer it gives the FormatException with the comma. Only way for me to succeed was to change it to 1 cpu to get rid of the decimal problem.

@mikkelhegn
Copy link
Contributor

@JohanSellberg - thanks for the info. We will get this fixed in an update soon.

FYI: The SfSbzYamlMerge.exe outputs a JSON file which get's posted to the local cluster endpoint. Can you share what's in the JSON file? The output folder is the one specified by the /o: parameter

/o:"C:\Users\mb\src\ServiceFabricMesh1\ServiceFabricMesh1\obj\SFApp"

@JohanSellberg
Copy link

I am not sure how this local deploy process works.. Here are the steps I took and the outputs:

I first changed back to the comma and pressed F5 I then get the failed to deploy as previously mentioned.
The exact eventlog message even if some is in swedish:

[(00000000-0000-0000-0000-000000002000:131807980298342570)+eb677a2c-e47c-4600-95a0-d44ee77cc777:0] single instance deployment create failed due to FABRIC_E_IMAGEBUILDER_VALIDATION_ERROR The CpuCores '0,5' is invalid.
FileName: C:\SfDevCluster\Data\ImageBuilderProxy\AppType\SingleInstance_6\ApplicationManifest.xml --> Exception: 0,5 är inte ett giltigt värde för Double. --> FormatException: Indatasträngen hade ett felaktigt format.

But the output folder had not updated. the json file had 1.0 for cpus. as the last sucessfull.

I then closed the project and reopened it (not sure but when opening project it tries to deploy). After it was done with a failed to deploy, the output folder was updated.

{
  "schemaVersion": "1.0.0-preview1",
  "name": "SFMeshTestApp",
  "properties": {
    "services": [
      {
        "name": "SFMeshTestWeb",
        "properties": {
          "description": "SFMeshTestWeb description.",
          "osType": "Windows",
          "codePackages": [
            {
              "name": "SFMeshTestWeb",
              "image": "sfmeshtestweb:dev",
              "endpoints": [
                {
                  "name": "SFMeshTestWebListener",
                  "port": 20006
                }
              ],
              "environmentVariables": [
                {
                  "name": "ASPNETCORE_URLS",
                  "value": "http://+:20006"
                }
              ],
              "resources": {
                "requests": {
                  "cpu": 0.5,
                  "memoryInGB": 1.0
                }
              }
            }
          ],
          "replicaCount": 1,
          "networkRefs": [
            {
              "name": "SFMeshTestAppNetwork"
            }
          ]
        }
      }
    ],
    "description": "SFMeshTestApp description.",
    "debugParams": "[\n  {\n    \"ServiceManifestName\": \"SFMeshTestWebPkg\",\n    \"CodePackageName\": \"SFMeshTestWeb\",\n    \"ContainerDebugParams\":\n    {\n      \"Entrypoint\": [\"C:\\\\remote_debugger\\\\x64\\\\msvsmon.exe\", \"/noauth\", \"/anyuser\", \"/silent\", \"/nostatus\", \"/noclrwarn\", \"/nosecuritywarn\", \"/nofirewallwarn\", \"/nowowwarn\", \"/fallbackloadremotemanagedpdbs\", \"/timeout:2147483646\"],\n      \"EnvVars\": [\"ASPNETCORE_ENVIRONMENT=Development\", \"SERVICE_PROJECT_VOLUME_PATH=C:\\\\app\", \"NUGET_PACKAGES=C:\\\\nuget1\", \"NUGET_FALLBACK_PACKAGES=C:\\\\nuget2\"],\n      \"Volumes\": [\"C:\\\\Users\\\\jose01\\\\onecoremsvsmon\\\\15.0.28010.2016:C:\\\\remote_debugger\", \"C:\\\\Users\\\\jose01\\\\source\\\\repos\\\\SFMeshTestApp\\\\SFMeshTestWeb:C:\\\\app\", \"C:\\\\Users\\\\jose01\\\\.nuget\\\\packages:C:\\\\nuget1\", \"C:\\\\Program Files\\\\dotnet\\\\sdk\\\\NuGetFallbackFolder:C:\\\\nuget2\"]\n    }\n  }\n]\n"
  }
}

So output folder had with a .

@mikkelhegn
Copy link
Contributor

Thanks @JohanSellberg @anantshankar17, can you please help look in to this?

@anantshankar17
Copy link

Hello @JohanSellberg
If the output json has a "." then it should get deployed. Can you look at the "output" tab in VS, and in that "Show Output from "Service fabric Tools"" and copy paste the execution info from there ?
Also service fabric traces from C:\SfDevCluster\Log\Traces will also help.

@JohanSellberg
Copy link

Sure here is my information from the Output when using , in the yml file:

========== Checking for Container Prerequisites ==========
Verifying that Docker for Windows is installed...
Docker for Windows is installed.
Verifying that Docker for Windows is running...
Docker for Windows is running.
Verifying that the Service Fabric SDK is installed...
The Service Fabric SDK is installed.
Finding required service projects...
Service projects found.
========== Pulling Required Images ==========
Checking for missing Docker images...
Docker images are ready.
========== Warming up Service Fabric application ==========
Verifying that Docker for Windows' operating system mode matches the project's target operating system...
Docker for Windows' operating system mode matches the project's mode.
Preparing Docker images for service projects...
The Dockerfile 'C:\Users\jose01\source\repos\SFMeshTestApp\SFMeshTestWeb\Dockerfile' will be used to build image sfmeshtestweb:dev needed by Service SFMeshTestWeb, CodePackage SFMeshTestWeb.
The existing image sfmeshtestweb:dev does not need to be rebuilt.
Docker images are ready.
Preparing the debugger...
Debugger is ready.
The container runtime settings for Service SFMeshTestWeb, CodePackage SFMeshTestWeb have not changed since the last deployment.
Preparing Service Fabric application in local Service Fabric cluster...
A running container for Service SFMeshTestWeb, CodePackage SFMeshTestWeb was not found.
C:\Program Files\Microsoft SDKs\Service Fabric\Tools\Mesh\SfSbzYamlMerge\SfSbzYamlMerge.exe  /i:"C:\Users\jose01\source\repos\SFMeshTestApp\SFMeshTestWeb\Service Resources\service.yaml" /i:"C:\Users\jose01\source\repos\SFMeshTestApp\SFMeshTestApp\App Resources\app.yaml" /i:"C:\Users\jose01\source\repos\SFMeshTestApp\SFMeshTestApp\obj\SFApp\App.debug.yaml" /o:"C:\Users\jose01\source\repos\SFMeshTestApp\SFMeshTestApp\obj\SFApp" /of:"SF_SBZ_JSON"
{
  "properties": {
      {
          "osType": "Windows",
              "name": "SFMeshTestWeb",
  "schemaVersion": "1.0.0-preview1",
              "image": "sfmeshtestweb:dev",
              ],
    "services": [
                  "port": 20006
            {
              "environmentVariables": [
                }
                  "name": "SFMeshTestWebListener",
          "codePackages": [
              "resources": {
          "description": "SFMeshTestWeb description.",
                }
        "properties": {
                  "cpu": 0.5,
                  "name": "ASPNETCORE_URLS",
              "endpoints": [
              }
        "name": "SFMeshTestWeb",
  "name": "SFMeshTestApp",
              ],
            }
                {
                "requests": {
        }
                }
            }
                  "value": "http://+:20006"
    "debugParams": "[\n  {\n    \"ServiceManifestName\": \"SFMeshTestWebPkg\",\n    \"CodePackageName\": \"SFMeshTestWeb\",\n    \"ContainerDebugParams\":\n    {\n      \"Entrypoint\": [\"C:\\\\remote_debugger\\\\x64\\\\msvsmon.exe\", \"/noauth\", \"/anyuser\", \"/silent\", \"/nostatus\", \"/noclrwarn\", \"/nosecuritywarn\", \"/nofirewallwarn\", \"/nowowwarn\", \"/fallbackloadremotemanagedpdbs\", \"/timeout:2147483646\"],\n      \"EnvVars\": [\"ASPNETCORE_ENVIRONMENT=Development\", \"SERVICE_PROJECT_VOLUME_PATH=C:\\\\app\", \"NUGET_PACKAGES=C:\\\\nuget1\", \"NUGET_FALLBACK_PACKAGES=C:\\\\nuget2\"],\n      \"Volumes\": [\"C:\\\\Users\\\\jose01\\\\onecoremsvsmon\\\\15.0.28010.2016:C:\\\\remote_debugger\", \"C:\\\\Users\\\\jose01\\\\source\\\\repos\\\\SFMeshTestApp\\\\SFMeshTestWeb:C:\\\\app\", \"C:\\\\Users\\\\jose01\\\\.nuget\\\\packages:C:\\\\nuget1\", \"C:\\\\Program Files\\\\dotnet\\\\sdk\\\\NuGetFallbackFolder:C:\\\\nuget2\"]\n    }\n  }\n]\n"
          "networkRefs": [
}
          ],
          "replicaCount": 1,
            {
                  "memoryInGB": 1.0
              "name": "SFMeshTestAppNetwork"
          ]
                {
      }
    ],
  }
    "description": "SFMeshTestApp description.",

Ensuring previously deployed application is removed...
Deploying application to local Service Fabric cluster...
C:\WINDOWS\sysnative\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "import-module 'C:\Program Files\Microsoft SDKs\Service Fabric\Tools\Mesh\Scripts\PSModule\ServiceFabricHttpPSModule.dll'; Connect-SFCluster -Endpoint http://localhost:19080; .'C:\Program Files\Microsoft SDKs\Service Fabric\Tools\Mesh\Scripts\Deploy-ServiceFabricApplicationResource.ps1' -ApplicationResourcename SFMeshTestApp -ResourceDescriptionFile 'C:\Users\jose01\source\repos\SFMeshTestApp\SFMeshTestApp\obj\SFApp\merged-application-SFMeshTestApp.json'"
Deploying the application to the Service Fabric local cluster failed. See Service Fabric Explorer for additional details.
Deployment of Service Fabric application to local Service Fabric cluster failed.
========== Finished ==========

As you see in the end it still fails even if it has changed it to a dot. And when I check the error message (could only find error message in the EventLog). I can see that the error is still FormatException. As previously posted the error is:

[(00000000-0000-0000-0000-000000002000:131807980298342570)+eb677a2c-e47c-4600-95a0-d44ee77cc777:0] single instance deployment create failed due to FABRIC_E_IMAGEBUILDER_VALIDATION_ERROR The CpuCores '0,5' is invalid.
FileName: C:\SfDevCluster\Data\ImageBuilderProxy\AppType\SingleInstance_6\ApplicationManifest.xml --> Exception: 0,5 är inte ett giltigt värde för Double. --> FormatException: Indatasträngen hade ett felaktigt format.

So when I use , the yml file works as expected. But ApplicationManifest gets Invalid FormatException.

@anantshankar17
Copy link

Can you manually execute the cmd and collect the cluster traces and share them ?

C:\WINDOWS\sysnative\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "import-module 'C:\Program Files\Microsoft SDKs\Service Fabric\Tools\Mesh\Scripts\PSModule\ServiceFabricHttpPSModule.dll'; Connect-SFCluster -Endpoint http://localhost:19080; .'C:\Program Files\Microsoft SDKs\Service Fabric\Tools\Mesh\Scripts\Deploy-ServiceFabricApplicationResource.ps1' -ApplicationResourcename SFMeshTestApp -ResourceDescriptionFile 'C:\Users\jose01\source\repos\SFMeshTestApp\SFMeshTestApp\obj\SFApp\merged-application-SFMeshTestApp.json'"

Since this is the app json that you're deploying manually, you may also validate if this file doesn't container the comma which is which visible in the error string: " Exception: 0,5 är inte ett giltigt värde för Double". It is strange to see this error if the json is successfully getting generated without the comma separator.

@JohanSellberg
Copy link

Well if you look close the second EventViewer Message it isn't the json, it is ApplicationManifest.xml But I guess that is somehow generated from the json? And there is Format Convert problems there?
I will try run the command later during the day.

@JohanSellberg
Copy link

I tried the command but I still get an error in the Event Log... I also get a related warning at the same time.. Maybe that gives some more information.. I copies the XML for the warning:

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name="Microsoft-ServiceFabric" Guid="{CBD93BC2-71E5-4566-B3A7-595D8EECA6E8}" /> 
  <EventID>59648</EventID> 
  <Version>1</Version> 
  <Level>2</Level> 
  <Task>233</Task> 
  <Opcode>0</Opcode> 
  <Keywords>0x8000000000000001</Keywords> 
  <TimeCreated SystemTime="2018-09-19T07:16:36.181725500Z" /> 
  <EventRecordID>1230</EventRecordID> 
  <Correlation /> 
  <Execution ProcessID="21088" ThreadID="36316" /> 
  <Channel>Microsoft-ServiceFabric/Admin</Channel> 
  <Computer>XXXX</Computer> 
  <Security UserID="XXXX" /> 
  </System>
- <EventData>
  <Data Name="id" /> 
  <Data Name="type">ManifestValidatorUtility</Data> 
  <Data Name="message">Value '0,5' cannot be assigned to CpuCores.</Data> 
  </EventData>
  </Event>

@anantshankar17
Copy link

I would still need the cluster traces to makeout what is not working correctly. Can you please share the traces ? For now I would suggest you to not use the comma, until we figure out what all is not working. In the meantime we will try to repro this locally to debug faster. The locale that you have is fi-FI, right?

@JohanSellberg
Copy link

Not fully sure how to check locale but should be sv or sv-SE since its swedish.
How can I see traces? The command did not output anything in cmd window.

@anantshankar17
Copy link

You would find the traces here: C:\SfDevCluster\Log\Traces

@JohanSellberg
Copy link

JohanSellberg commented Sep 19, 2018

Ok here is the trace file no0t sure if you need the lease_traces too, just say if you do. (both in 1 zip was too big)
fabric_traces_6.3.176.9494_131816473619706080_0.zip

Also confirmed with powershell that my locale is sv-SE

LCID             Name             DisplayName                                                                                                                           
----             ----             -----------                                                                                                                           
1053             sv-SE            Svenska (Sverige) 

@nforss
Copy link

nforss commented Oct 2, 2018

I'm having the exact same problem. Did you find a solution?

@anantshankar17
Copy link

@nforss For now we suggest you avoid using the decimal values in the yamls. we will have fixes rolled out for these issues soon.

@anantshankar17
Copy link

These issues are all fixed in the latest SF Release 6.4.637 and SDK version 3.3.637. Kindly try them out and let us know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants