Skip to content

src/ceph-crash.in: use an iterator when looping on the crash dir - #53711

Closed
leseb wants to merge 1 commit into
ceph:mainfrom
leseb:ceph-crash-dict-iter
Closed

leseb wants to merge 1 commit into
ceph:mainfrom
leseb:ceph-crash-dict-iter

Conversation

@leseb

@leseb leseb commented Sep 28, 2023 •

Copy link
Copy Markdown
Contributor

os.listdir(path) could potentially change if files are added or removed from the directory while the loop is running, leading to unexpected behavior, especially the following error:

dictionary changed size during iteration

Fix: https://tracker.ceph.com/issues/63016

Contribution Guidelines

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows

os.listdir(path) could potentially change if files are added or removed
from the directory while the loop is running, leading to unexpected
behavior, especially the following error:

```
dictionary changed size during iteration
```

Fix: https://tracker.ceph.com/issues/63016
Signed-off-by: Sébastien Han <[email protected]>
@guits

guits commented Sep 28, 2023

Copy link
Copy Markdown
Contributor

I might miss a detail but doesn't os.listdir() already return a list ?

In [5]: print(type(os.listdir()))
<class 'list'>

I might be wrong but afaik, I think it can't be changed during the loop execution. Even if a file gets added/removed meantime.
Any chance I can see the full python trace? (Unless I missed it, I couldn't find it from either the tracker or the linked rook issue)

@leseb

leseb commented Sep 28, 2023

Copy link
Copy Markdown
Contributor Author

After discussing with @guits it looks like the source of the error is in mgr/crash/module.py. So closing for further investigations.

@leseb leseb closed this Sep 28, 2023
@leseb
leseb deleted the ceph-crash-dict-iter branch September 28, 2023 12:23
@badone

badone commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

See #71994

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants