Skip to content

Commit 1d60988

Browse files
authored
Merge pull request #51 from linux-kdevops/cel/fixes
Fixes for recent incomplete patches
2 parents 5de0d0c + e11ee2a commit 1d60988

File tree

4 files changed

+119
-53
lines changed

4 files changed

+119
-53
lines changed

playbooks/roles/volume_group/tasks/terraform/aws.yml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,19 @@
1010
# are not fixed and cannot be depended upon to locate specific
1111
# devices or their content.
1212
#
13-
# The block device name attached to each volume is fixed by
14-
# terraform but not exposed to Ansible or the guest. It has to be
15-
# extracted from terraform state and matched to a volume ID, which
16-
# appears as the device serial number.
13+
# Instead, rely on a directory created by a udev rule to find the
14+
# EBS block devices attached on behalf of kdevops. The rule
15+
# guarantees the symlinks names always point to the same block
16+
# device.
1717
#
18-
# The root EBS device is not included in terraform's block device
19-
# map, so is easily avoided.
20-
#
21-
22-
- name: Retrieve the block_device_map from terraform
23-
delegate_to: localhost
24-
run_once: true
25-
ansible.builtin.command:
26-
chdir: "{{ topdir_path }}/terraform/aws/"
27-
cmd: "terraform output -json block_device_map"
28-
register: terraform_output
29-
changed_when: false
3018

31-
- name: Exclude the device that will house the /data file system
32-
vars:
33-
block_device_dict: "{{ terraform_output.stdout | from_json }}"
34-
local_map: "{{ block_device_dict[inventory_hostname] }}"
35-
ansible.builtin.set_fact:
36-
ebs_volume_ids: "{{ ebs_volume_ids + ['nvme-Amazon_Elastic_Block_Store_' + item.value | regex_replace('-', '')] }}"
37-
when:
38-
item.key != data_device
39-
with_dict: "{{ local_map }}"
19+
- name: Retrieve list of symlinks residing under /dev/disk/kdevops
20+
ansible.builtin.find:
21+
file_type: link
22+
paths: "/dev/disk/kdevops"
23+
excludes: "{{ data_device | basename }}"
24+
register: find_output
4025

41-
- name: Add unused EBS volumes to the volume list
26+
- name: Extract device paths from find output
4227
ansible.builtin.set_fact:
43-
physical_volumes: "{{ physical_volumes + ['/dev/' + item.key] }}"
44-
when:
45-
- item.value.links.ids | intersect(ebs_volume_ids) | list | count > 0
46-
loop_control:
47-
label: "Adding block device: /dev/{{ item.key }}"
48-
with_dict: "{{ ansible_devices }}"
28+
physical_volumes: "{{ find_output.files | map(attribute='path') | list }}"

scripts/detect_indentation_issues.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ def check_file_indentation(file_path):
3434

3535
# Special rules for certain file types
3636
file_ext = Path(file_path).suffix.lower()
37+
file_name = Path(file_path).name
3738
is_yaml = file_ext in [".yml", ".yaml"]
38-
is_makefile = "Makefile" in Path(file_path).name or file_ext == ".mk"
39+
is_makefile = "Makefile" in file_name or file_ext == ".mk"
3940
is_python = file_ext == ".py"
41+
is_kconfig = file_name.startswith("Kconfig")
4042

4143
# Check each line for issues
4244
for line_num, line in enumerate(lines, 1):
@@ -69,6 +71,11 @@ def check_file_indentation(file_path):
6971
issues.append(
7072
f"Line {line_num}: Tab character in Python file (PEP 8 recommends spaces)"
7173
)
74+
elif is_kconfig:
75+
# Kconfig files use tabs for indentation and tab+spaces for help text
76+
# The pattern "\t " (tab followed by 2 spaces) is valid for help text
77+
# So we don't flag this as mixed indentation
78+
pass
7279
else:
7380
# For other files, check for mixed indentation
7481
if leading_ws:

scripts/dynamic-cloud-kconfig.Makefile

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,51 @@ LAMBDALABS_KCONFIG_IMAGES := $(LAMBDALABS_KCONFIG_DIR)/Kconfig.images.generated
1212

1313
LAMBDALABS_KCONFIGS := $(LAMBDALABS_KCONFIG_COMPUTE) $(LAMBDALABS_KCONFIG_LOCATION) $(LAMBDALABS_KCONFIG_IMAGES)
1414

15-
# Add Lambda Labs generated files to mrproper clean list
16-
KDEVOPS_MRPROPER += $(LAMBDALABS_KCONFIGS)
15+
# AWS dynamic configuration
16+
AWS_KCONFIG_DIR := terraform/aws/kconfigs
17+
AWS_KCONFIG_AMI := $(AWS_KCONFIG_DIR)/Kconfig.ami
18+
AWS_KCONFIG_INSTANCE := $(AWS_KCONFIG_DIR)/Kconfig.instance
19+
AWS_KCONFIG_LOCATION := $(AWS_KCONFIG_DIR)/Kconfig.location
20+
21+
AWS_KCONFIGS := $(AWS_KCONFIG_AMI) $(AWS_KCONFIG_INSTANCE) $(AWS_KCONFIG_LOCATION)
22+
23+
# Add generated files to mrproper clean list
24+
KDEVOPS_MRPROPER += $(LAMBDALABS_KCONFIGS) $(AWS_KCONFIGS)
1725

1826
# Touch Lambda Labs generated files so Kconfig can source them
1927
# This ensures the files exist (even if empty) before Kconfig runs
2028
dynamic_lambdalabs_kconfig_touch:
2129
$(Q)touch $(LAMBDALABS_KCONFIGS)
2230

23-
DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch
31+
# Touch AWS generated files so Kconfig can source them
32+
dynamic_aws_kconfig_touch:
33+
$(Q)touch $(AWS_KCONFIGS)
34+
35+
DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch
2436

25-
# Individual Lambda Labs targets are now handled by generate_cloud_configs.py
37+
# Lambda Labs targets use --provider argument for efficiency
2638
cloud-config-lambdalabs:
27-
$(Q)python3 scripts/generate_cloud_configs.py
39+
$(Q)python3 scripts/generate_cloud_configs.py --provider lambdalabs
40+
41+
# AWS targets use --provider argument for efficiency
42+
cloud-config-aws:
43+
$(Q)python3 scripts/generate_cloud_configs.py --provider aws
2844

2945
# Clean Lambda Labs generated files
3046
clean-cloud-config-lambdalabs:
3147
$(Q)rm -f $(LAMBDALABS_KCONFIGS)
3248

33-
DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs
49+
# Clean AWS generated files
50+
clean-cloud-config-aws:
51+
$(Q)rm -f $(AWS_KCONFIGS)
52+
53+
DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs cloud-config-aws
3454

3555
cloud-config-help:
3656
@echo "Cloud-specific dynamic kconfig targets:"
3757
@echo "cloud-config - generates all cloud provider dynamic kconfig content"
3858
@echo "cloud-config-lambdalabs - generates Lambda Labs dynamic kconfig content"
59+
@echo "cloud-config-aws - generates AWS dynamic kconfig content"
3960
@echo "clean-cloud-config - removes all generated cloud kconfig files"
4061
@echo "cloud-list-all - list all cloud instances for configured provider"
4162

@@ -44,11 +65,11 @@ HELP_TARGETS += cloud-config-help
4465
cloud-config:
4566
$(Q)python3 scripts/generate_cloud_configs.py
4667

47-
clean-cloud-config: clean-cloud-config-lambdalabs
68+
clean-cloud-config: clean-cloud-config-lambdalabs clean-cloud-config-aws
4869
$(Q)echo "Cleaned all cloud provider dynamic Kconfig files."
4970

5071
cloud-list-all:
5172
$(Q)chmod +x scripts/cloud_list_all.sh
5273
$(Q)scripts/cloud_list_all.sh
5374

54-
PHONY += cloud-config cloud-config-lambdalabs clean-cloud-config clean-cloud-config-lambdalabs cloud-config-help cloud-list-all
75+
PHONY += cloud-config cloud-config-lambdalabs cloud-config-aws clean-cloud-config clean-cloud-config-lambdalabs clean-cloud-config-aws cloud-config-help cloud-list-all

scripts/generate_cloud_configs.py

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
import subprocess
1212
import json
13+
import argparse
1314

1415

1516
def generate_lambdalabs_kconfig() -> bool:
@@ -146,16 +147,12 @@ def generate_aws_kconfig() -> bool:
146147
return all_success
147148

148149

149-
def main():
150-
"""Main function to generate cloud configurations."""
151-
print("Cloud Provider Configuration Summary")
152-
print("=" * 60)
153-
print()
154-
155-
# Lambda Labs - Generate Kconfig files first
150+
def process_lambdalabs():
151+
"""Process Lambda Labs configuration."""
152+
# Generate Kconfig files first
156153
kconfig_generated = generate_lambdalabs_kconfig()
157154

158-
# Lambda Labs - Get summary
155+
# Get summary
159156
success, summary = get_lambdalabs_summary()
160157
if success:
161158
print(f"✓ {summary}")
@@ -167,23 +164,84 @@ def main():
167164
print(f"⚠ {summary}")
168165
print()
169166

170-
# AWS - Generate Kconfig files
167+
168+
def process_aws():
169+
"""Process AWS configuration."""
171170
kconfig_generated = generate_aws_kconfig()
172171
if kconfig_generated:
173172
print("✓ AWS: Kconfig files generated successfully")
174173
else:
175174
print("⚠ AWS: Failed to generate Kconfig files - using defaults")
176175
print()
177176

178-
# Azure (placeholder - not implemented)
177+
178+
def process_azure():
179+
"""Process Azure configuration (placeholder)."""
179180
print("⚠ Azure: Dynamic configuration not yet implemented")
180181

181-
# GCE (placeholder - not implemented)
182+
183+
def process_gce():
184+
"""Process GCE configuration (placeholder)."""
182185
print("⚠ GCE: Dynamic configuration not yet implemented")
183186

184-
# OCI (placeholder - not implemented)
187+
188+
def process_oci():
189+
"""Process OCI configuration (placeholder)."""
185190
print("⚠ OCI: Dynamic configuration not yet implemented")
186191

192+
193+
def main():
194+
"""Main function to generate cloud configurations."""
195+
parser = argparse.ArgumentParser(
196+
description="Generate dynamic cloud configurations for supported providers",
197+
formatter_class=argparse.RawDescriptionHelpFormatter,
198+
epilog="""
199+
Examples:
200+
%(prog)s # Generate configs for all providers
201+
%(prog)s --provider lambdalabs # Generate configs for Lambda Labs only
202+
%(prog)s --provider aws # Generate configs for AWS only
203+
%(prog)s --provider azure # Generate configs for Azure only
204+
205+
Supported providers: lambdalabs, aws, azure, gce, oci
206+
""",
207+
)
208+
209+
parser.add_argument(
210+
"--provider",
211+
choices=["lambdalabs", "aws", "azure", "gce", "oci"],
212+
help="Generate configuration for a specific cloud provider only",
213+
)
214+
215+
args = parser.parse_args()
216+
217+
# Provider dispatch table
218+
providers = {
219+
"lambdalabs": process_lambdalabs,
220+
"aws": process_aws,
221+
"azure": process_azure,
222+
"gce": process_gce,
223+
"oci": process_oci,
224+
}
225+
226+
print("Cloud Provider Configuration Summary")
227+
print("=" * 60)
228+
print()
229+
230+
# If a specific provider is requested, only process that one
231+
if args.provider:
232+
if args.provider in providers:
233+
providers[args.provider]()
234+
else:
235+
print(f"Error: Unknown provider '{args.provider}'", file=sys.stderr)
236+
sys.exit(1)
237+
else:
238+
# Process all providers
239+
process_lambdalabs()
240+
process_aws()
241+
process_azure()
242+
process_gce()
243+
process_oci()
244+
187245
print()
188246
print("Note: Dynamic configurations query real-time availability")
189247
print("Run 'make menuconfig' to configure your cloud provider")

0 commit comments

Comments
 (0)