Compare commits

...

3 Commits

Author SHA1 Message Date
e746eed39d merge
Some checks failed
Lint Checks / Run linter (pull_request) Failing after 37s
Smoke Test / Run basic test suite (pull_request) Failing after 1m16s
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Failing after 1m20s
Deploy Test / Run deploy test suite (pull_request) Failing after 1m22s
Webapp Test / Run webapp test suite (pull_request) Failing after 1m29s
2024-08-14 15:22:57 -05:00
952389abb0 Add option to recreate deployments rather than update them. (#920)
All checks were successful
Lint Checks / Run linter (push) Successful in 48s
Publish / Build and publish (push) Successful in 1m21s
Smoke Test / Run basic test suite (push) Successful in 4m46s
Webapp Test / Run webapp test suite (push) Successful in 5m16s
Deploy Test / Run deploy test suite (push) Successful in 5m41s
cherry-pick from #912

Reviewed-on: #920
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
2024-08-14 20:14:40 +00:00
5c275aa622 Defensively handle errors examining app requests. (#922)
All checks were successful
Lint Checks / Run linter (push) Successful in 34s
Publish / Build and publish (push) Successful in 1m7s
Smoke Test / Run basic test suite (push) Successful in 4m0s
Webapp Test / Run webapp test suite (push) Successful in 4m42s
Deploy Test / Run deploy test suite (push) Successful in 4m58s
Database Test / Run database hosting test on kind/k8s (push) Successful in 10m2s
Container Registry Test / Run contaier registry hosting test on kind/k8s (push) Successful in 3m44s
External Stack Test / Run external stack test suite (push) Successful in 4m26s
Related to cerc-io/webapp-deployment-status-api#10

There are two issues in that.  One is that the output probably changed recently, whether in the client or server, where no matching record is found by ID (Note this is specific to `laconic record get --id <v>` and does not seem to apply to the similar command to retrieve a record by name, `laconic name resolve <n>`).

Rather than returning `[]` it is now returning `[ null ]`.  This cause us to think there *was* an application record found, and we attempt to treat the `null` entry like an Application object.  That's fixed by filtering out null responses, which is a good precaution for the deployer, though I think it makes sense to ask whether this new behavior by the client/server is correct.  Seems suspicious.

The other issue is that all the defensive checks we had in place to deal with broken/bad AppDeploymentRequests were around the _build_.  This error was coming much earlier, merely when parsing and examining the request to see if it needed to be handled at all.

I have now added similar defensive error handling around that portion of the code.

Reviewed-on: #922
Reviewed-by: zramsay <zramsay@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-14 18:04:31 +00:00
2 changed files with 22 additions and 11 deletions

View File

@ -45,6 +45,7 @@ def process_app_deployment_request(
image_registry,
force_rebuild,
fqdn_policy,
recreate_on_deploy,
logger
):
logger.log("BEGIN - process_app_deployment_request")
@ -165,6 +166,7 @@ def process_app_deployment_request(
deploy_to_k8s(
deployment_record,
deployment_dir,
recreate_on_deploy,
logger
)
@ -220,12 +222,13 @@ def dump_known_requests(filename, requests, status="SEEN"):
@click.option("--include-tags", help="Only include requests with matching tags (comma-separated).", default="")
@click.option("--exclude-tags", help="Exclude requests with matching tags (comma-separated).", default="")
@click.option("--force-rebuild", help="Rebuild even if the image already exists.", is_flag=True)
@click.option("--recreate-on-deploy", help="Remove and recreate deployments instead of updating them.", is_flag=True)
@click.option("--log-dir", help="Output build/deployment logs to directory.", default=None)
@click.pass_context
def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_dir, # noqa: C901
request_id, discover, state_file, only_update_state,
dns_suffix, fqdn_policy, record_namespace_dns, record_namespace_deployments, dry_run,
include_tags, exclude_tags, force_rebuild, log_dir):
include_tags, exclude_tags, force_rebuild, recreate_on_deploy, log_dir):
root_logger = TimedLogger(file=sys.stderr)
if request_id and discover:
print("Cannot specify both --request-id and --discover", file=sys.stderr)
@ -383,6 +386,7 @@ def command(ctx, kube_config, laconic_config, image_registry, deployment_parent_
image_registry,
force_rebuild,
fqdn_policy,
recreate_on_deploy,
logger
)
status = "DEPLOYED"

View File

@ -318,17 +318,24 @@ def push_container_image(deployment_dir, logger):
logger.log("Finished pushing images.")
def deploy_to_k8s(deploy_record, deployment_dir, logger):
if not deploy_record:
command = "start"
else:
command = "update"
def deploy_to_k8s(deploy_record, deployment_dir, recreate, logger):
logger.log("Deploying to k8s ...")
logger.log(f"Running {command} command on deployment dir: {deployment_dir}")
result = subprocess.run([sys.argv[0], "deployment", "--dir", deployment_dir, command],
stdout=logger.file, stderr=logger.file)
result.check_returncode()
if recreate:
commands_to_run = ["stop", "start"]
else:
if not deploy_record:
commands_to_run = ["start"]
else:
commands_to_run = ["update"]
for command in commands_to_run:
logger.log(f"Running {command} command on deployment dir: {deployment_dir}")
result = subprocess.run([sys.argv[0], "deployment", "--dir", deployment_dir, command],
stdout=logger.file, stderr=logger.file)
result.check_returncode()
logger.log(f"Finished {command} command on deployment dir: {deployment_dir}")
logger.log("Finished deploying to k8s.")