ams get hook failed: "registry-client-relation-changed" when deploying with aar

Bug #2106349 reported by Shunde Zhang
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Anbox Cloud
Fix Released
Medium
Gary.Wang

Bug Description

A user deploys ams and aar in one juju deploy command, which means juju will deploy them at the same time. But ams runs into a hook error. aar is deployed properly though.

App Version Status Scale Charm Channel Rev Exposed Message
aar 1.25.1-0fe31... active 1 aar 1.25/stable 952 no
ams 1.25.1-0fe31... error 1 ams 1.25/edge 994 no hook failed: "registry-client-relation-changed"

aar/0* active idle 4 98.83.118.9 3000/tcp
ams/0* error idle 2 44.205.6.129 hook failed: "registry-client-relation-changed"

In ams juju log, it shows:

2025-04-07 00:58:35 INFO juju.worker.uniter resolver.go:180 awaiting error resolution for "relation-changed" hook
2025-04-07 00:58:35 WARNING unit.ams/0.juju-log server.go:326 registry-client:26: <class '__main__.AmsOperatorCharm'>.tracing_cert is None; sending traces over INSECURE connection.
2025-04-07 00:58:35 ERROR unit.ams/0.juju-log server.go:326 registry-client:26: Waiting for ams to start to share certificate
2025-04-07 00:58:35 ERROR unit.ams/0.juju-log server.go:326 registry-client:26: AMS not yet started
2025-04-07 00:58:35 ERROR unit.ams/0.juju-log server.go:326 registry-client:26: Uncaught exception while in charm code:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-ams-0/charm/./src/charm.py", line 682, in <module>
    main(AmsOperatorCharm)
  File "/var/lib/juju/agents/unit-ams-0/charm/venv/ops/__init__.py", line 343, in __call__
    return _main.main(charm_class=charm_class, use_juju_for_storage=use_juju_for_storage)
  File "/var/lib/juju/agents/unit-ams-0/charm/venv/ops/_main.py", line 543, in main
    manager.run()
  File "/var/lib/juju/agents/unit-ams-0/charm/venv/ops/_main.py", line 529, in run
    self._emit()
  File "/var/lib/juju/agents/unit-ams-0/charm/venv/ops/_main.py", line 518, in _emit
    _emit_charm_event(self.charm, self.dispatcher.event_name, self._juju_context)
  File "/var/lib/juju/agents/unit-ams-0/charm/venv/ops/_main.py", line 134, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-ams-0/charm/venv/ops/framework.py", line 347, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-ams-0/charm/venv/ops/framework.py", line 857, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-ams-0/charm/venv/ops/framework.py", line 947, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-ams-0/charm/lib/charms/tempo_coordinator_k8s/v0/charm_tracing.py", line 1064, in wrapped_function
    return callable(*args, **kwargs) # type: ignore
  File "/var/lib/juju/agents/unit-ams-0/charm/./src/charm.py", line 416, in _on_registry_client_changed
    self.ams.setup_aar(
  File "/var/lib/juju/agents/unit-ams-0/charm/src/ams.py", line 268, in setup_aar
    self.register_client(certificate)
  File "/var/lib/juju/agents/unit-ams-0/charm/src/ams.py", line 327, in register_client
    current_certs = self.get_registered_certificates()
  File "/var/lib/juju/agents/unit-ams-0/charm/src/ams.py", line 320, in get_registered_certificates
    return json.loads(result.stdout.decode())
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
2025-04-07 00:58:36 ERROR juju.worker.uniter.operation runhook.go:180 hook "registry-client-relation-changed" (via hook dispatching script: dispatch) failed: exit status 1
2025-04-07 00:58:36 INFO juju.worker.uniter resolver.go:180 awaiting error resolution for "relation-changed" hook

It looks the charm wants to get a token for aar but ams is not running yet. [1]
then set the unit state to error which stops ams configuration.
Probably should check if ams is running in [1] before attempting to configure aar.

A workaround is to deploy aar and ams without a relation between them. Then add the relation after they are up and running.

[1] https://github.com/canonical/anbox-cloud-charms/blob/stable-1.25/charms/ams/src/charm.py#L393

Gary.Wang (gary-wzl77)
Changed in anbox-cloud:
milestone: none → 1.25.2
status: New → In Progress
assignee: nobody → Gary.Wang (gary-wzl77)
importance: Undecided → Medium
Gary.Wang (gary-wzl77)
Changed in anbox-cloud:
status: In Progress → Fix Committed
Gary.Wang (gary-wzl77)
Changed in anbox-cloud:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.