Fix startup issues for collectd.

- Use encodeutils from olso library to handle string encodings.
 - Expand the generator into a list.
 - Use python3 iterator __next__().

Note: there needs to be a separate task to remove the Encoding parameter from python_plugins.conf which can be cherry-picked only for python3 deployments.

Story: 2008454
Task: 42647
Depends-On: Iaa7bd0cadd3b1d097b276dcc37ebceaeb208a6a5

Signed-off-by: Andrei Grosu <andrei.grosu@windriver.com>
Change-Id: I58cd4829806e98b1e15471ce97a7c7ba6a2fe135
This commit is contained in:
Andrei Grosu 2021-06-18 11:30:42 +03:00
parent fdc0d099fb
commit f2e5263206
5 changed files with 6 additions and 4 deletions

View File

@ -46,6 +46,7 @@ Requires: fm-api
Requires: python3-httplib2
Requires: python3-influxdb
Requires: python3-oslo-concurrency
Requires: python3-oslo-utils
Requires: tsconfig
Requires: /bin/systemctl

View File

@ -194,7 +194,7 @@ def get_cpuacct():
# Walk the first level cgroups and get cpuacct usage
# (e.g., docker, k8s-infra, user.slice, system.slice, machine.slice)
dir_list = os.walk(CPUACCT).next()[1]
dir_list = next(os.walk(CPUACCT))[1]
for name in dir_list:
cg_path = '/'.join([CPUACCT, name])
acct = get_cgroup_cpuacct(cg_path)

View File

@ -88,6 +88,7 @@ import re
import socket
import collectd
from threading import RLock as Lock
from oslo_utils import encodeutils
from fm_api import constants as fm_constants
from fm_api import fm_api
import tsconfig.tsconfig as tsc
@ -387,7 +388,7 @@ class DegradeObject:
collectd.info("%s: %s" % (PLUGIN_DEGRADE, message))
mtce_socket.settimeout(1.0)
mtce_socket.sendto(message, (self.addr, self.port))
mtce_socket.sendto(encodeutils.safe_encode(message), (self.addr, self.port))
mtce_socket.close()
else:
collectd.error("%s %s failed to open socket (%s)" %

View File

@ -261,7 +261,7 @@ def get_platform_memory():
# Walk the first level cgroups and get memory usage
# (e.g., docker, k8s-infra, user.slice, system.slice, machine.slice)
dir_list = os.walk(MEMCONT).next()[1]
dir_list = next(os.walk(MEMCONT))[1]
for name in dir_list:
cg_path = '/'.join([MEMCONT, name])
m = get_cgroup_memory(cg_path)

View File

@ -785,7 +785,7 @@ def range_to_list(csv_range=None):
if not csv_range:
return []
ranges = [(lambda L: range(L[0], L[-1] + 1))(map(int, r.split('-')))
ranges = [(lambda L: range(L[0], L[-1] + 1))(list(map(int, r.split('-'))))
for r in csv_range.split(',')]
return [y for x in ranges for y in x]