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

panic: runtime error: index out of range #5

Closed
lucaschain opened this issue Feb 21, 2017 · 3 comments
Closed

panic: runtime error: index out of range #5

lucaschain opened this issue Feb 21, 2017 · 3 comments

Comments

@lucaschain
Copy link
Contributor

Good night, I had this problem when trying ecs-gen, I'm using the default nginx template from codesuki/ecs-nginx-proxy

here's my command output:

[chain@localhost dev]$ ./ecs-gen-linux-amd64 --template=nginx.tmpl --output=out --cluster=kanto
2017/02/21 02:13:45 updating config
panic: runtime error: index out of range

goroutine 1 [running]:
panic(0x97b5c0, 0xc42000e160)
	/usr/local/go/src/runtime/panic.go:500 +0x1a1
main.(*ecsClient).describeCluster(0xc4200961f0, 0x7ffc3b4c2262, 0x5, 0x9161e0, 0xc420075f20, 0xc4200e1640)
	/go/src/github.com/codesuki/ecs-gen/ecs.go:27 +0x142
main.(*scanner).scan(0xc420043d90, 0xc420043dd0, 0x412bce, 0xc4200961f0, 0x8, 0x8)
	/go/src/github.com/codesuki/ecs-gen/scanner.go:29 +0xc3
main.updateAndWrite(0xc4200961d8, 0xc4200961f0)
	/go/src/github.com/codesuki/ecs-gen/main.go:95 +0x99
main.execute(0xc4200961d8, 0xc4200961f0)
	/go/src/github.com/codesuki/ecs-gen/main.go:80 +0x55
main.main()
	/go/src/github.com/codesuki/ecs-gen/main.go:73 +0x1d1

My only cluster's EC2 intance has the following inline permissions:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "*****************",
            "Effect": "Allow",
            "Action": [
                "ecs:DescribeClusters",
                "ecs:DescribeContainerInstances",
                "ecs:DescribeServices",
                "ecs:DescribeTaskDefinition",
                "ecs:DescribeTasks",
                "ecs:ListClusters",
                "ecs:ListContainerInstances",
                "ecs:ListServices",
                "ecs:ListTaskDefinitionFamilies",
                "ecs:ListTaskDefinitions",
                "ecs:ListTasks"
            ],
            "Resource": [
                "arn:aws:ecs:::*/*"
            ]
        }
    ]
}

Is there anything I'm doing wrong?

@codesuki
Copy link
Owner

codesuki commented Feb 21, 2017

Hi! I cannot tell you exactly where the problem is but let's try to debug it.

I replicated your bug by setting a cluster, i.e. --cluster doesntexist that does not exist.

Adding some prints I found the following response

  Clusters: [],
  Failures: [{
      Arn: "arn:aws:ecs:ap-northeast-1:664653893268:cluster/doesntexist",
      Reason: "MISSING"
    }]
}

So, I know it sounds stupid but, can you make sure you have a cluster called kanto?
Also it seems you are running the command from your local dev machine which is ok as long as your user has enough rights etc.

To easily get the correct reason for the crash you can change the code directly in $GOPATH/src/github.com/codesuki/ecs-gen/
Change line 25 to

resp, err := e.ecs.DescribeClusters(params)
fmt.Println(resp)

After recompiling and running again you should get a reason for the command failing.
Let me know what it says!
Good luck!

Note: Do better error handling in describeCluster

@lucaschain
Copy link
Contributor Author

Hey, thanks for the fast response.

I was able to debug and my problem was exactly what you said: my cluster didn't exist because I did not specify the region I wanted (I thought the default option was the one I set in aws configure.

When I specify my region with the --region flag it works okay.

I would love to contribute to this amazing tool, the only problem is that I am not good with golang yet.

Again, thank you very much

@codesuki
Copy link
Owner

Glad it's fixed!

That would be a neat feature, to have it read the aws config.

Feel free to send a pullrequest if you want to add some feature. We can talk about how to organize the code etc :)

codesuki added a commit that referenced this issue Feb 22, 2017
Show usage hints and return error if cluster was not found.

Fixes #5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants