← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~igor-brovtsin/maas:dgx-deployment-fixes into maas:master

 

Igor Brovtsin has proposed merging ~igor-brovtsin/maas:dgx-deployment-fixes into maas:master.

Commit message:
Deployment fixes for platform-optimised kernels

Requested reviews:
  MAAS Maintainers (maas-maintainers)

For more details, see:
https://code.launchpad.net/~igor-brovtsin/maas/+git/maas/+merge/442660

Final touches to the platform-optimised kernel handling:

- Modified `get_boot_config_for_machine` so that it always tries to find a kernel, regardless of the purpose. This allows us to point rack at the correct kernel, regardless of the `hwe_kernel` and `subarch` values.

- Fixed machines not being able to fetch curtin config because of platform-unaware boot resource filtering

- Fixed `precise` deployment hack I accidentally broke
-- 
Your team MAAS Committers is subscribed to branch maas:master.
diff --git a/src/maasserver/models/bootresource.py b/src/maasserver/models/bootresource.py
index 8629310..34c37e6 100644
--- a/src/maasserver/models/bootresource.py
+++ b/src/maasserver/models/bootresource.py
@@ -186,7 +186,9 @@ class BootResourceManager(Manager):
             architecture__startswith=architecture,
         )
         for resource in resources:
-            if resource.supports_subarch(subarchitecture):
+            if resource.supports_subarch(
+                subarchitecture
+            ) or resource.supports_platform(subarchitecture):
                 return resource
         return None
 
@@ -735,3 +737,15 @@ class BootResource(CleanSave, TimestampedModel):
             return False
         subarches = self.extra["subarches"].split(",")
         return subarch in subarches
+
+    def supports_platform(self, platform):
+        """Return True if the resource supports the given platform."""
+        _, self_subarch = self.split_arch()
+        if platform == self_subarch:
+            return True
+        if platform == self.extra.get("platform"):
+            return True
+        if "supported_platforms" not in self.extra:
+            return False
+        platforms = self.extra["supported_platforms"].split(",")
+        return platform in platforms
diff --git a/src/maasserver/preseed.py b/src/maasserver/preseed.py
index 8e9a8ed..b7472b0 100644
--- a/src/maasserver/preseed.py
+++ b/src/maasserver/preseed.py
@@ -492,6 +492,11 @@ def get_curtin_installer_url(node):
         url_prepend = ""
     else:
         url_prepend = "%s:" % image["xinstall_type"]
+    if node.hwe_kernel:
+        subarch = node.hwe_kernel
+    if series == "precise":
+        # See above: it is the only squashfs available for precise
+        subarch = "generic"
     dyn_uri = "/".join(
         [
             osystem,
diff --git a/src/maasserver/rpc/boot.py b/src/maasserver/rpc/boot.py
index 68fc881..bbc204a 100644
--- a/src/maasserver/rpc/boot.py
+++ b/src/maasserver/rpc/boot.py
@@ -251,6 +251,13 @@ def get_boot_config_for_machine(machine, configs, purpose):
     # hardware enablement kernels(i.e a highbank hwe-t kernel on precise)
     # we give precedence to any kernel defined in the subarchitecture field
 
+    # XXX: roaksoax LP: #1739761 - Do not override the subarch (used for
+    # the deployment ephemeral env) when deploying precise, provided that
+    # it uses the commissioning distro_series and hwe kernels are not
+    # needed.
+
+    subarch_override = machine.hwe_kernel and not precise
+
     # If the machine is deployed, hardcode the use of the Minimum HWE Kernel
     # This is to ensure that machines can always do testing regardless of
     # what they were deployed with, using the defaults from the settings
@@ -259,33 +266,41 @@ def get_boot_config_for_machine(machine, configs, purpose):
         and machine.status == NODE_STATUS.TESTING
         and purpose == "commissioning"
     )
+
     if testing_from_deployed:
         subarch = (
             subarch
             if not configs["default_min_hwe_kernel"]
             else configs["default_min_hwe_kernel"]
         )
-    # XXX: roaksoax LP: #1739761 - Do not override the subarch (used for
-    # the deployment ephemeral env) when deploying precise, provided that
-    # it uses the commissioning distro_series and hwe kernels are not
-    # needed.
-    elif subarch == "generic" and machine.hwe_kernel and not precise:
+    elif subarch_override:
         subarch = machine.hwe_kernel
-    elif (
-        subarch == "generic"
-        and purpose == "commissioning"
-        and machine.min_hwe_kernel
-    ):
-        try:
-            subarch = get_working_kernel(
-                None,
-                machine.min_hwe_kernel,
-                machine.architecture,
-                osystem,
-                series,
-            )
-        except ValidationError:
+    try:
+        subarch = get_working_kernel(
+            subarch,
+            machine.min_hwe_kernel,
+            machine.architecture,
+            osystem,
+            series,
+        )
+    except ValidationError:
+        # In case the kernel for that particular subarch
+        # was not found, and no specific kernel was requested,
+        # try our best to find a suitable one
+        if not subarch_override:
+            try:
+                subarch = get_working_kernel(
+                    None,
+                    machine.min_hwe_kernel,
+                    machine.architecture,
+                    osystem,
+                    series,
+                )
+            except ValidationError:
+                subarch = "no-such-kernel"
+        else:
             subarch = "no-such-kernel"
+
     return osystem, series, subarch
 
 

Follow ups