canonical / oathkeeper-operator

Charmed Ory Oathkeeper
https://charmhub.io/oathkeeper
Apache License 2.0
1 stars 4 forks source link

statefulsets.apps "oathkeeper" not found #40

Closed sed-i closed 9 months ago

sed-i commented 9 months ago

Bug Description

On startup, the charm is stuck in

Unit     Workload  Agent      Address       Ports  Message
ok/0*    waiting   executing  10.1.166.110         Waiting for Oathkeeper service

To Reproduce

I deployed the following bundle:

bundle: kubernetes
applications:
  ok:
    # From https://github.com/canonical/oathkeeper-operator
    charm: ./oathkeeper-operator/oathkeeper_ubuntu-22.04-amd64.charm
    scale: 1
    trust: true
    resources:
      oci-image: "ghcr.io/canonical/oathkeeper:0.40.6"
  trfk:
    # From https://github.com/canonical/traefik-k8s-operator/pull/275
    charm: ./traefik-k8s-operator/traefik-k8s_ubuntu-20.04-amd64.charm
    series: focal
    scale: 1
    trust: true
    resources:
      traefik-image: "docker.io/ubuntu/traefik:2-22.04"  
  zinc:
    # From https://github.com/natalian98/zinc-k8s-operator/tree/test-proxy-interfaces
    charm: ./zinc-k8s-operator/zinc-k8s_ubuntu-22.04-amd64.charm
    scale: 1
    trust: true
    resources:
      zinc-image: "ghcr.io/jnsgruk/zinc:0.4.9"
relations:
- - ok:forward-auth
  - trfk:experimental-forward-auth
- - ok:auth-proxy
  - zinc:auth-proxy
- - zinc:ingress
  - trfk:ingress

Environment

Juju 3.1.6.

Relevant log output

unit-ok-0: 14:55:12.963 ERROR unit.ok/0.juju-log Uncaught exception while in charm code:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-ok-0/charm/venv/lightkube/core/generic_client.py", line 188, in raise_for_status
    resp.raise_for_status()
  File "/var/lib/juju/agents/unit-ok-0/charm/venv/httpx/_models.py", line 758, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '404 Not Found' for url 'https://10.152.183.1/apis/apps/v1/namespaces/auth2/statefulsets/oathkeeper?fieldManager=ok'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-ok-0/charm/./src/charm.py", line 555, in <module>
    main(OathkeeperCharm)
  File "/var/lib/juju/agents/unit-ok-0/charm/venv/ops/main.py", line 436, in main
    _emit_charm_event(charm, dispatcher.event_name)
  File "/var/lib/juju/agents/unit-ok-0/charm/venv/ops/main.py", line 144, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-ok-0/charm/venv/ops/framework.py", line 340, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-ok-0/charm/venv/ops/framework.py", line 842, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-ok-0/charm/venv/ops/framework.py", line 931, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-ok-0/charm/./src/charm.py", line 329, in _on_oathkeeper_pebble_ready
    self._patch_statefulset()
  File "/var/lib/juju/agents/unit-ok-0/charm/./src/charm.py", line 318, in _patch_statefulset
    self.client.patch(StatefulSet, name=self.meta.name, namespace=self.model.name, obj=patch)
  File "/var/lib/juju/agents/unit-ok-0/charm/venv/lightkube/core/client.py", line 325, in patch
    return self._client.request("patch", res=res, name=name, namespace=namespace, obj=obj,
  File "/var/lib/juju/agents/unit-ok-0/charm/venv/lightkube/core/generic_client.py", line 245, in request
    return self.handle_response(method, resp, br)
  File "/var/lib/juju/agents/unit-ok-0/charm/venv/lightkube/core/generic_client.py", line 196, in handle_response
    self.raise_for_status(resp)
  File "/var/lib/juju/agents/unit-ok-0/charm/venv/lightkube/core/generic_client.py", line 190, in raise_for_status
    raise transform_exception(e)
lightkube.core.exceptions.ApiError: statefulsets.apps "oathkeeper" not found
unit-ok-0: 14:55:13.190 ERROR juju.worker.uniter.operation hook "oathkeeper-pebble-ready" (via hook dispatching script: dispatch) failed: exit status 1
unit-ok-0: 14:55:13.191 ERROR juju.worker.uniter pebble poll failed for container "oathkeeper": failed to send pebble-ready event: hook failed

Additional context

https://github.com/canonical/traefik-k8s-operator/pull/275

syncronize-issues-to-jira[bot] commented 9 months ago

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/IAM-587.

This message was autogenerated

natalian98 commented 9 months ago

Hi @sed-i, thanks for taking the time to report this issue. The charm was trying to patch a statefulset with a wrong name - ops.CharmMeta.name, which appears not to be the juju charm name as stated in the docs. So it was trying to patch a statefulset named oathkeeper instead of the ok alias you gave it. It will be fixed by https://github.com/canonical/oathkeeper-operator/pull/41. Thanks!