Skip to content

Commit 74eef7e

Browse files
authored
Merge pull request #1445 from sanimej/revertlb
Revert "Add sandbox API for task insertion to service LB and service discovery"
2 parents 2bf9f28 + 44f6be4 commit 74eef7e

4 files changed

Lines changed: 6 additions & 60 deletions

File tree

endpoint.go

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ type endpoint struct {
7474
ingressPorts []*PortConfig
7575
dbIndex uint64
7676
dbExists bool
77-
serviceEnabled bool
7877
sync.Mutex
7978
}
8079

@@ -304,24 +303,6 @@ func (ep *endpoint) isAnonymous() bool {
304303
return ep.anonymous
305304
}
306305

307-
// CompareAndSwap ep's serviceEnabled. If its in oldState, set it to newState
308-
// and return true. If its not in oldState return false
309-
func (ep *endpoint) casServiceEnabled(oldState, newState bool) bool {
310-
ep.Lock()
311-
defer ep.Unlock()
312-
if ep.serviceEnabled == oldState {
313-
ep.serviceEnabled = newState
314-
return true
315-
}
316-
return false
317-
}
318-
319-
func (ep *endpoint) setServiceEnabled(state bool) {
320-
ep.Lock()
321-
defer ep.Unlock()
322-
ep.serviceEnabled = state
323-
}
324-
325306
func (ep *endpoint) needResolver() bool {
326307
ep.Lock()
327308
defer ep.Unlock()
@@ -519,6 +500,10 @@ func (ep *endpoint) sbJoin(sb *sandbox, options ...EndpointOption) error {
519500
return err
520501
}
521502

503+
if e := ep.addToCluster(); e != nil {
504+
log.Errorf("Could not update state for endpoint %s into cluster: %v", ep.Name(), e)
505+
}
506+
522507
if sb.needDefaultGW() && sb.getEndpointInGWNetwork() == nil {
523508
return sb.setupDefaultGW()
524509
}

libnetwork_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,14 +1216,6 @@ func (f *fakeSandbox) Endpoints() []libnetwork.Endpoint {
12161216
return nil
12171217
}
12181218

1219-
func (f *fakeSandbox) EnableService() error {
1220-
return nil
1221-
}
1222-
1223-
func (f *fakeSandbox) DisableService() error {
1224-
return nil
1225-
}
1226-
12271219
func TestExternalKey(t *testing.T) {
12281220
externalKeyTest(t, false)
12291221
}

networkdb/networkdb.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,9 @@ func (nDB *NetworkDB) getEntry(tname, nid, key string) (*entry, error) {
203203
// table, key) tuple and if the NetworkDB is part of the cluster
204204
// propogates this event to the cluster. It is an error to create an
205205
// entry for the same tuple for which there is already an existing
206-
// entry unless the current entry is deleting state.
206+
// entry.
207207
func (nDB *NetworkDB) CreateEntry(tname, nid, key string, value []byte) error {
208-
e, _ := nDB.getEntry(tname, nid, key)
209-
if e != nil && !e.deleting {
208+
if _, err := nDB.GetEntry(tname, nid, key); err == nil {
210209
return fmt.Errorf("cannot create entry as the entry in table %s with network id %s and key %s already exists", tname, nid, key)
211210
}
212211

sandbox.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ type Sandbox interface {
5050
ResolveService(name string) ([]*net.SRV, []net.IP, error)
5151
// Endpoints returns all the endpoints connected to the sandbox
5252
Endpoints() []Endpoint
53-
// EnableService makes a managed container's service available by adding the
54-
// endpoint to the service load balancer and service discovery
55-
EnableService() error
56-
// DisableService removes a managed contianer's endpoints from the load balancer
57-
// and service discovery
58-
DisableService() error
5953
}
6054

6155
// SandboxOption is an option setter function type used to pass various options to
@@ -728,30 +722,6 @@ func (sb *sandbox) SetKey(basePath string) error {
728722
return nil
729723
}
730724

731-
func (sb *sandbox) EnableService() error {
732-
for _, ep := range sb.getConnectedEndpoints() {
733-
if ep.casServiceEnabled(false, true) {
734-
if e := ep.addToCluster(); e != nil {
735-
ep.setServiceEnabled(false)
736-
return fmt.Errorf("could not update state for endpoint %s into cluster: %v", ep.Name(), e)
737-
}
738-
}
739-
}
740-
return nil
741-
}
742-
743-
func (sb *sandbox) DisableService() error {
744-
for _, ep := range sb.getConnectedEndpoints() {
745-
if ep.casServiceEnabled(true, false) {
746-
if e := ep.deleteFromCluster(); e != nil {
747-
ep.setServiceEnabled(true)
748-
return fmt.Errorf("could not delete state for endpoint %s from cluster: %v", ep.Name(), e)
749-
}
750-
}
751-
}
752-
return nil
753-
}
754-
755725
func releaseOSSboxResources(osSbox osl.Sandbox, ep *endpoint) {
756726
for _, i := range osSbox.Info().Interfaces() {
757727
// Only remove the interfaces owned by this endpoint from the sandbox.

0 commit comments

Comments
 (0)