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

Multiple istio-ingress-k8s charms try to apply changes in a single underlying HTTPRoute resource which causes conflicts #22

Open
wood-push-melon opened this issue Nov 18, 2024 · 0 comments

Comments

@wood-push-melon
Copy link

wood-push-melon commented Nov 18, 2024

Bug Description

This happens if a requirer charm application would like to use multiple istio-ingress-k8s charms to expose services.

If a requirer charm integrates with multiple istio-ingress-k8s charms, the istio-ingress-k8s charms will apply changes to a single HTTPRoute. This will lead to conflict errors in the istio-ingress-k8s charms.

From what I understand, it is supposed to create multiple HTTPRoutes referenced by different gateways.

Please see more details below.

cc @shipperizer

To Reproduce

# Deploy public ingress
juju deploy istio-ingress-k8s istio-ingress-public --channel edge

# Deploy admin ingress
juju deploy istio-ingress-k8s istio-ingress-admin --channel edge

# Deploy client charm
juju deploy hydra --channel edge

# Deploy dependency charms
juju deploy postgresql-k8s --channel 14/stable --trust
juju integrate hydra postgresql-k8s

# Integrate client charm with public ingress
juju integrate hydra:public-ingress istio-ingress-public

# Integrate client charm with admin ingress. This will cause errors
juju integrate hydra:admin-ingress istio-ingress-admin

Environment

microk8s: v1.27.16
istio-ingress-k8s channel: edge

Relevant log output

unit-istio-ingress-admin-0: 19:31:05 INFO unit.istio-ingress-admin/0.juju-log ingress:24: Applying resources
unit-istio-ingress-admin-0: 19:31:05 INFO unit.istio-ingress-admin/0.juju-log ingress:24: HTTP Request: PATCH https://10.152.183.1/apis/gateway.networking.k8s.io/v1/namespaces/test/httproutes/hydra-http?fieldManager=istio-ingress-admin "HTTP/1.1 409 Conflict"
unit-istio-ingress-admin-0: 19:31:05 ERROR unit.istio-ingress-admin/0.juju-log ingress:24: Uncaught exception while in charm code:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/lightkube/core/generic_client.py", line 232, in raise_for_status
    resp.raise_for_status()
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/httpx/_models.py", line 763, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Client error '409 Conflict' for url 'https://10.152.183.1/apis/gateway.networking.k8s.io/v1/namespaces/test/httproutes/hydra-http?fieldManager=istio-ingress-admin'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/./src/charm.py", line 684, in <module>
    main(IstioIngressCharm)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/ops/main.py", line 45, in main
    return _main.main(charm_class=charm_class, use_juju_for_storage=use_juju_for_storage)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/ops/_main.py", line 543, in main
    manager.run()
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/ops/_main.py", line 529, in run
    self._emit()
  File "/var/lib/juju/agents/unit-istio-ingress-admin-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-istio-ingress-admin-0/charm/venv/ops/_main.py", line 134, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/ops/framework.py", line 347, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/ops/framework.py", line 857, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/ops/framework.py", line 947, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/lib/charms/traefik_k8s/v2/ingress.py", line 461, in _handle_relation
    self.on.data_provided.emit(  # type: ignore
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/ops/framework.py", line 347, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/ops/framework.py", line 857, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/ops/framework.py", line 947, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/./src/charm.py", line 234, in _on_ingress_data_provided
    self._sync_all_resources()
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/./src/charm.py", line 478, in _sync_all_resources
    self._sync_ingress_resources()
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/./src/charm.py", line 580, in _sync_ingress_resources
    krm.reconcile(current_ingresses)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/lightkube_extensions/batch/_kubernetes_resource_manager.py", line 179, in reconcile
    self.apply(resources=resources, force=force)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/lightkube_extensions/batch/_kubernetes_resource_manager.py", line 102, in apply
    apply_many(
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/lightkube_extensions/batch/_many.py", line 70, in apply_many
    returns[i] = client.apply(
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/lightkube/core/client.py", line 754, in apply
    return self.patch(
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/lightkube/core/client.py", line 489, in patch
    return self._client.request(
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/lightkube/core/generic_client.py", line 308, in request
    return self.handle_response(method, resp, br)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/lightkube/core/generic_client.py", line 248, in handle_response
    self.raise_for_status(resp)
  File "/var/lib/juju/agents/unit-istio-ingress-admin-0/charm/venv/lightkube/core/generic_client.py", line 234, in raise_for_status
    raise transform_exception(e)
lightkube.core.exceptions.ApiError: Apply failed with 3 conflicts: conflicts with "istio-ingress-public":
- .metadata.labels.app.kubernetes.io/instance
- .spec.parentRefs
- .spec.rules
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant