1
0
Fork 0

adjusting level of debug

This commit is contained in:
Joao Gilberto Magalhaes 2022-08-25 12:30:17 -05:00
parent af896c1d8b
commit 7d441d6386
5 changed files with 17 additions and 18 deletions

View file

@ -6,6 +6,6 @@ updates:
schedule: schedule:
interval: "daily" interval: "daily"
- package-ecosystem: "pip" - package-ecosystem: "pip"
directory: "/" directory: "/src"
schedule: schedule:
interval: "daily" interval: "daily"

View file

@ -5,9 +5,9 @@ set -e
# Start k8s-ci before run this command # Start k8s-ci before run this command
# docker run --privileged -v /tmp/z:/var/lib/containers -it --rm -v $PWD:/work -w /work byjg/k8s-ci # docker run --privileged -v /tmp/z:/var/lib/containers -it --rm -v $PWD:/work -w /work byjg/k8s-ci
if [ -z "$DOCKER_USERNAME" ] || [ -z "$DOCKER_PASSWORD" ] || [ -z "$DOCKER_REGISTRY" ] if [ -z "$DOCKER_USERNAME" ] || [ -z "$DOCKER_PASSWORD" ] || [ -z "$DOCKER_REGISTRY" ] || [ -z "$VERSIONS" ]
then then
echo You need to setup \$DOCKER_USERNAME, \$DOCKER_PASSWORD and \$DOCKER_REGISTRY before run this command. echo You need to setup \$DOCKER_USERNAME, \$DOCKER_PASSWORD, \$DOCKER_REGISTRY and \$VERSIONS before run this command.
exit 1 exit 1
fi fi
@ -15,15 +15,14 @@ buildah login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD $DOCKER_RE
podman run --rm --events-backend=file --cgroup-manager=cgroupfs --privileged docker://multiarch/qemu-user-static --reset -p yes podman run --rm --events-backend=file --cgroup-manager=cgroupfs --privileged docker://multiarch/qemu-user-static --reset -p yes
VERSIONS="latest $TRAVIS_TAG"
for VERSION in $VERSIONS for VERSION in $VERSIONS
do do
DOCKERFILE=Dockerfile DOCKERFILE=Dockerfile
buildah manifest create byjg/easy-haproxy:$VERSION buildah manifest create byjg/easy-haproxy:$VERSION
buildah bud --arch arm64 --os linux --iidfile /tmp/iid-arm64 -f $DOCKERFILE -t byjg/easy-haproxy:$VERSION-arm64 . buildah bud --arch arm64 --os linux --iidfile /tmp/iid-arm64 -f $DOCKERFILE --build-arg=RELEASE_VERSION_ARG="$VERSION-manual" -t byjg/easy-haproxy:$VERSION-arm64 .
buildah bud --arch amd64 --os linux --iidfile /tmp/iid-amd64 -f $DOCKERFILE -t byjg/easy-haproxy:$VERSION-amd64 . buildah bud --arch amd64 --os linux --iidfile /tmp/iid-amd64 -f $DOCKERFILE --build-arg=RELEASE_VERSION_ARG="$VERSION-manual" -t byjg/easy-haproxy:$VERSION-amd64 .
buildah manifest add byjg/easy-haproxy:$VERSION --arch arm64 --os linux --variant v8 $(cat /tmp/iid-arm64) buildah manifest add byjg/easy-haproxy:$VERSION --arch arm64 --os linux --variant v8 $(cat /tmp/iid-arm64)
buildah manifest add byjg/easy-haproxy:$VERSION --arch amd64 --os linux --os=linux $(cat /tmp/iid-amd64) buildah manifest add byjg/easy-haproxy:$VERSION --arch amd64 --os linux --os=linux $(cat /tmp/iid-amd64)

View file

@ -103,7 +103,7 @@ class DaemonizeHAProxy:
Functions.log(source, "info", line) Functions.log(source, "info", line)
returncode = self.process.wait() returncode = self.process.wait()
Functions.log(source, "info", "Return code %s" % (returncode)) Functions.log(source, "debug", "Return code %s" % (returncode))
except Exception as e: except Exception as e:
Functions.log(source, 'error', "%s" % (e)) Functions.log(source, 'error', "%s" % (e))
@ -137,15 +137,15 @@ class Certbot:
filename = "%s/%s.pem" % (self.certs, host) filename = "%s/%s.pem" % (self.certs, host)
host_arg = '-d %s' % (host) host_arg = '-d %s' % (host)
if not os.path.exists(filename): if not os.path.exists(filename):
Functions.log("CERTBOT", "info", "Request new certificate for %s" % (host)) Functions.log("CERTBOT", "debug", "Request new certificate for %s" % (host))
request_certs.append(host_arg) request_certs.append(host_arg)
else: else:
creation_time = os.path.getctime(filename) creation_time = os.path.getctime(filename)
if (current_time - creation_time) // (24 * 3600) > 90: if (current_time - creation_time) // (24 * 3600) > 90:
Functions.log("CERTBOT", "info", "Request expired certificate for %s" % (host)) Functions.log("CERTBOT", "debug", "Request expired certificate for %s" % (host))
request_certs.append(host_arg) request_certs.append(host_arg)
if (current_time - creation_time) // (24 * 3600) >= 45: if (current_time - creation_time) // (24 * 3600) >= 45:
Functions.log("CERTBOT", "info", "Renew certificate for %s" % (host)) Functions.log("CERTBOT", "debug", "Renew certificate for %s" % (host))
renew_certs.append(host_arg) renew_certs.append(host_arg)
certbot_certonly = ('/usr/bin/certbot certonly ' certbot_certonly = ('/usr/bin/certbot certonly '

View file

@ -20,7 +20,7 @@ def start():
processor_obj.save_config(haproxy_config) processor_obj.save_config(haproxy_config)
processor_obj.save_certs(certs_haproxy) processor_obj.save_certs(certs_haproxy)
letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts() letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts()
Functions.log('EASYHAPROXY', 'info', 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config Functions.log('EASYHAPROXY', 'debug', 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config
old_haproxy = None old_haproxy = None
haproxy = DaemonizeHAProxy() haproxy = DaemonizeHAProxy()
@ -37,11 +37,11 @@ def start():
old_parsed = processor_obj.get_parsed_object() old_parsed = processor_obj.get_parsed_object()
processor_obj.refresh() processor_obj.refresh()
if DeepDiff(old_parsed, processor_obj.get_parsed_object()) != {} or not haproxy.is_alive(): if DeepDiff(old_parsed, processor_obj.get_parsed_object()) != {} or not haproxy.is_alive():
Functions.log('EASYHAPROXY', 'info', 'New configuration found. Reloading...') Functions.log('EASYHAPROXY', 'debug', 'New configuration found. Reloading...')
processor_obj.save_config(haproxy_config) processor_obj.save_config(haproxy_config)
processor_obj.save_certs(certs_haproxy) processor_obj.save_certs(certs_haproxy)
letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts() letsencrypt_certs_found = processor_obj.get_letsencrypt_hosts()
Functions.log('EASYHAPROXY', 'info', 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config Functions.log('EASYHAPROXY', 'debug', 'Found hosts: %s' % ", ".join(processor_obj.get_hosts())) # Needs to after save_config
old_haproxy = haproxy old_haproxy = haproxy
haproxy = DaemonizeHAProxy() haproxy = DaemonizeHAProxy()
haproxy.haproxy("reload") haproxy.haproxy("reload")
@ -49,8 +49,8 @@ def start():
certbot.check_certificates(letsencrypt_certs_found) certbot.check_certificates(letsencrypt_certs_found)
except Exception as e: except Exception as e:
Functions.log('EASYHAPROXY', 'error', "Err: %s" % (e)) Functions.log('EASYHAPROXY', 'fatal', "Err: %s" % (e))
Functions.log('EASYHAPROXY', 'info', 'Heartbeat') Functions.log('EASYHAPROXY', 'debug', 'Heartbeat')
@ -65,10 +65,10 @@ def main():
Functions.log('INIT', 'info', " |__/ |_| |__/ ") Functions.log('INIT', 'info', " |__/ |_| |__/ ")
Functions.log('INIT', 'info', "Release: %s" % (os.getenv("RELEASE_VERSION"))) Functions.log('INIT', 'info', "Release: %s" % (os.getenv("RELEASE_VERSION")))
Functions.log('INIT', 'info', 'Environment:') Functions.log('INIT', 'debug', 'Environment:')
for name, value in os.environ.items(): for name, value in os.environ.items():
if "HAPROXY" in name: if "HAPROXY" in name:
Functions.log('INIT', 'info', "- {0}: {1}".format(name, value)) Functions.log('INIT', 'debug', "- {0}: {1}".format(name, value))
start() start()

View file

@ -48,7 +48,7 @@ class ProcessorInterface:
elif mode == "kubernetes": elif mode == "kubernetes":
return Kubernetes() return Kubernetes()
else: else:
Functions.log("FACTORY", "error", "Expected mode to be 'static', 'docker', 'swarm' or 'kubernetes'. I got '%s'" % (mode)) Functions.log("FACTORY", "fatal", "Expected mode to be 'static', 'docker', 'swarm' or 'kubernetes'. I got '%s'" % (mode))
return None return None
def refresh(self): def refresh(self):