Skip to content

Commit

Permalink
fix(service): adjust when device discovery runs
Browse files Browse the repository at this point in the history
Want device discovery to run at service startup only when there are no blades and hosts.  However, don't want the presence of empty appliances to block the discovery code from running.  Code needs to check the blade map lengths directly to see if there are any blades present.
  • Loading branch information
scott-howe-1 committed Dec 17, 2024
1 parent a49451a commit e61a0b2
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cmd/cfm-service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,20 @@ func main() {
data := datastore.DStore().GetDataStore()

// Check if there are any devices in the data store
bladeExist := len(data.ApplianceData) != 0
hostExist := len(data.HostData) != 0
hostsExist := len(data.HostData) != 0
appliancesExist := len(data.ApplianceData) != 0
bladesExist := false
if appliancesExist {
for _, applianceDatum := range data.ApplianceData {
bladesExist = len(applianceDatum.BladeData) != 0
if bladesExist {
break
}
}
}

// If there are no devices in the data store, do discovery, otherwise skip
if !bladeExist && !hostExist {
if !bladesExist && !hostsExist {
// Discover devices before loading datastore
bladeDevices, errBlade := services.DiscoverDevices(ctx, defaultApiService, "blade")
hostDevices, errHost := services.DiscoverDevices(ctx, defaultApiService, "cxl-host")
Expand Down

0 comments on commit e61a0b2

Please sign in to comment.