Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the probe healthcheck script ipv6 compatible #304

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions templates/manila/bin/healthcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

from http import server
import signal
import socket
import subprocess
import sys
import time
Expand All @@ -45,13 +46,15 @@
from manila.common import config as manila_config


HOSTNAME = ''
SERVER_PORT = 8080
CONF = cfg.CONF
BINARIES = ('share', 'scheduler')
STATE_UP = ":-)"
STATUS_ENABLED = "enabled"

class HTTPServerV6(server.HTTPServer):
address_family = socket.AF_INET6


class ServiceNotFoundException(Exception):

Expand Down Expand Up @@ -215,7 +218,12 @@ def stopper(signal_number=None, frame=None):

HeartbeatServer.initialize_class(binary, cfg_dir)

webServer = server.HTTPServer((HOSTNAME, SERVER_PORT), HeartbeatServer)
hostname = socket.gethostname()
ipv6_address = socket.getaddrinfo(hostname, None, socket.AF_INET6)
if ipv6_address:
webServer = HTTPServerV6(("::", SERVER_PORT), HeartbeatServer)
else:
webServer = server.HTTPServer(("0.0.0.0", SERVER_PORT), HeartbeatServer)
stop = get_stopper(webServer)

# Need to run the server on a different thread because its shutdown method
Expand All @@ -224,7 +232,7 @@ def stopper(signal_number=None, frame=None):
thread = threading.Thread(target=webServer.serve_forever)
thread.daemon = True
thread.start()
print(f"Manila Healthcheck Server started http://{HOSTNAME}:{SERVER_PORT}")
print(f"Manila Healthcheck Server started http://{hostname}:{SERVER_PORT}")
signal.signal(signal.SIGTERM, stop)

try:
Expand Down
Loading