From e08ad7a48ad960e9be7c1044d3b3118bdf6a07e1 Mon Sep 17 00:00:00 2001 From: Liam Hopkins Date: Tue, 10 Sep 2019 15:51:37 -0700 Subject: [PATCH 1/4] google-startup-scripts run before apt-daily on systemd systems (#841) --- .../src/lib/systemd/system/google-startup-scripts.service | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/google-compute-engine/src/lib/systemd/system/google-startup-scripts.service b/packages/google-compute-engine/src/lib/systemd/system/google-startup-scripts.service index 233298a8..c1506937 100644 --- a/packages/google-compute-engine/src/lib/systemd/system/google-startup-scripts.service +++ b/packages/google-compute-engine/src/lib/systemd/system/google-startup-scripts.service @@ -2,6 +2,7 @@ Description=Google Compute Engine Startup Scripts After=network-online.target network.target rsyslog.service After=google-instance-setup.service google-network-daemon.service +Before=apt-daily.service [Service] ExecStart=/usr/bin/google_metadata_script_runner --script-type startup From f334621c13b04d2a331bb531b8cb3ea6992eb93f Mon Sep 17 00:00:00 2001 From: Liam Hopkins Date: Mon, 16 Sep 2019 15:44:51 -0700 Subject: [PATCH 2/4] rollback VM rename feature (#850) --- .../networking/network_daemon.py | 12 ++------ .../networking/tests/network_daemon_test.py | 30 +++++++------------ 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py b/packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py index 5a791cc3..5bc55ce4 100644 --- a/packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py +++ b/packages/python-google-compute-engine/google_compute_engine/networking/network_daemon.py @@ -30,7 +30,6 @@ from google_compute_engine import logger from google_compute_engine import metadata_watcher from google_compute_engine import network_utils -from google_compute_engine.compat import distro_utils from google_compute_engine.networking.ip_forwarding import ip_forwarding from google_compute_engine.networking.network_setup import network_setup @@ -40,7 +39,7 @@ class NetworkDaemon(object): """Manage networking based on changes to network metadata.""" - instance_metadata_key = 'instance/' + network_interface_metadata_key = 'instance/network-interfaces' def __init__( self, ip_forwarding_enabled, proto_id, ip_aliases, target_instance_ips, @@ -64,7 +63,6 @@ def __init__( self.ip_forwarding_enabled = ip_forwarding_enabled self.network_setup_enabled = network_setup_enabled self.target_instance_ips = target_instance_ips - self.dhclient_script = dhclient_script self.ip_forwarding = ip_forwarding.IpForwarding( proto_id=proto_id, debug=debug) @@ -72,7 +70,6 @@ def __init__( dhclient_script=dhclient_script, dhcp_command=dhcp_command, debug=debug) self.network_utils = network_utils.NetworkUtils(logger=self.logger) self.watcher = metadata_watcher.MetadataWatcher(logger=self.logger) - self.distro_utils = distro_utils.Utils(debug=debug) try: with file_utils.LockFile(LOCKFILE): @@ -80,7 +77,7 @@ def __init__( timeout = 60 + random.randint(0, 30) self.watcher.WatchMetadata( self.HandleNetworkInterfaces, - metadata_key=self.instance_metadata_key, recursive=True, + metadata_key=self.network_interface_metadata_key, recursive=True, timeout=timeout) except (IOError, OSError) as e: self.logger.warning(str(e)) @@ -91,8 +88,7 @@ def HandleNetworkInterfaces(self, result): Args: result: dict, the metadata response with the network interfaces. """ - network_interfaces = self._ExtractInterfaceMetadata( - result['networkInterfaces']) + network_interfaces = self._ExtractInterfaceMetadata(result) if self.network_setup_enabled: default_interface = network_interfaces[0] @@ -107,8 +103,6 @@ def HandleNetworkInterfaces(self, result): for interface in network_interfaces: self.ip_forwarding.HandleForwardedIps( interface.name, interface.forwarded_ips, interface.ip) - if socket.gethostname() != result['hostname'].split('.')[0]: - self.distro_utils.RestartNetworking(self.logger) def _ExtractInterfaceMetadata(self, metadata): """Extracts network interface metadata. diff --git a/packages/python-google-compute-engine/google_compute_engine/networking/tests/network_daemon_test.py b/packages/python-google-compute-engine/google_compute_engine/networking/tests/network_daemon_test.py index 2c3640a1..9216ea37 100644 --- a/packages/python-google-compute-engine/google_compute_engine/networking/tests/network_daemon_test.py +++ b/packages/python-google-compute-engine/google_compute_engine/networking/tests/network_daemon_test.py @@ -54,7 +54,7 @@ def testNetworkDaemon( mocks.attach_mock(mock_ip_forwarding, 'forwarding') mocks.attach_mock(mock_network_setup, 'network_setup') mocks.attach_mock(mock_watcher, 'watcher') - metadata_key = network_daemon.NetworkDaemon.instance_metadata_key + metadata_key = network_daemon.NetworkDaemon.network_interface_metadata_key with mock.patch.object( network_daemon.NetworkDaemon, 'HandleNetworkInterfaces' @@ -129,13 +129,11 @@ def testNetworkDaemonError( ] self.assertEqual(mocks.mock_calls, expected_calls) - @mock.patch('google_compute_engine.networking.network_daemon.distro_utils') - def testHandleNetworkInterfaces(self, mock_distro_utils): + def testHandleNetworkInterfaces(self): mocks = mock.Mock() mocks.attach_mock(self.mock_ip_forwarding, 'forwarding') mocks.attach_mock(self.mock_network_setup, 'network_setup') mocks.attach_mock(self.mock_setup, 'setup') - mocks.attach_mock(mock_distro_utils, 'distro_utils') self.mock_setup.ip_aliases = None self.mock_setup.target_instance_ips = None self.mock_setup.ip_forwarding_enabled = True @@ -145,19 +143,17 @@ def testHandleNetworkInterfaces(self, mock_distro_utils): 'eth0', forwarded_ips=['a'], ip='1.1.1.1', ipv6=False), network_daemon.NetworkDaemon.NetworkInterface('eth1'), ] - self.mock_setup.distro_utils = mock.MagicMock() - result = mock.MagicMock() + result = mock.Mock() network_daemon.NetworkDaemon.HandleNetworkInterfaces( self.mock_setup, result) expected_calls = [ - mock.call.setup._ExtractInterfaceMetadata(result['networkInterfaces']), + mock.call.setup._ExtractInterfaceMetadata(result), mock.call.network_setup.DisableIpv6(['eth0']), mock.call.network_setup.EnableNetworkInterfaces(['eth1']), mock.call.forwarding.HandleForwardedIps( 'eth0', ['a'], '1.1.1.1'), mock.call.forwarding.HandleForwardedIps('eth1', None, None), - mock.call.setup.distro_utils.RestartNetworking(self.mock_setup.logger), ] self.assertEqual(mocks.mock_calls, expected_calls) @@ -174,18 +170,16 @@ def testHandleNetworkInterfacesIpv6(self): network_daemon.NetworkDaemon.NetworkInterface( 'eth0', forwarded_ips=['a'], ip='1.1.1.1', ipv6=True), ] - self.mock_setup.distro_utils = mock.MagicMock() - result = mock.MagicMock() + result = mock.Mock() network_daemon.NetworkDaemon.HandleNetworkInterfaces( self.mock_setup, result) expected_calls = [ - mock.call.setup._ExtractInterfaceMetadata(result['networkInterfaces']), + mock.call.setup._ExtractInterfaceMetadata(result), mock.call.network_setup.EnableIpv6(['eth0']), mock.call.network_setup.EnableNetworkInterfaces([]), mock.call.forwarding.HandleForwardedIps( 'eth0', ['a'], '1.1.1.1'), - mock.call.setup.distro_utils.RestartNetworking(self.mock_setup.logger), ] self.assertEqual(mocks.mock_calls, expected_calls) @@ -202,18 +196,16 @@ def testHandleNetworkInterfacesIpv6Disabled(self): network_daemon.NetworkDaemon.NetworkInterface( 'eth0', forwarded_ips=['a'], ip='1.1.1.1', ipv6=False), ] - self.mock_setup.distro_utils = mock.MagicMock() - result = mock.MagicMock() + result = mock.Mock() network_daemon.NetworkDaemon.HandleNetworkInterfaces( self.mock_setup, result) expected_calls = [ - mock.call.setup._ExtractInterfaceMetadata(result['networkInterfaces']), + mock.call.setup._ExtractInterfaceMetadata(result), mock.call.network_setup.DisableIpv6(['eth0']), mock.call.network_setup.EnableNetworkInterfaces([]), mock.call.forwarding.HandleForwardedIps( 'eth0', ['a'], '1.1.1.1'), - mock.call.setup.distro_utils.RestartNetworking(self.mock_setup.logger), ] self.assertEqual(mocks.mock_calls, expected_calls) @@ -230,14 +222,12 @@ def testHandleNetworkInterfacesDisabled(self): network_daemon.NetworkDaemon.NetworkInterface('a'), network_daemon.NetworkDaemon.NetworkInterface('b'), ] - self.mock_setup.distro_utils = mock.MagicMock() - result = mock.MagicMock() + result = mock.Mock() network_daemon.NetworkDaemon.HandleNetworkInterfaces( self.mock_setup, result) expected_calls = [ - mock.call.setup._ExtractInterfaceMetadata(result['networkInterfaces']), - mock.call.setup.distro_utils.RestartNetworking(self.mock_setup.logger), + mock.call.setup._ExtractInterfaceMetadata(result), ] self.assertEqual(mocks.mock_calls, expected_calls) From 4dd53399757958295f2e813f27279d3651a02344 Mon Sep 17 00:00:00 2001 From: Zach Marano Date: Mon, 16 Sep 2019 15:57:55 -0700 Subject: [PATCH 3/4] Fix EL6 spec to not call systemctl and put that logic back in the EL7+ spec (#848) --- .../packaging/google-compute-engine-el6.spec | 5 ----- .../packaging/google-compute-engine.spec | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/google-compute-engine/packaging/google-compute-engine-el6.spec b/packages/google-compute-engine/packaging/google-compute-engine-el6.spec index 5555b204..ffa5c74c 100644 --- a/packages/google-compute-engine/packaging/google-compute-engine-el6.spec +++ b/packages/google-compute-engine/packaging/google-compute-engine-el6.spec @@ -60,11 +60,6 @@ ln -sf /usr/bin/google_set_hostname %{buildroot}/etc/dhcp/dhclient-exit-hooks %config /etc/sysctl.d/* %post -if [ $1 -eq 2 ]; then - # New service might not be enabled during upgrade. - systemctl enable google-network-daemon.service -fi - # On upgrade run instance setup again to handle any new configs and restart # daemons. if [ $1 -eq 2 ]; then diff --git a/packages/google-compute-engine/packaging/google-compute-engine.spec b/packages/google-compute-engine/packaging/google-compute-engine.spec index 1ec37dca..3d0560e3 100644 --- a/packages/google-compute-engine/packaging/google-compute-engine.spec +++ b/packages/google-compute-engine/packaging/google-compute-engine.spec @@ -66,6 +66,11 @@ cp -a src/lib/udev/rules.d/* %{buildroot}/%{_udevrulesdir} %config /etc/sysctl.d/* %post +if [ $1 -eq 2 ]; then + # New service might not be enabled during upgrade. + systemctl enable google-network-daemon.service +fi + # On upgrade run instance setup again to handle any new configs and restart # daemons. if [ $1 -eq 2 ]; then From 900e29c2a0e2d7eec016a112aa5f734e7dc19ffe Mon Sep 17 00:00:00 2001 From: Zach Marano Date: Mon, 16 Sep 2019 16:02:06 -0700 Subject: [PATCH 4/4] Bump versions. (#851) --- packages/google-compute-engine/packaging/debian/changelog | 6 ++++++ packages/google-compute-engine/packaging/setup_deb.sh | 2 +- packages/google-compute-engine/packaging/setup_rpm.sh | 2 +- .../python-google-compute-engine/packaging/debian/changelog | 6 ++++++ .../python-google-compute-engine/packaging/setup_deb.sh | 2 +- .../python-google-compute-engine/packaging/setup_rpm.sh | 2 +- packages/python-google-compute-engine/setup.py | 2 +- 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/google-compute-engine/packaging/debian/changelog b/packages/google-compute-engine/packaging/debian/changelog index c9ce87bd..81262c93 100644 --- a/packages/google-compute-engine/packaging/debian/changelog +++ b/packages/google-compute-engine/packaging/debian/changelog @@ -1,3 +1,9 @@ +google-compute-engine (1:20190916.00-g1) stable; urgency=medium + + * Bump version to match python package release. + + -- Google Cloud Team Mon, 16 Sep 2019 15:51:24 -0700 + google-compute-engine (1:20190905.00-g1) stable; urgency=medium * Bump version to match python package release. diff --git a/packages/google-compute-engine/packaging/setup_deb.sh b/packages/google-compute-engine/packaging/setup_deb.sh index 06e5f82e..66c2f30f 100755 --- a/packages/google-compute-engine/packaging/setup_deb.sh +++ b/packages/google-compute-engine/packaging/setup_deb.sh @@ -14,7 +14,7 @@ # limitations under the License. NAME="google-compute-engine" -VERSION="20190905.00" +VERSION="20190916.00" working_dir=${PWD} if [[ $(basename "$working_dir") != $NAME ]]; then diff --git a/packages/google-compute-engine/packaging/setup_rpm.sh b/packages/google-compute-engine/packaging/setup_rpm.sh index 28065e24..b0590e2e 100755 --- a/packages/google-compute-engine/packaging/setup_rpm.sh +++ b/packages/google-compute-engine/packaging/setup_rpm.sh @@ -14,7 +14,7 @@ # limitations under the License. NAME="google-compute-engine" -VERSION="20190905.00" +VERSION="20190916.00" rpm_working_dir=/tmp/rpmpackage/${NAME}-${VERSION} working_dir=${PWD} diff --git a/packages/python-google-compute-engine/packaging/debian/changelog b/packages/python-google-compute-engine/packaging/debian/changelog index ebf225a6..edf3f0c1 100644 --- a/packages/python-google-compute-engine/packaging/debian/changelog +++ b/packages/python-google-compute-engine/packaging/debian/changelog @@ -1,3 +1,9 @@ +python-google-compute-engine (1:20190916.00-g1) stable; urgency=medium + + * Revert VM rename feature. + + -- Google Cloud Team Mon, 16 Sep 2019 15:52:24 -0700 + python-google-compute-engine (1:20190905.00-g1) stable; urgency=medium * Fix setup.py version to be compliant with legacy builds. diff --git a/packages/python-google-compute-engine/packaging/setup_deb.sh b/packages/python-google-compute-engine/packaging/setup_deb.sh index ed321c8e..1b64ba76 100755 --- a/packages/python-google-compute-engine/packaging/setup_deb.sh +++ b/packages/python-google-compute-engine/packaging/setup_deb.sh @@ -14,7 +14,7 @@ # limitations under the License. NAME="python-google-compute-engine" -VERSION="20190905.00" +VERSION="20190916.00" working_dir=${PWD} if [[ $(basename "$working_dir") != $NAME ]]; then diff --git a/packages/python-google-compute-engine/packaging/setup_rpm.sh b/packages/python-google-compute-engine/packaging/setup_rpm.sh index 8d5e05d9..acd617c9 100755 --- a/packages/python-google-compute-engine/packaging/setup_rpm.sh +++ b/packages/python-google-compute-engine/packaging/setup_rpm.sh @@ -14,7 +14,7 @@ # limitations under the License. NAME="python-google-compute-engine" -VERSION="20190905.00" +VERSION="20190916.00" rpm_working_dir=/tmp/rpmpackage/${NAME}-${VERSION} working_dir=${PWD} diff --git a/packages/python-google-compute-engine/setup.py b/packages/python-google-compute-engine/setup.py index 5722ab03..c8900f93 100755 --- a/packages/python-google-compute-engine/setup.py +++ b/packages/python-google-compute-engine/setup.py @@ -37,7 +37,7 @@ name='google-compute-engine', packages=setuptools.find_packages(), url='https://github.com/GoogleCloudPlatform/compute-image-packages', - version='20190905.0', + version='20190916.0', # Entry points create scripts in /usr/bin that call a function. entry_points={ 'console_scripts': [