Skip to content

Why do controller call addServiceBinding() twice? #1588

@ncoolz

Description

@ncoolz

In agent.go, I found that controller.addServiceBinding() function is called from addServiceInfoToCluster() and from handleEpTableEvent().

(487th line)

if err := c.addServiceBinding(ep.svcName, ep.svcID, n.ID(), ep.ID(), ep.virtualIP, ingressPorts, ep.svcAliases, ep.Iface().Address().IP); err != nil {
				return err
			}

(689th)

	if err := c.addServiceBinding(svcName, svcID, nid, eid, vip, ingressPorts, aliases, ip); err != nil {
		logrus.Errorf("Failed adding service binding for value %s: %v", value, err)
		return
	}

I know that handleEpTableEvent() should be called after addServiceInfoToCluster(), because addServiceInfoToCluster() creates entry into "endpoint_table" and then an event handler calls handleEpTableEvent().

So, because of the above code, you can see always log that addServiceBinding() is called twice whenever you create services as below.

Dec 08 11:47:45 host abc[81511]: time="2016-12-08T11:47:45.972911850+09:00" level=debug msg="This message is that I added into addServiceBinding()."
Dec 08 11:47:45 host abc[81511]: time="2016-12-08T11:47:45.979237425+09:00" level=debug msg="Programming external connectivity on endpoint qwerty.1.eu6r6gsfg9dfah3q8lc25cnh1 (7660997f6b869c2b21fee2cb658f5ad8caac1a765861b8eb06b3c058283a24c5)"
Dec 08 11:47:45 host abc[81511]: time="2016-12-08T11:47:45.979760300+09:00" level=debug msg="This message is that I added into addServiceBinding()."

It looks a duplicate work. I don't understand why the controller works like this. Is there any need for it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions