Use a mutex for registry CLI txs in webapp deployment commands
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 32s
Deploy Test / Run deploy test suite (pull_request) Successful in 4m51s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 7m30s
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Successful in 5m24s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m48s
Smoke Test / Run basic test suite (pull_request) Successful in 3m51s
All checks were successful
Lint Checks / Run linter (pull_request) Successful in 32s
Deploy Test / Run deploy test suite (pull_request) Successful in 4m51s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 7m30s
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Successful in 5m24s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m48s
Smoke Test / Run basic test suite (pull_request) Successful in 3m51s
This commit is contained in:
parent
0c47da42fe
commit
8ea84e6b70
@ -102,7 +102,7 @@ def command(
|
||||
"max_price": max_price,
|
||||
"num_providers": num_providers,
|
||||
}
|
||||
auction_id = laconic.create_auction(provider_auction_params)
|
||||
auction_id = laconic.create_deployment_auction(provider_auction_params)
|
||||
print("Deployment auction created:", auction_id)
|
||||
|
||||
if not auction_id:
|
||||
|
27
stack_orchestrator/deploy/webapp/registry_mutex.py
Normal file
27
stack_orchestrator/deploy/webapp/registry_mutex.py
Normal file
@ -0,0 +1,27 @@
|
||||
import fcntl
|
||||
from functools import wraps
|
||||
|
||||
# Define the file path for the lock
|
||||
LOCK_FILE_PATH = "/tmp/registry_mutex_lock_file"
|
||||
|
||||
|
||||
def registry_mutex():
|
||||
def decorator(func):
|
||||
@wraps(func)
|
||||
def wrapper(*args, **kwargs):
|
||||
with open(LOCK_FILE_PATH, 'w') as lock_file:
|
||||
try:
|
||||
# Try to acquire the lock
|
||||
fcntl.flock(lock_file, fcntl.LOCK_EX)
|
||||
|
||||
# Call the actual function
|
||||
result = func(*args, **kwargs)
|
||||
finally:
|
||||
# Always release the lock
|
||||
fcntl.flock(lock_file, fcntl.LOCK_UN)
|
||||
|
||||
return result
|
||||
|
||||
return wrapper
|
||||
|
||||
return decorator
|
@ -26,6 +26,8 @@ import yaml
|
||||
|
||||
from enum import Enum
|
||||
|
||||
from stack_orchestrator.deploy.webapp.registry_mutex import registry_mutex
|
||||
|
||||
|
||||
class AuctionStatus(str, Enum):
|
||||
COMMIT = "commit"
|
||||
@ -391,6 +393,7 @@ class LaconicRegistryClient:
|
||||
criteria["type"] = "ApplicationDeploymentAuction"
|
||||
return self.list_records(criteria, all)
|
||||
|
||||
@registry_mutex()
|
||||
def publish(self, record, names=None):
|
||||
if names is None:
|
||||
names = []
|
||||
@ -421,6 +424,7 @@ class LaconicRegistryClient:
|
||||
finally:
|
||||
logged_cmd(self.log_file, "rm", "-rf", tmpdir)
|
||||
|
||||
@registry_mutex()
|
||||
def set_name(self, name, record_id):
|
||||
logged_cmd(
|
||||
self.log_file,
|
||||
@ -434,6 +438,7 @@ class LaconicRegistryClient:
|
||||
record_id,
|
||||
)
|
||||
|
||||
@registry_mutex()
|
||||
def delete_name(self, name):
|
||||
logged_cmd(
|
||||
self.log_file,
|
||||
@ -446,6 +451,7 @@ class LaconicRegistryClient:
|
||||
name,
|
||||
)
|
||||
|
||||
@registry_mutex()
|
||||
def send_tokens(self, address, amount, type="alnt"):
|
||||
args = [
|
||||
"laconic",
|
||||
@ -464,8 +470,8 @@ class LaconicRegistryClient:
|
||||
|
||||
return AttrDict(json.loads(logged_cmd(self.log_file, *args)))
|
||||
|
||||
def create_auction(self, auction):
|
||||
if auction["kind"] == AUCTION_KIND_PROVIDER:
|
||||
@registry_mutex()
|
||||
def create_deployment_auction(self, auction):
|
||||
args = [
|
||||
"laconic",
|
||||
"-c",
|
||||
@ -490,32 +496,10 @@ class LaconicRegistryClient:
|
||||
"--num-providers",
|
||||
str(auction["num_providers"])
|
||||
]
|
||||
else:
|
||||
args = [
|
||||
"laconic",
|
||||
"-c",
|
||||
self.config_file,
|
||||
"registry",
|
||||
"auction",
|
||||
"create",
|
||||
"--kind",
|
||||
auction["kind"],
|
||||
"--commits-duration",
|
||||
str(auction["commits_duration"]),
|
||||
"--reveals-duration",
|
||||
str(auction["reveals_duration"]),
|
||||
"--denom",
|
||||
auction["denom"],
|
||||
"--commit-fee",
|
||||
str(auction["commit_fee"]),
|
||||
"--reveal-fee",
|
||||
str(auction["reveal_fee"]),
|
||||
"--minimum-bid",
|
||||
str(auction["minimum_bid"])
|
||||
]
|
||||
|
||||
return json.loads(logged_cmd(self.log_file, *args))["auctionId"]
|
||||
|
||||
@registry_mutex()
|
||||
def commit_bid(self, auction_id, amount, type="alnt"):
|
||||
args = [
|
||||
"laconic",
|
||||
@ -532,6 +516,7 @@ class LaconicRegistryClient:
|
||||
|
||||
return json.loads(logged_cmd(self.log_file, *args))["reveal_file"]
|
||||
|
||||
@registry_mutex()
|
||||
def reveal_bid(self, auction_id, reveal_file_path):
|
||||
logged_cmd(
|
||||
self.log_file,
|
||||
|
Loading…
Reference in New Issue
Block a user