stx-chartmuseum: add new bbclass
For the packages that provide helm charts, chartmuseum is used as the local helm chart repository for building the chart, and the port 8879 is used. To avoid race condition, add this bbclass to help adding a lock for do_compile of each package that uses chartmuseum to build helm chart, and add a prefunc to check if the port is already in use by other program on the host. Story: 2008952 Task: 42576 Signed-off-by: Jackie Huang <jackie.huang@windriver.com> Change-Id: I4be391997ef01c191eb5a906786d0ec0ff8b0097
This commit is contained in:
parent
ad6d65fe90
commit
9c3c3aa115
28
meta-stx-distro/classes/stx-chartmuseum.bbclass
Normal file
28
meta-stx-distro/classes/stx-chartmuseum.bbclass
Normal file
@ -0,0 +1,28 @@
|
||||
# This class is intended to avoid race condition by adding a lock
|
||||
# for do_compile of each package that uses chartmuseum to build
|
||||
# helm chart, and add a prefunc to check if the port is already
|
||||
# in use by other program on the host.
|
||||
#
|
||||
|
||||
DEPENDS += "chartmuseum-native"
|
||||
|
||||
CHARTMUSEUM_PORT = "8879"
|
||||
|
||||
python check_port_in_use() {
|
||||
import socket
|
||||
|
||||
port_num = int(d.getVar("CHARTMUSEUM_PORT"))
|
||||
|
||||
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||
res = s.connect_ex(('localhost', port_num))
|
||||
if res == 0:
|
||||
bb.fatal("The port %s is already in use, please ensure the port is not used by other programs" % (port_num))
|
||||
|
||||
}
|
||||
|
||||
# Check if the port for chartmuseum is in use
|
||||
do_compile[prefuncs] += "check_port_in_use"
|
||||
|
||||
# Ensure we don't race against other chartmuseum instances
|
||||
check_port_in_use[lockfiles] = "${TMPDIR}/stx-chartmuseum.lock"
|
||||
do_compile[lockfiles] = "${TMPDIR}/stx-chartmuseum.lock"
|
Loading…
Reference in New Issue
Block a user