Merge "Provide zone args for acloud create to help TF host allocating resources."
diff --git a/internal/lib/android_compute_client.py b/internal/lib/android_compute_client.py
index 7c01d11..fbcb6a0 100755
--- a/internal/lib/android_compute_client.py
+++ b/internal/lib/android_compute_client.py
@@ -78,6 +78,8 @@
         self._ssh_public_key_path = acloud_config.ssh_public_key_path
         self._launch_args = acloud_config.launch_args
         self._instance_name_pattern = acloud_config.instance_name_pattern
+        # Store error log folder to pass to the end.
+        self._error_log_folder = None
         self._AddPerInstanceSshkey()
 
     # TODO(147047953): New args to contorl zone metrics check.
@@ -409,3 +411,8 @@
         """
         return super(AndroidComputeClient, self).GetSerialPortOutput(
             instance, zone or self._zone, port)
+
+    @property
+    def error_log_folder(self):
+        """Return error log folder"""
+        return self._error_log_folder
diff --git a/internal/lib/cvd_compute_client_multi_stage.py b/internal/lib/cvd_compute_client_multi_stage.py
index 78d99d7..811b568 100644
--- a/internal/lib/cvd_compute_client_multi_stage.py
+++ b/internal/lib/cvd_compute_client_multi_stage.py
@@ -408,8 +408,8 @@
             instance: String, instance name.
         """
         log_files = pull.GetAllLogFilePaths(self._ssh)
-        download_folder = pull.GetDownloadLogFolder(instance)
-        pull.PullLogs(self._ssh, log_files, download_folder)
+        self._error_log_folder = pull.GetDownloadLogFolder(instance)
+        pull.PullLogs(self._ssh, log_files, self._error_log_folder)
 
     @utils.TimeExecute(function_description="Reusing GCE instance")
     def _ReusingGceInstance(self, avd_spec):
diff --git a/internal/lib/utils.py b/internal/lib/utils.py
index 3adacde..6060c88 100755
--- a/internal/lib/utils.py
+++ b/internal/lib/utils.py
@@ -1207,6 +1207,9 @@
 def IsSupportedPlatform(print_warning=False):
     """Check if user's os is the supported platform.
 
+    platform.version() return such as '#1 SMP Debian 5.6.14-1rodete2...'
+    and use to judge supported or not.
+
     Args:
         print_warning: Boolean, print the unsupported warning
                        if True.
@@ -1214,17 +1217,19 @@
         Boolean, True if user is using supported platform.
     """
     system = platform.system()
-    # TODO(b/143197659): linux_distribution() deprecated in python 3. To fix it
-    # try to use another package "import distro".
-    dist = platform.linux_distribution()[0]
-    platform_supported = (system in _SUPPORTED_SYSTEMS_AND_DISTS and
-                          dist in _SUPPORTED_SYSTEMS_AND_DISTS[system])
+    # TODO(b/161085678): After python3 fully migrated, then use distro to fix.
+    platform_supported = False
+    if system in _SUPPORTED_SYSTEMS_AND_DISTS:
+        for dist in _SUPPORTED_SYSTEMS_AND_DISTS[system]:
+            if dist in platform.version():
+                platform_supported = True
+                break
 
     logger.info("Updated supported system and dists: %s",
                 _SUPPORTED_SYSTEMS_AND_DISTS)
     platform_supported_msg = ("%s[%s] %s supported platform" %
                               (system,
-                               dist,
+                               platform.version(),
                                "is a" if platform_supported else "is not a"))
     if print_warning and not platform_supported:
         PrintColorString(platform_supported_msg, TextColors.WARNING)
diff --git a/public/acloud_main.py b/public/acloud_main.py
index b3133a1..4fa1644 100644
--- a/public/acloud_main.py
+++ b/public/acloud_main.py
@@ -143,6 +143,12 @@
 CMD_CREATE_CUTTLEFISH = "create_cf"
 CMD_CREATE_GOLDFISH = "create_gf"
 
+# show contact info to user.
+_CONTACT_INFO = ("If you have any question or need acloud team support, "
+                 "please feel free to contact us by email at "
+                 "buganizer-system+419709@google.com")
+_LOG_INFO = " and attach those log files from %s"
+
 
 # pylint: disable=too-many-statements
 def _ParseArgs(args):
@@ -427,7 +433,11 @@
         report.Dump(args.report_file)
     if report and report.errors:
         error_msg = "\n".join(report.errors)
-        sys.stderr.write("Encountered the following errors:\n%s\n" % error_msg)
+        help_msg = _CONTACT_INFO
+        if report.data.get("error_log_folder"):
+            help_msg += _LOG_INFO % report.data.get("error_log_folder")
+        sys.stderr.write("Encountered the following errors:\n%s\n\n%s.\n" %
+                         (error_msg, help_msg))
         return constants.EXIT_BY_FAIL_REPORT, error_msg
     return constants.EXIT_SUCCESS, NO_ERROR_MESSAGE
 
diff --git a/public/actions/common_operations.py b/public/actions/common_operations.py
index 3aa014a..a11677f 100644
--- a/public/actions/common_operations.py
+++ b/public/actions/common_operations.py
@@ -126,6 +126,16 @@
                 failures[device.instance_name] = e
         return failures
 
+    def SetErrorLogFolder(self, reporter):
+        """Set error log folder.
+
+        Args:
+            reporter: Report object.
+        """
+        if self._compute_client.error_log_folder:
+            reporter.AddData(key="error_log_folder",
+                             value=self._compute_client.error_log_folder)
+
     def CollectSerialPortLogs(self, output_file,
                               port=constants.DEFAULT_SERIAL_PORT):
         """Tar the instance serial logs into specified output_file.
@@ -211,6 +221,7 @@
             failures = device_factory.GetFailures()
 
         if failures:
+            device_pool.SetErrorLogFolder(reporter)
             reporter.SetStatus(report.Status.BOOT_FAIL)
         else:
             reporter.SetStatus(report.Status.SUCCESS)