All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: Chuck Lever <cel@kernel.org>, Daniel Gomez <da.gomez@kruces.com>,
	kdevops@lists.linux.dev
Cc: Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH v4 4/8] aws: integrate dynamic Kconfig generation with make targets
Date: Tue, 16 Sep 2025 17:34:45 -0700	[thread overview]
Message-ID: <20250917003451.2318229-5-mcgrof@kernel.org> (raw)
In-Reply-To: <20250917003451.2318229-1-mcgrof@kernel.org>

Add Makefile integration for AWS dynamic Kconfig generation using
Chuck's scripts with the optimized wrapper. This provides:

- make cloud-config-aws: Generate AWS Kconfig files
- make cloud-update-aws: Clear cache and regenerate fresh data
- make cloud-config: Now includes AWS generation
- make cloud-update: Refreshes all cloud provider data
- make clean-cloud-config-aws: Clean generated AWS files

The integration properly manages AWS Kconfig files alongside Lambda Labs
configurations and ensures empty files exist before Kconfig runs to
prevent sourcing errors.

Also update generate_cloud_configs.py to call the AWS generator and
provide summary statistics about available AWS resources.

Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 scripts/dynamic-cloud-kconfig.Makefile | 49 ++++++++++++++--
 scripts/generate_cloud_configs.py      | 78 +++++++++++++++++++++++++-
 2 files changed, 120 insertions(+), 7 deletions(-)

diff --git a/scripts/dynamic-cloud-kconfig.Makefile b/scripts/dynamic-cloud-kconfig.Makefile
index e15651ab..ed2d5366 100644
--- a/scripts/dynamic-cloud-kconfig.Makefile
+++ b/scripts/dynamic-cloud-kconfig.Makefile
@@ -12,8 +12,18 @@ LAMBDALABS_KCONFIG_IMAGES := $(LAMBDALABS_KCONFIG_DIR)/Kconfig.images.generated
 
 LAMBDALABS_KCONFIGS := $(LAMBDALABS_KCONFIG_COMPUTE) $(LAMBDALABS_KCONFIG_LOCATION) $(LAMBDALABS_KCONFIG_IMAGES)
 
-# Add Lambda Labs generated files to mrproper clean list
-KDEVOPS_MRPROPER += $(LAMBDALABS_KCONFIGS)
+# AWS dynamic configuration
+AWS_KCONFIG_DIR := terraform/aws/kconfigs
+AWS_KCONFIG_COMPUTE := $(AWS_KCONFIG_DIR)/Kconfig.compute.generated
+AWS_KCONFIG_LOCATION := $(AWS_KCONFIG_DIR)/Kconfig.location.generated
+AWS_KCONFIG_GPU_AMIS := $(AWS_KCONFIG_DIR)/Kconfig.gpu-amis.generated
+AWS_KCONFIG_INSTANCE_TYPES_DIR := $(AWS_KCONFIG_DIR)/instance-types
+
+# Note: Instance type files are generated dynamically, so we just track the main ones
+AWS_KCONFIGS := $(AWS_KCONFIG_COMPUTE) $(AWS_KCONFIG_LOCATION) $(AWS_KCONFIG_GPU_AMIS)
+
+# Add generated files to mrproper clean list
+KDEVOPS_MRPROPER += $(LAMBDALABS_KCONFIGS) $(AWS_KCONFIGS)
 
 # Touch Lambda Labs generated files so Kconfig can source them
 # This ensures the files exist (even if empty) before Kconfig runs
@@ -22,20 +32,44 @@ dynamic_lambdalabs_kconfig_touch:
 
 DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch
 
+# Touch AWS generated files so Kconfig can source them
+dynamic_aws_kconfig_touch:
+	$(Q)mkdir -p $(AWS_KCONFIG_INSTANCE_TYPES_DIR)
+	$(Q)touch $(AWS_KCONFIGS)
+
+DYNAMIC_KCONFIG += dynamic_aws_kconfig_touch
+
 # Individual Lambda Labs targets are now handled by generate_cloud_configs.py
 cloud-config-lambdalabs:
 	$(Q)python3 scripts/generate_cloud_configs.py
 
+# AWS targets using Chuck's scripts with caching
+cloud-config-aws:
+	$(Q)python3 terraform/aws/scripts/generate_aws_kconfig.py
+
+# AWS cache refresh (clears cache and regenerates)
+cloud-update-aws:
+	$(Q)python3 terraform/aws/scripts/generate_aws_kconfig.py clear-cache
+	$(Q)python3 terraform/aws/scripts/generate_aws_kconfig.py
+
 # Clean Lambda Labs generated files
 clean-cloud-config-lambdalabs:
 	$(Q)rm -f $(LAMBDALABS_KCONFIGS)
 
-DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs
+# Clean AWS generated files
+clean-cloud-config-aws:
+	$(Q)rm -f $(AWS_KCONFIGS)
+	$(Q)rm -rf $(AWS_KCONFIG_INSTANCE_TYPES_DIR)
+
+DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs cloud-config-aws
 
 cloud-config-help:
 	@echo "Cloud-specific dynamic kconfig targets:"
 	@echo "cloud-config            - generates all cloud provider dynamic kconfig content"
 	@echo "cloud-config-lambdalabs - generates Lambda Labs dynamic kconfig content"
+	@echo "cloud-config-aws        - generates AWS dynamic kconfig content"
+	@echo "cloud-update            - refreshes cloud provider data (clears cache)"
+	@echo "cloud-update-aws        - refreshes AWS data (clears cache and regenerates)"
 	@echo "clean-cloud-config      - removes all generated cloud kconfig files"
 	@echo "cloud-list-all          - list all cloud instances for configured provider"
 
@@ -44,11 +78,16 @@ HELP_TARGETS += cloud-config-help
 cloud-config:
 	$(Q)python3 scripts/generate_cloud_configs.py
 
-clean-cloud-config: clean-cloud-config-lambdalabs
+cloud-update: cloud-update-aws
+	$(Q)echo "Updated cloud provider configurations."
+
+clean-cloud-config: clean-cloud-config-lambdalabs clean-cloud-config-aws
 	$(Q)echo "Cleaned all cloud provider dynamic Kconfig files."
 
 cloud-list-all:
 	$(Q)chmod +x scripts/cloud_list_all.sh
 	$(Q)scripts/cloud_list_all.sh
 
-PHONY += cloud-config cloud-config-lambdalabs clean-cloud-config clean-cloud-config-lambdalabs cloud-config-help cloud-list-all
+PHONY += cloud-config cloud-config-lambdalabs cloud-config-aws cloud-update cloud-update-aws
+PHONY += clean-cloud-config clean-cloud-config-lambdalabs clean-cloud-config-aws
+PHONY += cloud-config-help cloud-list-all
diff --git a/scripts/generate_cloud_configs.py b/scripts/generate_cloud_configs.py
index b16294dd..e8251a73 100755
--- a/scripts/generate_cloud_configs.py
+++ b/scripts/generate_cloud_configs.py
@@ -100,6 +100,68 @@ def get_lambdalabs_summary() -> tuple[bool, str]:
         return False, "Lambda Labs: Error querying API - using defaults"
 
 
+def generate_aws_kconfig() -> bool:
+    """
+    Generate AWS Kconfig files using Chuck's scripts.
+    Returns True on success, False on failure.
+    """
+    script_path = "terraform/aws/scripts/generate_aws_kconfig.py"
+
+    result = subprocess.run(
+        [sys.executable, script_path],
+        capture_output=True,
+        text=True,
+        check=False,
+    )
+
+    return result.returncode == 0
+
+
+def get_aws_summary() -> tuple[bool, str]:
+    """
+    Get a summary of AWS configurations.
+    Returns (success, summary_string)
+    """
+    try:
+        # Check if AWS credentials are configured
+        result = subprocess.run(
+            ["aws", "sts", "get-caller-identity"],
+            capture_output=True,
+            text=True,
+            check=False,
+        )
+
+        if result.returncode != 0:
+            return False, "AWS: Credentials not configured - using defaults"
+
+        # Get basic stats from cached data if available
+        cache_dir = os.path.expanduser("~/.cache/kdevops/aws")
+        families_cache = os.path.join(cache_dir, "aws_families.json")
+
+        if os.path.exists(families_cache):
+            with open(families_cache, 'r') as f:
+                families = json.load(f)
+                family_count = len(families)
+        else:
+            family_count = "72+"  # Known minimum
+
+        regions_cache = os.path.join(cache_dir, "aws_regions.json")
+        if os.path.exists(regions_cache):
+            with open(regions_cache, 'r') as f:
+                regions = json.load(f)
+                region_count = len(regions)
+        else:
+            region_count = "30+"  # Known minimum
+
+        return (
+            True,
+            f"AWS: {family_count} instance families, {region_count} regions, "
+            f"900+ instance types available"
+        )
+    except Exception:
+        return False, "AWS: Error checking configuration"
+
+
 def main():
     """Main function to generate cloud configurations."""
     print("Cloud Provider Configuration Summary")
@@ -121,8 +183,20 @@ def main():
         print(f"⚠ {summary}")
     print()
 
-    # AWS (placeholder - not implemented)
-    print("⚠ AWS: Dynamic configuration not yet implemented")
+    # AWS - Generate Kconfig files
+    aws_generated = generate_aws_kconfig()
+
+    # AWS - Get summary
+    success, summary = get_aws_summary()
+    if success:
+        print(f"✓ {summary}")
+        if aws_generated:
+            print("  Kconfig files generated successfully")
+        else:
+            print("  Warning: Failed to generate Kconfig files")
+    else:
+        print(f"⚠ {summary}")
+    print()
 
     # Azure (placeholder - not implemented)
     print("⚠ Azure: Dynamic configuration not yet implemented")
-- 
2.51.0


  parent reply	other threads:[~2025-09-17  0:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-17  0:34 [PATCH v4 0/8] aws: add dynamic kconfig support Luis Chamberlain
2025-09-17  0:34 ` [PATCH v4 1/8] aws: prevent SSH key conflicts across multiple kdevops directories Luis Chamberlain
2025-09-17  3:36   ` Chuck Lever
2025-09-17  0:34 ` [PATCH v4 2/8] terraform/aws: Add scripts to gather provider resource information Luis Chamberlain
2025-09-17  0:34 ` [PATCH v4 3/8] aws: add optimized Kconfig generator using Chuck's scripts Luis Chamberlain
2025-09-17  3:58   ` Chuck Lever
2025-09-17  0:34 ` Luis Chamberlain [this message]
2025-09-17  3:40   ` [PATCH v4 4/8] aws: integrate dynamic Kconfig generation with make targets Chuck Lever
2025-09-17  7:05     ` Luis Chamberlain
2025-09-17  0:34 ` [PATCH v4 5/8] aws: add cloud billing support with make cloud-bill Luis Chamberlain
2025-09-17  0:34 ` [PATCH v4 6/8] aws: replace static Kconfig files with dynamically generated ones Luis Chamberlain
2025-09-17  0:34 ` [PATCH v4 7/8] aws: add GPU instance defconfigs for AI/ML workloads Luis Chamberlain
2025-09-17  0:34 ` [PATCH v4 8/8] docs: add documentation for dynamic cloud configuration Luis Chamberlain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250917003451.2318229-5-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=cel@kernel.org \
    --cc=da.gomez@kruces.com \
    --cc=kdevops@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.