apache / apache/libcloud

Improper lock usage leads to inode overflow in LockLocalStorage implementation

Đang mở
#1,975 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
2.1k
Fork
931
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
4

Mô tả

## Summary

Behaviour of [fasteners.InterProcessLock](https://github.com/harlowja/fasteners/blob/06c3f06cab4e135b8d921932019a231c180eb9f4/fasteners/process_lock.py#L114) is pretty weird: class creates a lockfile by provided path, if it doesn't exist, but not manage to remove it after lock is released.

It may lead to **uncontrolled lockfiles spam** in `/tmp` folder just because libcloud local driver is not removing [this lockfile](https://github.com/apache/libcloud/blob/trunk/libcloud/storage/drivers/local.py#L85) either.

## Detailed Information

This issue encountered in cassandra-medusa `v0.15` and lower, which was using `apache-libcloud<3.4.0,>=3.3.0` as a dependency.

Please see https://github.com/thelastpickle/cassandra-medusa/issues/528 for more details.

---

Seems like the lightweight fix is to run

```python
with contextlib.suppress(FileNotFoundError):
os.remove(filename)
```

just right in the [exit method](https://github.com/apache/libcloud/blob/trunk/libcloud/storage/drivers/local.py#L114).

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu tại libcloud/storage/drivers/local.py, ở phương thức exit của driver cục bộ, và xem xét cách tên tệp khóa được xử lý sau khi InterProcessLock giải phóng khóa đó. Xác nhận hành vi bằng một bài kiểm thử tập trung hoặc một bản tái hiện, sau đó kiểm tra rằng các tệp khóa đã được giải phóng không còn bị bỏ lại trong /tmp mà không ảnh hưởng đến việc dọn dẹp các tệp bị thiếu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
cloud
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.