@@ -422,9 +422,10 @@ func handleEvents(netPlugin *plugin.NetPlugin, opts cliOpts) error {
422
422
423
423
go handleSvcProviderUpdEvents (netPlugin , opts , recvErr )
424
424
425
- docker , _ := dockerclient .NewDockerClient ("unix:///var/run/docker.sock" , nil )
426
- go docker .StartMonitorEvents (handleDockerEvents , recvErr , netPlugin , recvErr )
427
-
425
+ if opts .pluginMode == "docker" {
426
+ docker , _ := dockerclient .NewDockerClient ("unix:///var/run/docker.sock" , nil )
427
+ go docker .StartMonitorEvents (handleDockerEvents , recvErr , netPlugin , recvErr )
428
+ }
428
429
err := <- recvErr
429
430
if err != nil {
430
431
log .Errorf ("Failure occured. Error: %s" , err )
@@ -777,7 +778,10 @@ func handleDockerEvents(event *dockerclient.Event, ec chan error, args ...interf
777
778
return
778
779
}
779
780
containerTenant := getTenantFromContainerInspect (& containerInfo )
780
- network , ipAddress := getEpNetworkInfoFromContainerInspect (& containerInfo )
781
+ network , ipAddress , err := getEpNetworkInfoFromContainerInspect (& containerInfo )
782
+ if err != nil {
783
+ log .Errorf ("Error getting container network info for %v.Err:%s" , event .ID , err )
784
+ }
781
785
container := getContainerFromContainerInspect (& containerInfo )
782
786
if ipAddress != "" {
783
787
//Create provider info
@@ -799,7 +803,7 @@ func handleDockerEvents(event *dockerclient.Event, ec chan error, args ...interf
799
803
800
804
log .Infof ("Sending Provider create request to master: {%+v}" , providerUpdReq )
801
805
802
- err : = cluster .MasterPostReq ("/plugin/svcProviderUpdate" , providerUpdReq , & svcProvResp )
806
+ err = cluster .MasterPostReq ("/plugin/svcProviderUpdate" , providerUpdReq , & svcProvResp )
803
807
if err != nil {
804
808
log .Errorf ("Event: 'start' , Http error posting service provider update, Error:%s" , err )
805
809
}
@@ -841,21 +845,27 @@ func getTenantFromContainerInspect(containerInfo *types.ContainerJSON) string {
841
845
}
842
846
843
847
/*getEpNetworkInfoFromContainerInspect inspects the network info from containerinfo returned by dockerclient*/
844
- func getEpNetworkInfoFromContainerInspect (containerInfo * types.ContainerJSON ) (string , string ) {
848
+ func getEpNetworkInfoFromContainerInspect (containerInfo * types.ContainerJSON ) (string , string , error ) {
845
849
var networkName string
846
850
var IPAddress string
847
-
851
+ var networkUUID string
848
852
if containerInfo != nil && containerInfo .NetworkSettings != nil {
849
- for network , endpoint := range containerInfo .NetworkSettings .Networks {
850
- networkName = network
851
- if strings .Contains (network , "/" ) {
852
- //network name is of the form networkname/tenantname for non default tenant
853
- networkName = strings .Split (network , "/" )[0 ]
854
- }
853
+ for _ , endpoint := range containerInfo .NetworkSettings .Networks {
855
854
IPAddress = endpoint .IPAddress
855
+ networkUUID = endpoint .NetworkID
856
+ _ , network , serviceName , err := dockplugin .GetDockerNetworkName (networkUUID )
857
+ if err != nil {
858
+ log .Errorf ("Error getting docker networkname for network uuid : %s" , networkUUID )
859
+ return "" , "" , err
860
+ }
861
+ if serviceName != "" {
862
+ networkName = serviceName
863
+ } else {
864
+ networkName = network
865
+ }
856
866
}
857
867
}
858
- return networkName , IPAddress
868
+ return networkName , IPAddress , nil
859
869
}
860
870
861
871
func getContainerFromContainerInspect (containerInfo * types.ContainerJSON ) string {
0 commit comments