Include payment info in deployment record.
Some checks failed
Lint Checks / Run linter (pull_request) Failing after 35s
Smoke Test / Run basic test suite (pull_request) Successful in 4m31s
Webapp Test / Run webapp test suite (pull_request) Successful in 4m54s
Deploy Test / Run deploy test suite (pull_request) Successful in 5m6s
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Successful in 7m10s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Successful in 8m37s

This commit is contained in:
Thomas E Lackey 2024-08-16 22:33:23 -05:00
parent 07030044ec
commit b449d88b6c
2 changed files with 32 additions and 6 deletions

View File

@ -55,6 +55,7 @@ def process_app_deployment_request(
force_rebuild,
fqdn_policy,
recreate_on_deploy,
payment_address,
logger,
):
logger.log("BEGIN - process_app_deployment_request")
@ -226,6 +227,7 @@ def process_app_deployment_request(
dns_lrn,
deployment_dir,
app_deployment_request,
payment_address,
logger,
)
logger.log("Publication complete.")
@ -482,11 +484,17 @@ def command( # noqa: C901
# Find deployments.
main_logger.log("Discovering existing app deployments...")
deployments = laconic.app_deployments()
if all_requests:
deployments = laconic.app_deployments()
else:
deployments = laconic.app_deployments({"by": payment_address})
deployments_by_request = {}
deployments_by_payment = {}
for d in deployments:
if d.attributes.request:
deployments_by_request[d.attributes.request] = d
if d.attributes.payment:
deployments_by_request[d.attributes.payment] = d
# Find removal requests.
main_logger.log("Discovering deployment removal and cancellation requests...")
@ -524,7 +532,13 @@ def command( # noqa: C901
if min_required_payment:
for r in requests_to_check_for_payment:
main_logger.log(f"{r.id}: Confirming payment...")
if confirm_payment(
if r.attributes.payment in deployments_by_payment:
main_logger.log(
f"Skipping request {r.id}: payment already applied to deployment "
f"{deployments_by_payment[r.attributes.payment].id}"
)
dump_known_requests(state_file, [r], status="UNPAID")
elif confirm_payment(
laconic, r, payment_address, min_required_payment, main_logger
):
main_logger.log(f"{r.id}: Payment confirmed.")
@ -578,6 +592,7 @@ def command( # noqa: C901
force_rebuild,
fqdn_policy,
recreate_on_deploy,
payment_address,
build_logger,
)
status = "DEPLOYED"

View File

@ -96,7 +96,7 @@ def is_id(name_or_id: str):
def confirm_payment(laconic, record, payment_address, min_amount, logger):
if not record.attributes.payment:
logger.log(f"{record.id}: not payment tx")
logger.log(f"{record.id}: no payment tx info")
return False
tx = laconic.get_tx(record.attributes.payment)
@ -147,9 +147,12 @@ class LaconicRegistryClient:
return None
def get_owner(self, record):
bond = self.get_bond(record.bondId, require=True)
return bond.owner
def get_owner(self, record, require=False):
bond = self.get_bond(record.bondId, require)
if bond:
return bond.owner
return bond
def get_account(self, address, refresh=False, require=False):
if not refresh and address in self.cache["accounts"]:
@ -563,6 +566,7 @@ def publish_deployment(
dns_lrn,
deployment_dir,
app_deployment_request=None,
payment_address=None,
logger=None,
):
if not deploy_record:
@ -614,6 +618,13 @@ def publish_deployment(
}
if app_deployment_request:
new_deployment_record["record"]["request"] = app_deployment_request.id
if app_deployment_request.attributes.payment:
new_deployment_record["record"][
"payment"
] = app_deployment_request.attributes.payment
if payment_address:
new_deployment_record["record"]["by"] = payment_address
if logger:
logger.log("Publishing ApplicationDeploymentRecord.")