Make mutex file path configurable
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 42s
Webapp Test / Run webapp test suite (pull_request) Successful in 5m22s
Smoke Test / Run basic test suite (pull_request) Successful in 5m4s
Deploy Test / Run deploy test suite (pull_request) Successful in 6m11s
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Successful in 7m35s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 8m40s
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 42s
Webapp Test / Run webapp test suite (pull_request) Successful in 5m22s
Smoke Test / Run basic test suite (pull_request) Successful in 5m4s
Deploy Test / Run deploy test suite (pull_request) Successful in 6m11s
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Successful in 7m35s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 8m40s
This commit is contained in:
parent
8ea84e6b70
commit
5ffe74bf49
@ -360,6 +360,9 @@ def dump_known_requests(filename, requests, status="SEEN"):
|
|||||||
@click.option(
|
@click.option(
|
||||||
"--private-key-file", help="The private key for decrypting config.", required=True
|
"--private-key-file", help="The private key for decrypting config.", required=True
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
"--registry-lock-file", help="File path to use for registry mutex lock", default=None
|
||||||
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--private-key-passphrase",
|
"--private-key-passphrase",
|
||||||
help="The passphrase for the private key.",
|
help="The passphrase for the private key.",
|
||||||
@ -393,6 +396,7 @@ def command( # noqa: C901
|
|||||||
private_key_passphrase,
|
private_key_passphrase,
|
||||||
all_requests,
|
all_requests,
|
||||||
auction_requests,
|
auction_requests,
|
||||||
|
registry_lock_file,
|
||||||
):
|
):
|
||||||
if request_id and discover:
|
if request_id and discover:
|
||||||
print("Cannot specify both --request-id and --discover", file=sys.stderr)
|
print("Cannot specify both --request-id and --discover", file=sys.stderr)
|
||||||
@ -444,7 +448,7 @@ def command( # noqa: C901
|
|||||||
include_tags = [tag.strip() for tag in include_tags.split(",") if tag]
|
include_tags = [tag.strip() for tag in include_tags.split(",") if tag]
|
||||||
exclude_tags = [tag.strip() for tag in exclude_tags.split(",") if tag]
|
exclude_tags = [tag.strip() for tag in exclude_tags.split(",") if tag]
|
||||||
|
|
||||||
laconic = LaconicRegistryClient(laconic_config, log_file=sys.stderr)
|
laconic = LaconicRegistryClient(laconic_config, log_file=sys.stderr, mutex_lock_file=registry_lock_file)
|
||||||
webapp_deployer_record = laconic.get_record(lrn, require=True)
|
webapp_deployer_record = laconic.get_record(lrn, require=True)
|
||||||
payment_address = webapp_deployer_record.attributes.paymentAddress
|
payment_address = webapp_deployer_record.attributes.paymentAddress
|
||||||
main_logger.log(f"Payment address: {payment_address}")
|
main_logger.log(f"Payment address: {payment_address}")
|
||||||
@ -649,7 +653,7 @@ def command( # noqa: C901
|
|||||||
)
|
)
|
||||||
run_log_file = open(run_log_file_path, "wt")
|
run_log_file = open(run_log_file_path, "wt")
|
||||||
run_reg_client = LaconicRegistryClient(
|
run_reg_client = LaconicRegistryClient(
|
||||||
laconic_config, log_file=run_log_file
|
laconic_config, log_file=run_log_file, mutex_lock_file=registry_lock_file
|
||||||
)
|
)
|
||||||
|
|
||||||
build_logger = TimedLogger(run_id, run_log_file)
|
build_logger = TimedLogger(run_id, run_log_file)
|
||||||
|
@ -120,6 +120,9 @@ def dump_known_auction_requests(filename, requests, status="SEEN"):
|
|||||||
help="Bid to place on application deployment auctions (in alnt)",
|
help="Bid to place on application deployment auctions (in alnt)",
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
"--registry-lock-file", help="File path to use for registry mutex lock", default=None
|
||||||
|
)
|
||||||
@click.option(
|
@click.option(
|
||||||
"--dry-run", help="Don't do anything, just report what would be done.", is_flag=True
|
"--dry-run", help="Don't do anything, just report what would be done.", is_flag=True
|
||||||
)
|
)
|
||||||
@ -129,6 +132,7 @@ def command(
|
|||||||
laconic_config,
|
laconic_config,
|
||||||
state_file,
|
state_file,
|
||||||
bid_amount,
|
bid_amount,
|
||||||
|
registry_lock_file,
|
||||||
dry_run,
|
dry_run,
|
||||||
):
|
):
|
||||||
if int(bid_amount) < 0:
|
if int(bid_amount) < 0:
|
||||||
@ -138,7 +142,7 @@ def command(
|
|||||||
logger = TimedLogger(file=sys.stderr)
|
logger = TimedLogger(file=sys.stderr)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
laconic = LaconicRegistryClient(laconic_config, log_file=sys.stderr)
|
laconic = LaconicRegistryClient(laconic_config, log_file=sys.stderr, mutex_lock_file=registry_lock_file)
|
||||||
auctions_requests = laconic.app_deployment_auctions()
|
auctions_requests = laconic.app_deployment_auctions()
|
||||||
|
|
||||||
previous_requests = {}
|
previous_requests = {}
|
||||||
|
@ -1,21 +1,25 @@
|
|||||||
import fcntl
|
import fcntl
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
# Define the file path for the lock
|
# Define default file path for the lock
|
||||||
LOCK_FILE_PATH = "/tmp/registry_mutex_lock_file"
|
DEFAULT_LOCK_FILE_PATH = "/tmp/registry_mutex_lock_file"
|
||||||
|
|
||||||
|
|
||||||
def registry_mutex():
|
def registry_mutex():
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(self, *args, **kwargs):
|
||||||
with open(LOCK_FILE_PATH, 'w') as lock_file:
|
lock_file_path = DEFAULT_LOCK_FILE_PATH
|
||||||
|
if self.mutex_lock_file is not None:
|
||||||
|
lock_file_path = self.mutex_lock_file
|
||||||
|
|
||||||
|
with open(lock_file_path, 'w') as lock_file:
|
||||||
try:
|
try:
|
||||||
# Try to acquire the lock
|
# Try to acquire the lock
|
||||||
fcntl.flock(lock_file, fcntl.LOCK_EX)
|
fcntl.flock(lock_file, fcntl.LOCK_EX)
|
||||||
|
|
||||||
# Call the actual function
|
# Call the actual function
|
||||||
result = func(*args, **kwargs)
|
result = func(self, *args, **kwargs)
|
||||||
finally:
|
finally:
|
||||||
# Always release the lock
|
# Always release the lock
|
||||||
fcntl.flock(lock_file, fcntl.LOCK_UN)
|
fcntl.flock(lock_file, fcntl.LOCK_UN)
|
||||||
|
@ -178,6 +178,9 @@ def dump_known_requests(filename, requests):
|
|||||||
"my payment address are examined).",
|
"my payment address are examined).",
|
||||||
is_flag=True,
|
is_flag=True,
|
||||||
)
|
)
|
||||||
|
@click.option(
|
||||||
|
"--registry-lock-file", help="File path to use for registry mutex lock", default=None
|
||||||
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def command( # noqa: C901
|
def command( # noqa: C901
|
||||||
ctx,
|
ctx,
|
||||||
@ -195,6 +198,7 @@ def command( # noqa: C901
|
|||||||
min_required_payment,
|
min_required_payment,
|
||||||
lrn,
|
lrn,
|
||||||
all_requests,
|
all_requests,
|
||||||
|
registry_lock_file,
|
||||||
):
|
):
|
||||||
if request_id and discover:
|
if request_id and discover:
|
||||||
print("Cannot specify both --request-id and --discover", file=sys.stderr)
|
print("Cannot specify both --request-id and --discover", file=sys.stderr)
|
||||||
@ -212,7 +216,7 @@ def command( # noqa: C901
|
|||||||
include_tags = [tag.strip() for tag in include_tags.split(",") if tag]
|
include_tags = [tag.strip() for tag in include_tags.split(",") if tag]
|
||||||
exclude_tags = [tag.strip() for tag in exclude_tags.split(",") if tag]
|
exclude_tags = [tag.strip() for tag in exclude_tags.split(",") if tag]
|
||||||
|
|
||||||
laconic = LaconicRegistryClient(laconic_config, log_file=sys.stderr)
|
laconic = LaconicRegistryClient(laconic_config, log_file=sys.stderr, mutex_lock_file=registry_lock_file)
|
||||||
deployer_record = laconic.get_record(lrn, require=True)
|
deployer_record = laconic.get_record(lrn, require=True)
|
||||||
payment_address = deployer_record.attributes.paymentAddress
|
payment_address = deployer_record.attributes.paymentAddress
|
||||||
main_logger.log(f"Payment address: {payment_address}")
|
main_logger.log(f"Payment address: {payment_address}")
|
||||||
|
Loading…
Reference in New Issue
Block a user