Skip to content

Commit

Permalink
Merge pull request #58 from OpenCHAMI/synackd/fix-disappearing-params
Browse files Browse the repository at this point in the history
Fix check for identical boot configs in postgres.Update function
  • Loading branch information
alexlovelltroy authored Jan 8, 2025
2 parents 45f42a5 + 658c9d2 commit 87e702f
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions internal/postgres/bootparams.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,23 +505,25 @@ func (bddb BootDataDatabase) getNodesWithConfigs(macs, xnames []string, nids []i
` FROM nodes AS n` +
` JOIN boot_group_assignments AS bga ON n.id=bga.node_id` +
` JOIN boot_groups AS bg ON bga.boot_group_id=bg.id` +
` JOIN boot_configs AS bc ON bg.boot_config_id=bc.id` +
` WHERE`
lengths := []int{len(macs), len(xnames), len(nids)}
for first, i := true, 0; i < len(lengths); i++ {
if lengths[i] > 0 {
if !first {
qstr += ` OR`
}
switch i {
case 0:
qstr += fmt.Sprintf(` boot_mac IN %s`, stringSliceToSql(macs))
case 1:
qstr += fmt.Sprintf(` xname IN %s`, stringSliceToSql(xnames))
case 2:
qstr += fmt.Sprintf(` nid IN %s`, int32SliceToSql(nids))
` JOIN boot_configs AS bc ON bg.boot_config_id=bc.id`
if len(macs) > 0 || len(xnames) > 0 || len(nids) > 0 {
qstr += ` WHERE`
lengths := []int{len(macs), len(xnames), len(nids)}
for first, i := true, 0; i < len(lengths); i++ {
if lengths[i] > 0 {
if !first {
qstr += ` OR`
}
switch i {
case 0:
qstr += fmt.Sprintf(` boot_mac IN %s`, stringSliceToSql(macs))
case 1:
qstr += fmt.Sprintf(` xname IN %s`, stringSliceToSql(xnames))
case 2:
qstr += fmt.Sprintf(` nid IN %s`, int32SliceToSql(nids))
}
first = false
}
first = false
}
}
qstr += `;`
Expand Down Expand Up @@ -1730,7 +1732,7 @@ func (bddb BootDataDatabase) Update(bp bssTypes.BootParams) (nodesUpdated []stri
// depending on them.
delBgbc := true
for _, n := range nList {
if _, ok := nToBgbc[n]; !ok {
if _, ok := nToBgbc[n]; ok {
delBgbc = false
break
}
Expand Down

0 comments on commit 87e702f

Please sign in to comment.