Skip to content

Remove trailing empty argument in ContainerCommand #8891

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

Merged
merged 5 commits into from
Apr 1, 2019
Merged

Remove trailing empty argument in ContainerCommand #8891

merged 5 commits into from
Apr 1, 2019

Conversation

ssemyan
Copy link
Contributor

@ssemyan ssemyan commented Mar 28, 2019

The New-AzContainerGroup -Command argument adds an extra empty argument to the end of the commands. This is because Parser.ParseInput will return EOF as the final token. This means any programs using command arguments will get an extra empty argument passed in. The Python-based az cli does not do this. To repro:

  1. Create an app that shows how many arguments were passed into it. For example in .net core:
class Program
{
        static void Main(string[] args)
        {
            Console.WriteLine("I have {0} arguments", args.Length);
        }
}
  1. Add this to a container and push to a registry.
  2. Run the container as an ACI using powershell
New-AzContainerGroup -ResourceGroupName test -Name bugtest -Image showargImage -OsType Linux -Command "dotnet showargs.dll one two three"
  1. Examine the logs:
Get-AzContainerInstanceLog -ResourceGroupName test -ContainerGroupName bugtest
I have 4 arguments
  1. Run the image using the az CLI
az container create --resource-group test --name bugtest2 --image showargImage --command-line "dotnet BugTest.dll one two three"
  1. Examine the output
az container logs --resource-group akstest --name bugtest2
I have 3 arguments

Description

Checklist

The New-AzContainerGroup -Command argument adds an extra empty argument to the end of the commands. This is because Parser.ParseInput will return <EOF> as the final token. This means any programs using command arguments will get an extra empty argument passed in. The Python-based az cli does not do this. To repro: 

1. Create an app that shows how many arguments were passed into it. For example in .net core:  
```
class Program
{
        static void Main(string[] args)
        {
            Console.WriteLine("I have {0} arguments", args.Length);
        }
}
```
2. Add this to a container and push to a registry. 
3. Run the container as an ACI using powershell
```
New-AzContainerGroup -ResourceGroupName test -Name bugtest -Image showargImage -OsType Linux -Command "dotnet showargs.dll one two three"
```
4. Examine the logs:
```
Get-AzContainerInstanceLog -ResourceGroupName test -ContainerGroupName bugtest
I have 4 arguments
```
5. Run the image using the az CLI
```
az container create --resource-group test --name bugtest2 --image showargImage --command-line "dotnet BugTest.dll one two three"
``` 
6. Examine the output
```
az container logs --resource-group akstest --name bugtest2
I have 3 arguments
```
@markcowl markcowl removed their assignment Mar 28, 2019
Copy link
Member

@markcowl markcowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution - if you can add a short description for this change to the changelog, we will be happy to include it.

ssemyan and others added 2 commits March 29, 2019 10:42
Added a note as requested to describe the fixed issue with the -Command parameter of New-AzContainerGroup
@cormacpayne cormacpayne merged commit aea4fce into Azure:master Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants