From 53a96defe0ba66c6ad562882404953dfd09955da Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 30 Jan 2025 11:12:34 +0530 Subject: [PATCH 1/3] Add IP address value to DNS records for webapp deployments --- .../deploy/webapp/deploy_webapp_from_registry.py | 5 +++++ stack_orchestrator/deploy/webapp/util.py | 2 ++ 2 files changed, 7 insertions(+) diff --git a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py index 4e57659d..a4606dc9 100644 --- a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py +++ b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py @@ -54,6 +54,7 @@ def process_app_deployment_request( deployment_record_namespace, dns_record_namespace, default_dns_suffix, + dns_value, deployment_parent_dir, kube_config, image_registry, @@ -250,6 +251,7 @@ def process_app_deployment_request( app_deployment_lrn, dns_record, dns_lrn, + dns_value, deployment_dir, app_deployment_request, webapp_deployer_record, @@ -304,6 +306,7 @@ def dump_known_requests(filename, requests, status="SEEN"): help="How to handle requests with an FQDN: prohibit, allow, preexisting", default="prohibit", ) +@click.option("--ip", help="IP address of the k8s deployment (to be set in DNS record)") @click.option("--record-namespace-dns", help="eg, lrn://laconic/dns", required=True) @click.option( "--record-namespace-deployments", @@ -381,6 +384,7 @@ def command( # noqa: C901 only_update_state, dns_suffix, fqdn_policy, + ip, record_namespace_dns, record_namespace_deployments, dry_run, @@ -665,6 +669,7 @@ def command( # noqa: C901 record_namespace_deployments, record_namespace_dns, dns_suffix, + ip, os.path.abspath(deployment_parent_dir), kube_config, image_registry, diff --git a/stack_orchestrator/deploy/webapp/util.py b/stack_orchestrator/deploy/webapp/util.py index eebdb23c..375ee5be 100644 --- a/stack_orchestrator/deploy/webapp/util.py +++ b/stack_orchestrator/deploy/webapp/util.py @@ -688,6 +688,7 @@ def publish_deployment( deployment_lrn, dns_record, dns_lrn, + dns_value: str, deployment_dir, app_deployment_request=None, webapp_deployer_record=None, @@ -716,6 +717,7 @@ def publish_deployment( "version": dns_ver, "name": fqdn, "resource_type": "A", + "value": dns_value, "meta": {"so": uniq.hex}, } } -- 2.45.2 From 27a6470ad916762cca7ad65859ea6e9c1f0ae4fc Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 30 Jan 2025 11:33:33 +0530 Subject: [PATCH 2/3] Require IP input with allow FQDN policy --- .../deploy/webapp/deploy_webapp_from_registry.py | 7 +++++++ stack_orchestrator/deploy/webapp/util.py | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py index a4606dc9..228cd7a8 100644 --- a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py +++ b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py @@ -433,6 +433,13 @@ def command( # noqa: C901 ) sys.exit(2) + if fqdn_policy == "allow" and not ip: + print( + "--ip is required with 'allow' fqdn-policy", + file=sys.stderr, + ) + sys.exit(2) + tempdir = tempfile.mkdtemp() gpg = gnupg.GPG(gnupghome=tempdir) diff --git a/stack_orchestrator/deploy/webapp/util.py b/stack_orchestrator/deploy/webapp/util.py index 375ee5be..1b52cab0 100644 --- a/stack_orchestrator/deploy/webapp/util.py +++ b/stack_orchestrator/deploy/webapp/util.py @@ -688,7 +688,7 @@ def publish_deployment( deployment_lrn, dns_record, dns_lrn, - dns_value: str, + dns_value: str | None, deployment_dir, app_deployment_request=None, webapp_deployer_record=None, @@ -717,12 +717,13 @@ def publish_deployment( "version": dns_ver, "name": fqdn, "resource_type": "A", - "value": dns_value, "meta": {"so": uniq.hex}, } } if app_deployment_request: new_dns_record["record"]["request"] = app_deployment_request.id + if dns_value: + new_dns_record["record"]["value"] = dns_value if logger: logger.log("Publishing DnsRecord.") -- 2.45.2 From a085ca8756760588839d52908d8a3fc3b04b02c5 Mon Sep 17 00:00:00 2001 From: Prathamesh Musale Date: Thu, 30 Jan 2025 11:48:56 +0530 Subject: [PATCH 3/3] Fix function arg type --- .../deploy/webapp/deploy_webapp_from_registry.py | 4 ++-- stack_orchestrator/deploy/webapp/util.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py index 228cd7a8..24a529c2 100644 --- a/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py +++ b/stack_orchestrator/deploy/webapp/deploy_webapp_from_registry.py @@ -251,8 +251,8 @@ def process_app_deployment_request( app_deployment_lrn, dns_record, dns_lrn, - dns_value, deployment_dir, + dns_value, app_deployment_request, webapp_deployer_record, logger, @@ -306,7 +306,7 @@ def dump_known_requests(filename, requests, status="SEEN"): help="How to handle requests with an FQDN: prohibit, allow, preexisting", default="prohibit", ) -@click.option("--ip", help="IP address of the k8s deployment (to be set in DNS record)") +@click.option("--ip", help="IP address of the k8s deployment (to be set in DNS record)", default=None) @click.option("--record-namespace-dns", help="eg, lrn://laconic/dns", required=True) @click.option( "--record-namespace-deployments", diff --git a/stack_orchestrator/deploy/webapp/util.py b/stack_orchestrator/deploy/webapp/util.py index 1b52cab0..991dd249 100644 --- a/stack_orchestrator/deploy/webapp/util.py +++ b/stack_orchestrator/deploy/webapp/util.py @@ -688,8 +688,8 @@ def publish_deployment( deployment_lrn, dns_record, dns_lrn, - dns_value: str | None, deployment_dir, + dns_value=None, app_deployment_request=None, webapp_deployer_record=None, logger=None, -- 2.45.2