Merge lp:~mpontillo/maas/signal-handlers-add-logging--bug-1685963 into lp:~maas-committers/maas/trunk

Proposed by Mike Pontillo
Status: Merged
Approved by: Mike Pontillo
Approved revision: no longer in the source branch.
Merged at revision: 6016
Proposed branch: lp:~mpontillo/maas/signal-handlers-add-logging--bug-1685963
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 157 lines (+39/-16)
1 file modified
src/maasserver/models/signals/interfaces.py (+39/-16)
To merge this branch: bzr merge lp:~mpontillo/maas/signal-handlers-add-logging--bug-1685963
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+323094@code.launchpad.net

Commit message

Adds messages to regiond.log about interface changes due to Django signal handlers.

Description of the change

Note: these logs should already be covered by existing tests. This is debug logging, (so that we can get additional information to solve related bugs) so I don't feel it's worth the effort to test the messages themselves.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good. Nice messages.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (2.0 MiB)

The attempt to merge lp:~mpontillo/maas/signal-handlers-add-logging--bug-1685963 into lp:maas failed. Below is the output from the failed tests.

Hit:1 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Fetched 306 kB in 0s (634 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind avahi-utils bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libnss-wrapper libpq-dev make nodejs-legacy npm postgresql psmisc pxelinux python3-all python3-apt python3-attr python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~rc+dfsg-1ubuntu2).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1build1).
pxelinux is already the newest version (3:6.03+dfsg-11ubuntu1).
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0....

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (1.9 MiB)

The attempt to merge lp:~mpontillo/maas/signal-handlers-add-logging--bug-1685963 into lp:maas failed. Below is the output from the failed tests.

Hit:1 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:2 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Fetched 306 kB in 0s (582 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind avahi-utils bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libnss-wrapper libpq-dev make nodejs-legacy npm postgresql psmisc pxelinux python3-all python3-apt python3-attr python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~rc+dfsg-1ubuntu2).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
psmisc is already the newest version (22.21-2.1build1).
pxelinux is already the newest version (3:6.03+dfsg-11ubuntu1).
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0....

Revision history for this message
Mike Pontillo (mpontillo) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models/signals/interfaces.py'
2--- src/maasserver/models/signals/interfaces.py 2016-09-08 19:32:10 +0000
3+++ src/maasserver/models/signals/interfaces.py 2017-04-25 18:11:41 +0000
4@@ -35,6 +35,7 @@
5 )
6 from maasserver.models.staticipaddress import StaticIPAddress
7 from maasserver.utils.signals import SignalsManager
8+from provisioningserver.logger import LegacyLogger
9
10
11 INTERFACE_CLASSES = [
12@@ -48,6 +49,8 @@
13
14 signals = SignalsManager()
15
16+log = LegacyLogger()
17+
18
19 def interface_enabled_or_disabled(instance, old_values, **kwargs):
20 """When an interface is enabled be sure at minimum a LINK_UP is created.
21@@ -56,11 +59,15 @@
22 if instance.type != INTERFACE_TYPE.PHYSICAL:
23 return
24 if instance.is_enabled():
25+ log.msg("%s: Physical interface enabled; ensuring link-up." % (
26+ instance.get_log_string()))
27 # Make sure it has a LINK_UP link, and for its children.
28 instance.ensure_link_up()
29 for rel in instance.children_relationships.all():
30 rel.child.ensure_link_up()
31 else:
32+ log.msg("%s: Physical interface disabled; removing links." % (
33+ instance.get_log_string()))
34 # Was disabled. Remove the links.
35 for ip_address in instance.ip_addresses.exclude(
36 alloc_type=IPADDRESS_TYPE.DISCOVERED):
37@@ -80,6 +87,13 @@
38 klass, ['enabled'], delete=False)
39
40
41+def _update_mtu(interface, mtu, instance):
42+ log.msg("%s: MTU updated to %d (for consistency with %s)." % (
43+ interface.get_log_string(), mtu, instance.get_log_string()))
44+ interface.params['mtu'] = mtu
45+ interface.save()
46+
47+
48 def interface_mtu_params_update(instance, old_values, **kwargs):
49 """When an interfaces MTU is changed we need to do two things.
50
51@@ -104,7 +118,7 @@
52 # Update the children before the parents. Because calling update on the
53 # parent will call save on all the children again.
54
55- # If the children have a larger MTU than the parent, we update the childs
56+ # If the children have a larger MTU than the parent, we update the child's
57 # MTU to be the same size as the parents. If the child doesn't have MTU
58 # set then it is ignored.
59 for rel in instance.children_relationships.all():
60@@ -112,11 +126,10 @@
61 if child.params and 'mtu' in child.params:
62 child_mtu = child.params['mtu']
63 if child_mtu > new_mtu:
64- child.params['mtu'] = new_mtu
65- child.save()
66+ _update_mtu(child, new_mtu, instance)
67
68- # Update the parents MTU to either be the same size of the childs MTU or
69- # larger than the childs MTU.
70+ # Update the parents MTU to either be the same size of the child's MTU or
71+ # larger than the child's MTU.
72 for parent in instance.parents.all():
73 if parent.params:
74 parent_mtu = parent.params.get('mtu', None)
75@@ -124,18 +137,16 @@
76 if parent_mtu < new_mtu:
77 # Parent MTU is to small, make it bigger for the
78 # child interface.
79- parent.params['mtu'] = new_mtu
80- parent.save()
81+ _update_mtu(parent, new_mtu, instance)
82 else:
83- # Parent doesn't have MTU set. Set it to the childs
84+ # Parent doesn't have MTU set. Set it to the child's
85 # MTU value.
86- parent.params['mtu'] = new_mtu
87- parent.save()
88+ _update_mtu(parent, new_mtu, instance)
89 else:
90 # Parent has not parameters at all. Create the parameters
91 # object and set the MTU to the size of the child.
92- parent.params = {'mtu': new_mtu}
93- parent.save()
94+ parent.params = {}
95+ _update_mtu(parent, new_mtu, instance)
96
97
98 for klass in INTERFACE_CLASSES:
99@@ -167,6 +178,9 @@
100 try:
101 parent.vlan = instance.vlan
102 parent.save()
103+ log.msg("%s: VLAN updated to match %s (vlan=%s)." % (
104+ parent.get_log_string(), instance.get_log_string(),
105+ parent.vlan_id))
106 finally:
107 visiting.discard(parent.id)
108
109@@ -209,7 +223,11 @@
110 if ip_address.subnet is not None:
111 ip_address.subnet.vlan = new_vlan
112 ip_address.subnet.save()
113-
114+ log.msg(
115+ "%s: IP address [%s] subnet %s: "
116+ "VLAN updated (vlan=%s)." % (
117+ instance.get_log_string(), ip_address.ip,
118+ ip_address.subnet.cidr, ip_address.subnet.vlan_id))
119 # If any children are VLAN interfaces then we need to move those
120 # VLANs into the same fabric as the parent.
121 for rel in instance.children_relationships.all():
122@@ -220,12 +238,16 @@
123 rel.child.save()
124 # No need to update the IP addresses here this function
125 # will be called again because the child has been saved.
126-
127+ log.msg("%s: updated fabric on %s to %s (vlan=%s)" % (
128+ instance.get_log_string(), rel.child.get_log_string(),
129+ new_vlan.fabric.name, rel.child.vlan_id))
130 else:
131 # Interface VLAN was changed on a machine or device. Remove all its
132 # links except the DISCOVERED ones.
133 instance.ip_addresses.exclude(
134 alloc_type=IPADDRESS_TYPE.DISCOVERED).delete()
135+ log.msg("%s: deleted IP addresses due to VLAN update (%s -> %s)." % (
136+ instance.get_log_string(), old_vlan_id, new_vlan_id))
137
138
139 for klass in INTERFACE_CLASSES:
140@@ -242,6 +264,8 @@
141 if len(rel.child.parents.all()) == 1:
142 # Last parent of the child, so delete the child.
143 rel.child.delete()
144+ log.msg("%s has been deleted; orphaned by %s." % (
145+ rel.child.get_log_string(), instance.get_log_string()))
146
147
148 for klass in INTERFACE_CLASSES:
149@@ -265,8 +289,7 @@
150 # Remove its link to the interface before the interface
151 # is deleted.
152 if ip_address.alloc_type != IPADDRESS_TYPE.DISCOVERED:
153- instance.unlink_ip_address(
154- ip_address, clearing_config=True)
155+ instance.unlink_ip_address(ip_address, clearing_config=True)
156 else:
157 ip_address.delete()
158