Uploaded image for project: 'jclouds'
  1. jclouds
  2. JCLOUDS-1351

AWS CentOS marketplace AMI misdetecting OS type

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.1.0, 2.0.3
    • Component/s: jclouds-compute
    • Labels:

      Description

      When jclouds encounters an official CentOS Linux AMI from the AWS Marketplace, it detects the operating system as "unrecognized".

      To reproduce, set the jclouds.ec2.ami-query / jclouds.ec2.cc-ami-query properties to search the AWS Marketplace for CentOS images. Example: owner-id=679593333241;state=available;image-type=machine;root-device-type=ebs;architecture=x86_64;virtualization-type=hvm;name=CentOS Linux *

      jclouds will discover from AWS AMIs such as this one:

      <item>
          <imageId>ami-061b1560</imageId>
          <imageLocation>aws-marketplace/CentOS Linux 7 x86_64 HVM EBS 1704_01-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-d52f5bc3.4</imageLocation>
          <imageState>available</imageState>
          <imageOwnerId>679593333241</imageOwnerId>
          <isPublic>true</isPublic>
          <productCodes>
              <item>
                  <productCode>aw0evgkw8e5c1q413zgy5pjce</productCode>
                  <type>marketplace</type>
              </item>
          </productCodes>
          <architecture>x86_64</architecture>
          <imageType>machine</imageType>
          <imageOwnerAlias>aws-marketplace</imageOwnerAlias>
          <name>CentOS Linux 7 x86_64 HVM EBS 1704_01-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-d52f5bc3.4</name>
          <description>CentOS Linux 7 x86_64 HVM EBS 1704_01</description>
          <rootDeviceType>ebs</rootDeviceType>
          <rootDeviceName>/dev/sda1</rootDeviceName>
          <blockDeviceMapping>
              <item>
                  <deviceName>/dev/sda1</deviceName>
                  <ebs>
                      <snapshotId>snap-00f18f3f6413c7879</snapshotId>
                      <volumeSize>8</volumeSize>
                      <deleteOnTermination>false</deleteOnTermination>
                  </ebs>
              </item>
          </blockDeviceMapping>
          <virtualizationType>hvm</virtualizationType>
          <hypervisor>xen</hypervisor>
      </item>
      

      While parsing this, execution will end up here: https://github.com/jclouds/jclouds/blob/574c7fc3c1234037608c8daf96375673265e904f/compute/src/main/java/org/jclouds/compute/util/ComputeServiceUtils.java#L141

         public static org.jclouds.compute.domain.OsFamily parseOsFamilyOrUnrecognized(String in) {
            org.jclouds.compute.domain.OsFamily myOs = null;
            for (org.jclouds.compute.domain.OsFamily os : org.jclouds.compute.domain.OsFamily.values()) {
               if (in.toLowerCase().replaceAll("\\s", "").indexOf(os.toString()) != -1) {
                  myOs = os;
               }
            }
            return myOs != null ? myOs : OsFamily.UNRECOGNIZED;
         }
      

      This enumerates over the known OS names to see if there's a match in the AMI name. The string CentOS Linux 7 x86_64 HVM EBS 1704_01-b7ee8a69-ee97-4a49-9e68-afaee216db2e-ami-d52f5bc3.4 contains matches two enum values: CENTOS and LINUX. It seems that the alphabetically-last value is the one that is selected, so that this method returns LINUX and not CENTOS.

        Activity

        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 4dbba815caa77ad44d7e8d75fde1692a6810d862 in jclouds's branch refs/heads/2.0.x from Richard Downer
        [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=4dbba81 ]

        JCLOUDS-1351: improve OS Family parsing

        Modifies OsFamily to have two tiers of known OSes, so that generic OS
        names such as “Linux” cannot end up taking priority over more specific
        OS names. This fixes the case where “CentOS Linux” was detected as LINUX
        and not CENTOS.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 4dbba815caa77ad44d7e8d75fde1692a6810d862 in jclouds's branch refs/heads/2.0.x from Richard Downer [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=4dbba81 ] JCLOUDS-1351 : improve OS Family parsing Modifies OsFamily to have two tiers of known OSes, so that generic OS names such as “Linux” cannot end up taking priority over more specific OS names. This fixes the case where “CentOS Linux” was detected as LINUX and not CENTOS.
        Hide
        jira-bot ASF subversion and git services added a comment -

        Commit 045f1e952709117444fd7d06145d9a487db56e30 in jclouds's branch refs/heads/master from Richard Downer
        [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=045f1e9 ]

        JCLOUDS-1351: improve OS Family parsing

        Modifies OsFamily to have two tiers of known OSes, so that generic OS
        names such as “Linux” cannot end up taking priority over more specific
        OS names. This fixes the case where “CentOS Linux” was detected as LINUX
        and not CENTOS.

        Show
        jira-bot ASF subversion and git services added a comment - Commit 045f1e952709117444fd7d06145d9a487db56e30 in jclouds's branch refs/heads/master from Richard Downer [ https://git-wip-us.apache.org/repos/asf?p=jclouds.git;h=045f1e9 ] JCLOUDS-1351 : improve OS Family parsing Modifies OsFamily to have two tiers of known OSes, so that generic OS names such as “Linux” cannot end up taking priority over more specific OS names. This fixes the case where “CentOS Linux” was detected as LINUX and not CENTOS.
        Hide
        rdowner Richard Downer added a comment -

        I've made a PR which should fix this issue, and other issues that were blocking the correct use of these AMIs: https://github.com/jclouds/jclouds/pull/1153

        Show
        rdowner Richard Downer added a comment - I've made a PR which should fix this issue, and other issues that were blocking the correct use of these AMIs: https://github.com/jclouds/jclouds/pull/1153

          People

          • Assignee:
            Unassigned
            Reporter:
            rdowner Richard Downer
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development