Merge "Normalise format of OVN agent heartbeat timestamp" into stable/zed
This commit is contained in:
commit
1bf8d3340e
|
@ -81,7 +81,8 @@ class NeutronAgent(abc.ABC):
|
||||||
return {
|
return {
|
||||||
'binary': self.binary,
|
'binary': self.binary,
|
||||||
'host': self.chassis.hostname,
|
'host': self.chassis.hostname,
|
||||||
'heartbeat_timestamp': self.updated_at,
|
'heartbeat_timestamp': timeutils.normalize_time(
|
||||||
|
self.updated_at.replace(microsecond=0)),
|
||||||
'availability_zone': ', '.join(
|
'availability_zone': ', '.join(
|
||||||
ovn_utils.get_chassis_availability_zones(self.chassis)),
|
ovn_utils.get_chassis_availability_zones(self.chassis)),
|
||||||
'topic': 'n/a',
|
'topic': 'n/a',
|
||||||
|
|
|
@ -1148,7 +1148,7 @@ class TestAgentApi(base.TestOVNFunctionalBase):
|
||||||
'Chassis_Private', self.chassis, 'nb_cfg_timestamp'
|
'Chassis_Private', self.chassis, 'nb_cfg_timestamp'
|
||||||
).execute(check_error=True)
|
).execute(check_error=True)
|
||||||
updated_at = datetime.datetime.fromtimestamp(
|
updated_at = datetime.datetime.fromtimestamp(
|
||||||
int(chassis_ts / 1000), datetime.timezone.utc)
|
int(chassis_ts / 1000))
|
||||||
# if table Chassis_Private present, agent.updated_at is
|
# if table Chassis_Private present, agent.updated_at is
|
||||||
# Chassis_Private.nb_cfg_timestamp
|
# Chassis_Private.nb_cfg_timestamp
|
||||||
self.assertEqual(updated_at, heartbeat_timestamp)
|
self.assertEqual(updated_at, heartbeat_timestamp)
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import datetime
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
|
@ -67,3 +68,19 @@ class AgentCacheTestCase(base.BaseTestCase):
|
||||||
agents = list(agents)
|
agents = list(agents)
|
||||||
self.assertEqual(1, len(agents))
|
self.assertEqual(1, len(agents))
|
||||||
self.assertEqual('chassis5', agents[0].agent_id)
|
self.assertEqual('chassis5', agents[0].agent_id)
|
||||||
|
|
||||||
|
@mock.patch.object(neutron_agent.ControllerAgent, 'alive')
|
||||||
|
def test_heartbeat_timestamp_format(self, agent_alive):
|
||||||
|
chassis_private = fakes.FakeOvsdbRow.create_one_ovsdb_row(
|
||||||
|
attrs={'name': 'chassis5'})
|
||||||
|
agents = self.agent_cache.agents_by_chassis_private(chassis_private)
|
||||||
|
agent = list(agents)[0]
|
||||||
|
agent.chassis.hostname = 'fake-hostname'
|
||||||
|
agent.updated_at = datetime.datetime(
|
||||||
|
year=2023, month=2, day=23, hour=1, minute=2, second=3,
|
||||||
|
microsecond=456789).replace(tzinfo=datetime.timezone.utc)
|
||||||
|
agent_alive.return_value = True
|
||||||
|
|
||||||
|
# Verify that both microseconds and timezone are dropped
|
||||||
|
self.assertEqual(str(agent.as_dict()['heartbeat_timestamp']),
|
||||||
|
'2023-02-23 01:02:03')
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Normalise OVN agent heartbeat timestamp format to match other agent types.
|
||||||
|
This fixes parsing of ``GET /v2.0/agents`` for some clients, such as
|
||||||
|
gophercloud.
|
Loading…
Reference in New Issue