Skip to content

Commit

Permalink
little refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: Viktor Kramarenko <[email protected]>
  • Loading branch information
ViktorKram committed Aug 29, 2024
1 parent 2af3028 commit 82bd50e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions images/agent/src/pkg/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (c *Cache) AddLV(vgName, lvName string) {
}
}

func (c *Cache) RemoveLV(vgName, lvName string) {
func (c *Cache) MarkLVAsRemoved(vgName, lvName string) {
c.m.Lock()
defer c.m.Unlock()

Expand Down Expand Up @@ -172,11 +172,10 @@ func (c *Cache) PrintTheCache(log logger.Logger) {
log.Cache(c.vgsErrs.String())
log.Cache("[VGs ENDS]")
log.Cache("[LVs BEGIN]")
c.m.RLock()
for _, lv := range c.lvs {
log.Cache(fmt.Sprintf(" Data Name: %s, VG name: %s, size: %s, tags: %s, attr: %s, pool: %s", lv.Data.LVName, lv.Data.VGName, lv.Data.LVSize.String(), lv.Data.LvTags, lv.Data.LVAttr, lv.Data.PoolName))
lvs, _ := c.GetLVs()
for _, lv := range lvs {
log.Cache(fmt.Sprintf(" Data Name: %s, VG name: %s, size: %s, tags: %s, attr: %s, pool: %s", lv.LVName, lv.VGName, lv.LVSize.String(), lv.LvTags, lv.LVAttr, lv.PoolName))
}
c.m.RUnlock()
log.Cache("[ERRS]")
log.Cache(c.lvsErrs.String())
log.Cache("[LVs ENDS]")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ func deleteLVIfNeeded(log logger.Logger, sdsCache *cache.Cache, vgName string, l
return err
}

log.Debug(fmt.Sprintf("[deleteLVIfNeeded] removes LV %s from the cache", lv.Data.LVName))
sdsCache.RemoveLV(lv.Data.VGName, lv.Data.LVName)
log.Debug(fmt.Sprintf("[deleteLVIfNeeded] mark LV %s in the cache as removed", lv.Data.LVName))
sdsCache.MarkLVAsRemoved(lv.Data.VGName, lv.Data.LVName)

return nil
}
Expand Down

0 comments on commit 82bd50e

Please sign in to comment.