Skip to content

Commit

Permalink
Merge pull request #1594 from flanksource/find-correct-component-pers…
Browse files Browse the repository at this point in the history
…istence

fix: filter components by agent when persisting them
  • Loading branch information
moshloop authored Jan 18, 2024
2 parents bc5aeef + f21681d commit 2e4a494
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/db/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func DeleteInlineCanariesForComponent(db *gorm.DB, componentID string) error {
}

func GetActiveComponentsIDsOfTopology(db *gorm.DB, topologyID string) (compIDs []uuid.UUID, err error) {
if err := db.Table("components").Where("deleted_at is NULL and topology_id = ?", topologyID).Select("id").Find(&compIDs).Error; err != nil {
if err := db.Table("components").Where("deleted_at is NULL AND topology_id = ?", topologyID).Select("id").Find(&compIDs).Error; err != nil {
return nil, err
}
return
Expand Down
2 changes: 1 addition & 1 deletion pkg/system_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ type Component struct {

func (component *Component) FindExisting(db *gorm.DB) (*models.Component, error) {
var existing models.Component
tx := db.Model(component).Select("id", "deleted_at")
tx := db.Model(component).Select("id", "deleted_at").Where("agent_id = ?", uuid.Nil)
if component.ID == uuid.Nil {
if component.ParentId == nil {
tx = tx.Find(&existing, "name = ? AND type = ? and parent_id is NULL", component.Name, component.Type)
Expand Down

0 comments on commit 2e4a494

Please sign in to comment.