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

deployments.items[0] -> IndexError: list index out of range #9

Open
lhriley opened this issue Jan 28, 2019 · 1 comment
Open

deployments.items[0] -> IndexError: list index out of range #9

lhriley opened this issue Jan 28, 2019 · 1 comment

Comments

@lhriley
Copy link

lhriley commented Jan 28, 2019

I found your SQS autoscaler from the Wattpad issues discussion (Wattpad/kube-sqs-autoscaler#7). Unfortunately, your tool is apparently suffering from it's own issues.

I ran into the region problem (#1), and was able to fix it with the suggested env var. However, I'm not faced with the following:

{'sqs_queue_url': '<sqs url>', 'kubernetes_deployment': '<deployment>', 'kubernetes_namespace': <namespace>', 'aws_region': '<region>', 'poll_period': 5, 'scale_down_cool_down': 300, 'scale_up_cool_down': 30, 'scale_up_messages': 2, 'scale_down_messages': 0, 'max_pods': 5, 'min_pods': 1}
Starting poll for <sqs url> every 5s
Waiting for scale up cooldown
Waiting for scale up cooldown
Waiting for scale up cooldown
Waiting for scale up cooldown
Waiting for scale up cooldown
Waiting for scale up cooldown
loading deployment: <deployment> from namespace: <namepsace>
Traceback (most recent call last):
  File "./k8s-sqs-autoscaler", line 71, in <module>
    sqs.run(options)
  File "/usr/src/app/sqs/sqs.py", line 95, in run
    SQSPoller(options).run()
  File "/usr/src/app/sqs/sqs.py", line 88, in run
    self.poll()
  File "/usr/src/app/sqs/sqs.py", line 35, in poll
    self.scale_up()
  File "/usr/src/app/sqs/sqs.py", line 50, in scale_up
    deployment = self.deployment()
  File "/usr/src/app/sqs/sqs.py", line 74, in deployment
    return deployments.items[0]
IndexError: list index out of range

The error isn't really all that clear. Is this due to a lack of RBAC permissions? Or just some bad logic in your code? I can't really tell, unfortunately.

@amitnanaware
Copy link

amitnanaware commented Feb 22, 2019

@lhriley
The error says that the api is not getting any response for deployments. the code is as below:

deployments = self.extensions_v1_beta1.list_namespaced_deployment(self.options.kubernetes_namespace, label_selector="app={}".format(self.options.kubernetes_deployment))
return deployments.items[0]

Make sure the namespace and deployment which you are passing is correct. The deployment here is the label which you defile in deployment section of your yaml file e.g.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: frontend
spec:
  template:
    metadata:
      labels:
        app: frontend

In this case value of deployment is frontend.

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