From c4554ccd81b7d04401478704a43158769473472b Mon Sep 17 00:00:00 2001 From: Nicolas Haller Date: Tue, 27 Nov 2018 15:13:16 -0500 Subject: [PATCH] Add DEBIAN_FRONTEND=noninteractive in front of apt-get install commands The goal is to avoid a failure of apt-get install if one of the packages tries to ask questions. Story: #2004468 Task: #28158 Change-Id: I258d5c904c29110ccdb3a7fdff5b69f489552063 --- sahara/plugins/images.py | 2 +- sahara/tests/unit/plugins/test_images.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sahara/plugins/images.py b/sahara/plugins/images.py index 27654a47db..94719316f5 100644 --- a/sahara/plugins/images.py +++ b/sahara/plugins/images.py @@ -551,7 +551,7 @@ class SaharaPackageValidator(SaharaImageValidatorBase): def _apt_install(self, remote): install_cmd = ( - "apt-get -y install %s" % + "DEBIAN_FRONTEND=noninteractive apt-get -y install %s" % " ".join(str(package) for package in self.packages)) return _sudo(remote, install_cmd) diff --git a/sahara/tests/unit/plugins/test_images.py b/sahara/tests/unit/plugins/test_images.py index 2e93e4432d..90a6fb571c 100644 --- a/sahara/tests/unit/plugins/test_images.py +++ b/sahara/tests/unit/plugins/test_images.py @@ -262,9 +262,9 @@ class TestImages(b.SaharaTestCase): except p_ex.ImageValidationError as e: self.assertIn("So bad!", e.message) self.assertEqual(remote.execute_command.call_count, 2) - calls = [mock.call("dpkg -s java-8 hadoop", - run_as_root=True), - mock.call("apt-get -y install java-8 hadoop", + calls = [mock.call("dpkg -s java-8 hadoop", run_as_root=True), + mock.call("DEBIAN_FRONTEND=noninteractive " + + "apt-get -y install java-8 hadoop", run_as_root=True)] remote.execute_command.assert_has_calls(calls)