InstancePoller compares wrong Address list and always requests updated state Addresses

Bug #1454043 reported by John A Meinel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
juju-core
Fix Released
High
Tim Penhey
1.22
Fix Released
Critical
Tim Penhey
1.23
Fix Released
High
Tim Penhey
1.24
Fix Released
High
Tim Penhey

Bug Description

The Transaction log is full of entries that look like:

{ "_id": ObjectId("553deadbeef"), "n": "deadbeef",
 "o": [ {
   "c": "machines",
   "d": "6",
   "a": {
      "addresses": [
 {"value": "abcd.foo.com", "addresstype": "hostname", "networkscope": "public" },
    {"value": "abcd.foo.com", "addresstype": "hostname", "networkscope": "local-cloud" },
        ],
      "life": {"$ne": 2}
   }} ],
 "s": 2
}

However, that is simply asserting that the values in the DB are the values we currently have.
If we want a transaction, then it *should* just be setting the values to the
values we have rather than Asserting them. (SetAddresses is always going to be the official arbiter of what the addresses should be now).

Looking at this code:
  https://github.com/juju/juju/blob/1.20/state/machine.go#L986

It would look like we are only asserting notDeadDoc, but not asserting anything
about the value of addresses. But that doesn't appear to be what is in the
content of the database TXN collection.
I actually would offer that at most we should Refresh the object, and then
in-memory assert the addresses haven't changed, and in the changed=false case
we shouldn't be calling m.st.run() at all.

See also https://bugs.launchpad.net/juju-core/+bug/1454059 which is about other Transactions that seem to be filling up the txn collection.

Revision history for this message
John A Meinel (jameinel) wrote :

Note that https://github.com/juju/juju/blob/juju-1.20.11/state/machine.go#L973 still seems to have the same code path for SetAddresses, so we still need to figure out where this assert is comming from.

John A Meinel (jameinel)
description: updated
Revision history for this message
John A Meinel (jameinel) wrote :

So looking at: https://github.com/juju/juju/blob/juju-1.20.11/worker/instancepoller/updater.go#L264 it looks like instance poller is trying to not call SetAddresses if the addresses haven't changed.

However the bug appears to be that Machine.Addresses() is returning the union of cloud addresses and machine addresses, while SetAddresses is only updating the former.
https://github.com/juju/juju/blob/juju-1.20.11/state/machine.go#L940

Thus every loop on the instance poller is seeing that the addresses don't exactly match, so tries to force the update, which then does nothing because the cloud side of the address list already matches.

The big problem is that SetAddresses() and Addresses() do not round trip data, which breaks developer's models of how this works.

We could potentially rename the functions SetCloudAddresses (vs SetMachineAddresses), and Addresses() continues to return all addresses but we add a CloudAddresses() (ProviderAddresses?) function to retrieve just the values we are about to set.

Ante Karamatić (ivoks)
tags: added: cpec
Frank Mueller (themue)
tags: added: network
removed: cpec
Jonathan Davies (jpds)
tags: added: cpec
John A Meinel (jameinel)
summary: - Machine.SetAddresses should not generate transactions for noop changes
+ InstancePoller compares wrong Address list and always requests updated
+ state Addresses
Tim Penhey (thumper)
Changed in juju-core:
assignee: nobody → Tim Penhey (thumper)
assignee: Tim Penhey (thumper) → nobody
Tim Penhey (thumper)
Changed in juju-core:
assignee: nobody → Tim Penhey (thumper)
status: Triaged → In Progress
milestone: none → 1.25.0
Tim Penhey (thumper)
Changed in juju-core:
status: In Progress → Fix Committed
Curtis Hovey (sinzui)
Changed in juju-core:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.