• Uncategorized

About python : tcconfig-throws-ValueError-when-settingdeleting-traffic-control-on-docker-container

Question Detail

I’m using tcconfig to set traffic control rules on docker containers.

I’m running from a python script with venv (not from a bash shell) a tcset/tcdel command, for example:

tcdel --docker <container_name> --all

The command is run with check_call of subprocess module.

When I run the command I get an exception thrown:

Traceback (most recent call last):
  File "<base_dir>/venv/bin/tcdel", line 8, in <module>
  File "<base_dir>/venv/lib/python3.9/site-packages/tcconfig/tcdel.py", line 148, in main
    return TcDelMain(options).run(is_delete_all)
  File "<base_dir>/venv/lib/python3.9/site-packages/tcconfig/tcdel.py", line 61, in run
    for tc_target in self._fetch_tc_targets():
  File "<base_dir>/venv/lib/python3.9/site-packages/tcconfig/_main.py", line 43, in _fetch_tc_targets
  File "<base_dir>/venv/lib/python3.9/site-packages/tcconfig/_docker.py", line 127, in create_veth_table
    return_code = self.__create_ifindex_table(container_info.name)
  File "<base_dir>/venv/lib/python3.9/site-packages/tcconfig/_docker.py", line 227, in __create_ifindex_table
    peer_ifindex=int(peer_ifindex_prefix_regexp.sub("", peer_ifindex)),
ValueError: invalid literal for int() with base 10: 'vethd94cf85'

It seems there’s an error in tcconfig‘s resolving of docker interface name
How to solve this?

Question Answer

One workaround is to run the tcconfig commands with the flag --tc-command.

This gives you a list of the tc commands to run.

Another issue when running this for dockers with multiple interfaces is that you might get the same bulk of commands more than once, so you might have to filter duplicates.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.