Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
zmarano committed Sep 16, 2019
2 parents 6ac2a57 + 900e29c commit 741e0d4
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 44 deletions.
4 changes: 2 additions & 2 deletions packages/google-compute-engine/packaging/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
google-compute-engine (1:20190911.00-g1) stable; urgency=medium
google-compute-engine (1:20190916.00-g1) stable; urgency=medium

* Bump version to match python package release.

-- Google Cloud Team <gc-team@google.com> Thu, 11 Sep 2019 10:39:08 -0700
-- Google Cloud Team <gc-team@google.com> Mon, 16 Sep 2019 15:51:24 -0700

google-compute-engine (1:20190905.00-g1) stable; urgency=medium

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/google-compute-engine/packaging/setup_deb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

NAME="google-compute-engine"
VERSION="20190911.00"
VERSION="20190916.00"

working_dir=${PWD}
if [[ $(basename "$working_dir") != $NAME ]]; then
Expand Down
2 changes: 1 addition & 1 deletion packages/google-compute-engine/packaging/setup_rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

NAME="google-compute-engine"
VERSION="20190911.00"
VERSION="20190916.00"

rpm_working_dir=/tmp/rpmpackage/${NAME}-${VERSION}
working_dir=${PWD}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand All @@ -64,23 +63,21 @@ 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)
self.network_setup = network_setup.NetworkSetup(
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):
self.logger.info('Starting Google Networking daemon.')
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))
Expand All @@ -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]
Expand All @@ -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().split('.')[0] != result['hostname'].split('.')[0]:
self.distro_utils.RestartNetworking(self.logger)

def _ExtractInterfaceMetadata(self, metadata):
"""Extracts network interface metadata.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
python-google-compute-engine (1:20190911.00-g1) stable; urgency=medium
python-google-compute-engine (1:20190916.00-g1) stable; urgency=medium

* Fix network restart bug when detecting hostname change.
* Revert VM rename feature.

-- Google Cloud Team <gc-team@google.com> Thu, 11 Sep 2019 10:40:11 -0700
-- Google Cloud Team <gc-team@google.com> Mon, 16 Sep 2019 15:52:24 -0700

python-google-compute-engine (1:20190905.00-g1) stable; urgency=medium

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

NAME="python-google-compute-engine"
VERSION="20190911.00"
VERSION="20190916.00"

working_dir=${PWD}
if [[ $(basename "$working_dir") != $NAME ]]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

NAME="python-google-compute-engine"
VERSION="20190911.00"
VERSION="20190916.00"

rpm_working_dir=/tmp/rpmpackage/${NAME}-${VERSION}
working_dir=${PWD}
Expand Down
2 changes: 1 addition & 1 deletion packages/python-google-compute-engine/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
name='google-compute-engine',
packages=setuptools.find_packages(),
url='https://github.com/GoogleCloudPlatform/compute-image-packages',
version='20190911.0',
version='20190916.0',
# Entry points create scripts in /usr/bin that call a function.
entry_points={
'console_scripts': [
Expand Down

0 comments on commit 741e0d4

Please sign in to comment.