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

KeyError: 'status' when running redisboard within Kubernetes Django #51

Open
abhinavsingh opened this issue Oct 1, 2024 · 2 comments
Open

Comments

@abhinavsingh
Copy link

Hi, our integration with django-redisboard went well in DEV. But as we pushed this to our non-DEV environments, we are observing weird KeyError: 'status' issues. Here is what I tried:

  1. Added a redis server with url as redis://cloud-redis-gcp-memstore. cloud-redis-gcp-memstore is the same entry that we use for Django's REDIS_HOST variable. But this failed. Looks like redisboard wasn't able to reach this host, while Django could.

  2. Next, we added FQDN for cloud-redis-gcp-memstore.namespace.svc.cluster.local and it started working, but this time running into KeyError: 'status'. We also tried changing url to 10.244.20.116, internal IP over which redis is accessible, but we continue to get KeyError: 'status'.

It specifically errors out during

args | ["SLOWLOG GET",10]
-- | --
instance | ClosableStrictRedis<ConnectionPool<Connection<host=cloud-redis-gcp-memstore.namespace.svc.cluster.local,port=6379,db=0>>>

I am not sure if this issue is specific to Kubernetes environment in any ways. This worked out of box in DEV environment where redis url was simply redis://127.0.0.1

@ionelmc
Copy link
Owner

ionelmc commented Oct 1, 2024

Do you have a traceback? What is the redis server version?

@abhinavsingh
Copy link
Author

abhinavsingh commented Oct 2, 2024

  • Redis Version 6.x
  • Stacktrace
KeyError: 'status'
  File "django/db/models/options.py", line 681, in get_field
    return self.fields_map[field_name]
FieldDoesNotExist: RedisServer has no field named 'status'
  File "django/contrib/admin/utils.py", line 272, in lookup_field
    f = _get_non_gfk_field(opts, name)
  File "django/contrib/admin/utils.py", line 303, in _get_non_gfk_field
    field = opts.get_field(name)
  File "django/db/models/options.py", line 683, in get_field
    raise FieldDoesNotExist(
TypeError: sequence item 0: expected str instance, int found
  File "django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 220, in _get_response
    response = response.render()
  File "django/template/response.py", line 114, in render
    self.content = self.rendered_content
  File "django/template/response.py", line 92, in rendered_content
    return template.render(context, self._request)
  File "django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "elasticapm/instrumentation/packages/base.py", line 213, in call_if_sampling
    return self.call(module, method, wrapped, instance, args, kwargs)
  File "elasticapm/instrumentation/packages/django/template.py", line 46, in call
    return wrapped(*args, **kwargs)
  File "django/template/base.py", line 175, in render
    return self._render(context)
  File "django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 1005, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 966, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 157, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 1005, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 966, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 157, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 1005, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 966, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 157, in render
    return compiled_parent._render(context)
  File "django/template/base.py", line 167, in _render
    return self.nodelist.render(context)
  File "django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 1005, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 966, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 63, in render
    result = block.nodelist.render(context)
  File "django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 1005, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 966, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 63, in render
    result = block.nodelist.render(context)
  File "django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 1005, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 966, in render_annotated
    return self.render(context)
  File "django/template/loader_tags.py", line 63, in render
    result = block.nodelist.render(context)
  File "django/template/base.py", line 1005, in render
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 1005, in <listcomp>
    return SafeString("".join([node.render_annotated(context) for node in self]))
  File "django/template/base.py", line 966, in render_annotated
    return self.render(context)
  File "django/contrib/admin/templatetags/base.py", line 45, in render
    return super().render(context)
  File "django/template/library.py", line 258, in render
    _dict = self.func(*resolved_args, **resolved_kwargs)
  File "django/contrib/admin/templatetags/admin_list.py", line 336, in result_list
    "results": list(results(cl)),
  File "django/contrib/admin/templatetags/admin_list.py", line 312, in results
    yield ResultList(None, items_for_result(cl, res, None))
  File "django/contrib/admin/templatetags/admin_list.py", line 303, in __init__
    super().__init__(*items)
  File "django/contrib/admin/templatetags/admin_list.py", line 213, in items_for_result
    f, attr, value = lookup_field(field_name, result, cl.model_admin)
  File "django/contrib/admin/utils.py", line 281, in lookup_field
    value = attr(obj)
  File "redisboard/admin.py", line 76, in status
    return obj.stats.status
  File "functools.py", line 1001, in __get__
    val = self.func(instance)
  File "redisboard/models.py", line 173, in stats
    slowlog = conn.slowlog_get(num=REDISBOARD_SLOWLOG_NUM)
  File "redis/commands/core.py", line 1320, in slowlog_get
    return self.execute_command(*args, **kwargs)
  File "elasticapm/instrumentation/packages/base.py", line 213, in call_if_sampling
    return self.call(module, method, wrapped, instance, args, kwargs)
  File "elasticapm/instrumentation/packages/redis.py", line 66, in call
    return wrapped(*args, **kwargs)

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