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

MpsAgent fails when StartGameCommand is not empty #7

Open
DavidLoftus opened this issue Apr 14, 2021 · 1 comment
Open

MpsAgent fails when StartGameCommand is not empty #7

DavidLoftus opened this issue Apr 14, 2021 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@DavidLoftus
Copy link

MpsAgent incorrectly adds Windows specific prefix "cmd /c " to StartGameCommand on Linux Containers (with -lcow flag).
Upon inspection of the source, it seems that the code uses SystemOperations to get the host operating system, but this fails when using -lcow as the container is Linux while the host is Windows. This springs up more issues with properties like GameWorkingDirectory.

As an example this configuration:

{
    "RunContainer": true,
    "OutputFolder": "C:\\src\\LocalMultiplayerAgentPublish\\output",
    "NumHeartBeatsForActivateResponse": 10,
    "NumHeartBeatsForTerminateResponse": 60,
    "TitleId": "ABC123",
    "BuildId": "00000000-0000-0000-0000-000000000000",
    "Region": "EastUs",
    "AgentListeningPort": 56001,
    "ContainerStartParameters": {
        "ImageDetails": { 
            "Registry": "docker.io",
            "ImageName": "ubuntu",
            "ImageTag": "18.04"
        },
        "StartGameCommand": "sleep 100"
    },
    "PortMappingsList": [
        [
            {
                "NodePort": 80,
                "GamePort": {
                    "Name": "http",
                    "Number": 80,
                    "Protocol": "TCP"
                }
            }
        ]
    ],
    "SessionConfig": {
        "SessionId": "731f8b7a-a90d-4e74-b78e-79ff22177f07",
        "SessionCookie": null,
        "InitialPlayers": []
    }
}

results in the error:

fail: PlayFabLocalMultiplayerAgent[0]
      Failed to start container based host with instance number 0. Exception: Docker.DotNet.DockerApiException: Docker API responded with status code=BadRequest, response={"message":"OCI runtime create failed: container_linux.go:370: starting container process caused: exec: \"cmd /c sleep 100\": stat cmd /c sleep 100: no such file or directory: unknown"}
         at Docker.DotNet.DockerClient.HandleIfErrorResponseAsync(HttpStatusCode statusCode, HttpResponseMessage response, IEnumerable`1 handlers)
         at Docker.DotNet.DockerClient.MakeRequestAsync(IEnumerable`1 errorHandlers, HttpMethod method, String path, IQueryString queryString, IRequestContent body, IDictionary`2 headers, TimeSpan timeout, CancellationToken token)
         at Docker.DotNet.ContainerOperations.StartContainerAsync(String id, ContainerStartParameters parameters, CancellationToken cancellationToken)
         at Microsoft.Azure.Gaming.VmAgent.ContainerEngines.DockerContainerEngine.<>c__DisplayClass16_0.<<StartContainer>b__0>d.MoveNext()
      --- End of stack trace from previous location where exception was thrown ---
         at Microsoft.Azure.Gaming.VmAgent.TaskUtil.TimedExecute[T](Func`1 action, MultiLogger logger, String eventName, String metricName, Int64 elapsedThreshold)
         at Microsoft.Azure.Gaming.VmAgent.ContainerEngines.DockerContainerEngine.StartContainer(String containerId)
         at Microsoft.Azure.Gaming.VmAgent.ContainerEngines.DockerContainerEngine.CreateAndStart(Int32 instanceNumber, GameResourceDetails gameResourceDetails, ISessionHostManager sessionHostManager)
Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Azure.Gaming.LocalMultiplayerAgent.MultiplayerServerManager.CreateAndStartContainerWaitForExit(SessionHostsStartInfo startParameters)
   at Microsoft.Azure.Gaming.LocalMultiplayerAgent.Program.Main(String[] args)
   at Microsoft.Azure.Gaming.LocalMultiplayerAgent.Program.<Main>(String[] args)

I tried making a quick fix PR but seems to require reworking more than a few lines in order to avoid breaking other features. This seems to stem from SystemOperations being used for both the host (reading writing files) and the host (parsing paths in configuration).

@dgkanatsios dgkanatsios added bug Something isn't working good first issue Good for newcomers labels Apr 16, 2021
@dgkanatsios
Copy link
Contributor

thanks for reporting @DavidLoftus! We'll add this to the backlog, but if anyone wants to work on a PR for this, we'd be more than happy to help!

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

No branches or pull requests

2 participants