@@ -423,26 +423,30 @@ func ServiceProviderUpdateHandler(w http.ResponseWriter, r *http.Request, vars m
423
423
424
424
provider := mastercfg .ProviderDb [providerDbID ]
425
425
if provider == nil {
426
- log .Errorf ("Provider not present in Provider DB. Invalid state" )
426
+ // It is not a provider . Ignore event
427
+ return nil , nil
427
428
}
429
+
428
430
for _ , serviceID := range provider .Services {
429
431
service := mastercfg .ServiceLBDb [serviceID ]
430
432
providerID := getProviderID (provider )
431
433
if providerID == "" {
432
- return nil , fmt .Errorf ("Invalid ProviderID from providerInfp :{%v}" , provider )
434
+ return nil , fmt .Errorf ("Invalid ProviderID from providerInfo :{%v}" , provider )
433
435
}
434
- delete (service .Providers , providerID )
435
-
436
- serviceLbState := & mastercfg.CfgServiceLBState {}
437
- serviceLbState .StateDriver = stateDriver
438
- err = serviceLbState .Read (serviceID )
439
- if err != nil {
440
- return nil , err
436
+ if service .Providers [providerID ] != nil {
437
+ delete (service .Providers , providerID )
438
+
439
+ serviceLbState := & mastercfg.CfgServiceLBState {}
440
+ serviceLbState .StateDriver = stateDriver
441
+ err = serviceLbState .Read (serviceID )
442
+ if err != nil {
443
+ return nil , err
444
+ }
445
+ delete (serviceLbState .Providers , providerID )
446
+ serviceLbState .Write ()
447
+ delete (mastercfg .ProviderDb , providerDbID )
448
+ SvcProviderUpdate (serviceID , false )
441
449
}
442
- delete (serviceLbState .Providers , providerID )
443
- serviceLbState .Write ()
444
- delete (mastercfg .ProviderDb , providerDbID )
445
- SvcProviderUpdate (serviceID , false )
446
450
}
447
451
448
452
}
0 commit comments