Git Product home page Git Product logo

sdcore-upf-operator's Introduction

SD-Core UPF Operator

CharmHub Badge

Charmed Operator for SD-Core's User Plane Function (UPF). For more information, read here.

Usage

The SD-Core UPF charm should be deployed on a machine with two network interfaces. The access-interface-name and core-interface-name configuration options should be set to the names of the network interfaces that are connected to the access and core networks, respectively. Those interfaces should have IPv4 addresses assigned to them.

Set Multipass to use LXD as the driver:

multipass set local.driver=lxd
sudo snap restart multipass.multipassd

Create two LXD networks:

lxc network create access --type=bridge ipv4.address=192.168.252.1/24
lxc network create core --type=bridge ipv4.address=192.168.250.1/24

Deploy a VM using Multipass with the access and core networks:

multipass launch 22.04 --name upf --network access --network core --memory 8G --cpus 4

Add the Machine to the Juju controller:

sudo cp /var/snap/multipass/common/data/multipassd/ssh-keys/id_rsa .
sudo chown $USER:$USER id_rsa
juju add-machine ssh:ubuntu@<UPF machine IP address> --private-key id_rsa
juju deploy sdcore-upf \
  --channel=1.4/edge \
  --config access-interface-name=enp6s0 \
  --config core-interface-name=enp7s0 \
  --to <machine number>

sdcore-upf-operator's People

Contributors

dariofaccin avatar dependabot[bot] avatar gatici avatar ghislainbourgeois avatar gmerold avatar gruyaume avatar markbeierl avatar patriciareinoso avatar

Watchers

 avatar  avatar  avatar

sdcore-upf-operator's Issues

XTablesError error on install hook

Bug Description

ip4tc XTablesError error on install hook during integration tests. Error can be seen in this PR:

To Reproduce

  • Run integration tests

Environment

  • Juju 3.4/stable (3.4.2)
  • LXD 5.20/stable

Relevant log output

unit-sdcore-upf-0: 2024-04-29 12:44:57 DEBUG juju.worker.uniter.runner starting jujuc server  {unix @/var/lib/juju/agents/unit-sdcore-upf-0/agent.socket <nil>}
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install You seem to be using pydantic v1. Please upgrade to v2, as compatibility may be dropped in a future version of pytest-interface-tester.
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install Traceback (most recent call last):
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install   File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/./src/charm.py", line 26, in <module>
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install     from upf_network import UPFNetwork
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install   File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/src/upf_network.py", line 11, in <module>
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install     import iptc
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install   File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/venv/iptc/__init__.py", line 10, in <module>
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install     from iptc.ip4tc import (is_table_available, Table, Chain, Rule, Match, Target, Policy, IPTCError)
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install   File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/venv/iptc/ip4tc.py", line 13, in <module>
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install     from .xtables import (XT_INV_PROTO, NFPROTO_IPV4, XTablesError, xtables,
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install   File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/venv/iptc/xtables.py", line 825, in <module>
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install     raise XTablesError("can't find directory with extensions; "
unit-sdcore-upf-0: 2024-04-29 12:44:58 WARNING unit.sdcore-upf/0.install iptc.errors.XTablesError: can't find directory with extensions; please set XTABLES_LIBDIR
unit-sdcore-upf-0: 2024-04-29 12:44:58 ERROR juju.worker.uniter.operation hook "install" (via hook dispatching script: dispatch) failed: exit status 1

Additional context

No response

Integration tests logs from juju-crashdump are collected from wrong model

Describe the bug

By default, integration tests create a new model to be run on: juju-crashdump will always collect logs (status, debug-log) from this one. For the UPF charm we force integration tests to deploy to an existing model (upf-integration): logs should be collected from there.

Expected behavior

Logs archived from juju-crashdump are related to the upf-integration model.

Changing UPF interfaces waits until next refresh status event

I accidentally used the unconfigured host interfaces instead of the vlan wrapped interfaces for deploying the upf. Host interfaces are as follows:

10: enp8s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 1c:fd:08:7c:71:2c brd ff:ff:ff:ff:ff:ff
18: enp8s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 1c:fd:08:7c:71:2d brd ff:ff:ff:ff:ff:ff
...
27: vlan.1202@enp8s0f0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 1c:fd:08:7c:71:2c brd ff:ff:ff:ff:ff:ff
    inet 10.202.0.10/16 brd 10.202.255.255 scope global vlan.1202
       valid_lft forever preferred_lft forever
    inet6 fe80::1efd:8ff:fe7c:712c/64 scope link 
       valid_lft forever preferred_lft forever
28: vlan.1203@enp8s0f1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 1c:fd:08:7c:71:2d brd ff:ff:ff:ff:ff:ff
    inet 10.203.0.10/16 brd 10.203.255.255 scope global vlan.1203
       valid_lft forever preferred_lft forever
    inet6 fe80::1efd:8ff:fe7c:712d/64 scope link 
       valid_lft forever preferred_lft forever

The UPF was deployed using access-interface-name=enp8s0f0 and core-interface-name=enp8s0f1. This correctly resulted in messages in the debug-log:

unit-sdcore-upf-0: 14:04:07 WARNING unit.sdcore-upf/0.juju-log No IPv4 address found for interface enp8s0f1
unit-sdcore-upf-0: 14:04:07 WARNING unit.sdcore-upf/0.juju-log IP address for interface enp8s0f1 is empty
unit-sdcore-upf-0: 14:04:07 WARNING unit.sdcore-upf/0.juju-log Core network interface enp8s0f1 is not valid

I ran the following:

juju config sdcore-upf access-interface-name=vlan.1202 core-interface-name=vlan.1203

The charm did not change until about 2 minutes later, when this appeared in the juju debug-log

unit-sdcore-upf-0: 14:09:54 INFO unit.sdcore-upf/0.juju-log Pushed file /var/snap/sdcore-upf/common/upf.json
unit-sdcore-upf-0: 14:09:54 INFO unit.sdcore-upf/0.juju-log Pushed upf.json config file
unit-sdcore-upf-0: 14:09:54 INFO unit.sdcore-upf/0.juju-log Starting configuration of the `bessd` service
unit-sdcore-upf-0: 14:09:56 INFO unit.sdcore-upf/0.juju-log Service `bessd` configured
unit-sdcore-upf-0: 14:09:56 INFO unit.sdcore-upf/0.juju-log UPF service started

Not sure if that is due to refresh status, or something else, but either way, the charm did not act on the change when the event occurred.

Charm removal fails if services have never started

Describe the bug

The remove hook fails if snap services have never started.

To Reproduce

  1. Pack the charm: charmcraft pack
  2. Deploy the charm with an invalid config: juju deploy ./sdcore-upf_ubuntu-22.04-amd64.charm --config access-interface-name=whatever
  3. Wait for deployment and blocked status
  4. Remove the application: juju remove-application sdcore-upf

Expected behavior

Application is removed.

Logs

unit-sdcore-upf-0: 11:06:05 ERROR unit.sdcore-upf/0.juju-log Uncaught exception while in charm code:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/lib/charms/operator_libs_linux/v2/snap.py", line 309, in _snap_daemons
    return subprocess.run(args, universal_newlines=True, check=True, capture_output=True)
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['snap', 'stop', 'sdcore-upf.bessd']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/./src/charm.py", line 385, in <module>
    ops.main(SdcoreUpfCharm)  # type: ignore
  File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/venv/ops/main.py", line 471, in __call__
    return main(charm_class, use_juju_for_storage=use_juju_for_storage)
  File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/venv/ops/main.py", line 456, in main
    _emit_charm_event(charm, dispatcher.event_name)
  File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/venv/ops/main.py", line 144, in _emit_charm_event
    event_to_emit.emit(*args, **kwargs)
  File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/venv/ops/framework.py", line 352, in emit
    framework._emit(event)
  File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/venv/ops/framework.py", line 865, in _emit
    self._reemit(event_path)
  File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/venv/ops/framework.py", line 955, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/./src/charm.py", line 124, in _on_remove
    upf_snap.stop(services=["bessd"])
  File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/lib/charms/operator_libs_linux/v2/snap.py", line 372, in stop
    self._snap_daemons(args, services)
  File "/var/lib/juju/agents/unit-sdcore-upf-0/charm/lib/charms/operator_libs_linux/v2/snap.py", line 311, in _snap_daemons
    raise SnapError("Could not {} for snap [{}]: {}".format(args, self._name, e.stderr))
charms.operator_libs_linux.v2.snap.SnapError: Could not ['snap', 'stop', 'sdcore-upf.bessd'] for snap [sdcore-upf]: error: snap "sdcore-upf" has no service "bessd"

unit-sdcore-upf-0: 11:06:06 ERROR juju.worker.uniter.operation hook "remove" (via hook dispatching script: dispatch) failed: exit status 1

Environment

  • Charm / library version (if relevant): main
  • Juju version (output from juju --version): 3.4.0-genericlinux-amd64
  • Cloud Environment: LXD
  • Kubernetes version (output from kubectl version --short): N/A
  • Terraform version (output from terraform version): N/A

Bessctl configuration remains hanging

Bug Description

Sometimes the bess configuration remains hanging.
Running manually the command sudo sdcore-upf.bessctl run /snap/sdcore-upf/current/opt/bess/bessctl/conf/up4 returns the error provided in the log section. The command does not exit, causing the charm to be hanging forever.

To Reproduce

  1. Deploy sdcore-upf

Environment

Microk8s 1.29
Juju 3.4

Relevant log output

Setting up port enp6s0 on worker ids [0]
Failed to create AF_PACKET socket for enp6s0. Exiting...
*** Error: Unhandled exception in the configuration script (most recent call last)
  File "/snap/sdcore-upf/current/opt/bess/bessctl/conf/up4.bess", line 142, in <module>
    p.init_port(idx, parser.mode)
  File "/snap/sdcore-upf/42/opt/bess/bessctl/conf/ports.py", line 204, in init_port
    sys.exit()
SystemExit
  Command failed: run /snap/sdcore-upf/current/opt/bess/bessctl/conf/up4

Additional context

No response

Install hook fails for timeout of 2 seconds

Describe the bug

The install hook may fail for timeout of 2 seconds.

To Reproduce

  1. Pack the charm: charmcraft pack
  2. Deploy the charm with a valid config on a slow env: juju deploy ./sdcore-upf_ubuntu-22.04-amd64.charm --config access-interface-name=enp6s0 --config access-interface-name=enp7s0 --to 0
  3. Wait for deployment and active status

Expected behavior

Application is active.

Environment

  • Charm / library version (if relevant): main
  • Juju version (output from juju --version): 3.4.0-genericlinux-amd64
  • Cloud Environment: LXD
  • Kubernetes version (output from kubectl version --short): N/A
  • Terraform version (output from terraform version): N/A

Removing charm leaves processes running

I deployed UPF machine charm on a host, but specified the wrong interfaces. Changed the interfaces, but bess still did not get configured. Removed the charm, yet the following processes are still running on the host

root      103188  0.0  0.0   3984  2944 ?        Ss   14:20   0:00 /bin/bash /snap/sdcore-upf/7/bin/bessd-start
root      103215  0.5  1.9 1742320 1251352 ?     SLl  14:20   0:00 /snap/sdcore-upf/7/bin/bessd -f -grpc-url=0.0.0.0:10514 -m 0
root      103265  1.1  0.1 2073812 68632 ?       Sl   14:20   0:02 python /snap/sdcore-upf/7/opt/bess/bessctl/conf/route_control.py -i vlan.1202 vlan.1203

Re-installing reuses old snap

I installed UPF machine charm when the snap was at revision 7. I see the following in snap info:

tracking:     latest/edge
refresh-date: today at 14:20 UTC
hold:         forever
channels:
  latest/stable:    --
  latest/candidate: --
  latest/beta:      --
  latest/edge:      1.3 2024-03-12 (8)  83MB devmode
installed:          1.3            (7) 105MB devmode,held

I removed the charm, and UPF snap remained. Re-deploying the charm re-uses the installed version 7.

Instructions on how to upgrade the charm/snap should be provided.

Charm cannot be removed if subnet nexthop is invalid.

Bug Description

If an invalid route is supplied, the charm goes into error state and cannot be removed.

The following logs show that during removal it is still trying to configure a route

ops.pebble.ExecError: non-zero exit code 2 executing ['ip', 'route', 'replace', '10.11.6.0/24', 'via', '10.204.0.110'], stdout='', stderr='Error: Nexthop has invalid gateway.\n'

To Reproduce

Deploy the charm (terraform or juju deploy) and specify an invalid access gateway ip, for example:

upf_config = {
  cni-type          = "macvlan"
  access-gateway-ip = "10.0.0.1"
  access-interface  = "access"
  access-ip         = "10.11.4.119/24"
...

Environment

Microk8s 1.29 classic
Juju 3.4

Relevant log output

unit-upf-0: 12:02:25 ERROR unit.upf/0.juju-log Uncaught exception while in charm code:
Traceback (most recent call last):
  File "/var/lib/juju/agents/unit-upf-0/charm/./src/charm.py", line 1156, in <module>
    main(UPFOperatorCharm)
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/main.py", line 544, in main
    manager.run()
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/main.py", line 520, in run
    self._emit()
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/main.py", line 506, in _emit
    self.framework.reemit()
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/framework.py", line 859, in reemit
    self._reemit()
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/framework.py", line 939, in _reemit
    custom_handler(event)
  File "/var/lib/juju/agents/unit-upf-0/charm/./src/charm.py", line 580, in _on_config_changed
    self._on_bessd_pebble_ready(event)
  File "/var/lib/juju/agents/unit-upf-0/charm/./src/charm.py", line 600, in _on_bessd_pebble_ready
    self._configure_bessd_workload()
  File "/var/lib/juju/agents/unit-upf-0/charm/./src/charm.py", line 640, in _configure_bessd_workload
    self._create_ran_route()
  File "/var/lib/juju/agents/unit-upf-0/charm/./src/charm.py", line 755, in _create_ran_route
    self._exec_command_in_bessd_workload(
  File "/var/lib/juju/agents/unit-upf-0/charm/./src/charm.py", line 796, in _exec_command_in_bessd_workload
    return process.wait_output()
  File "/var/lib/juju/agents/unit-upf-0/charm/venv/ops/pebble.py", line 1571, in wait_output
    raise ExecError[AnyStr](self._command, exit_code, out_value, err_value)
ops.pebble.ExecError: non-zero exit code 2 executing ['ip', 'route', 'replace', '10.11.6.0/24', 'via', '10.204.0.110'], stdout='', stderr='Error: Nexthop has invalid gateway.\n'
unit-upf-0: 12:02:25 ERROR juju.worker.uniter.operation hook "shared-app-storage-detaching" (via hook dispatching script: dispatch) failed: exit status 1

Additional context

No response

Charm does not recover from invalid iface on host

I have an access and core interface on my machine. If I put the interfaces into a down state, the up4 script fails in an unusual way. The following log is displayed:

Failed to create AF_PACKET socket for access. Exiting...
*** Error: Unhandled exception in the configuration script (most recent call last)
  File "/snap/sdcore-upf/current/opt/bess/bessctl/conf/up4.bess", line 142, in <module>
    p.init_port(idx, parser.mode)
  File "/snap/sdcore-upf/16/opt/bess/bessctl/conf/ports.py", line 204, in init_port
    sys.exit()
SystemExit
  Command failed: run /snap/sdcore-upf/current/opt/bess/bessctl/conf/up4

... and then hangs.

So the charm is left waiting and no further action can be taken by Juju until it is cancelled.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.