Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/307 Fix replace_config to read prom2teams config #316

Merged
merged 7 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog).

## [Unreleased](https://github.com/idealista/prom2teams/tree/develop)
## [4.2.1](https://github.com/idealista/prom2teams/tree/4.2.1)
[Full Changelog](https://github.com/idealista/prom2teams/compare/4.2.0...4.2.1)
### Fixed
- *[#307](https://github.com/idealista/prom2teams/pull/307) Update prom2teams replace_config with exception control* @santi-eidu
## [4.2.0](https://github.com/idealista/prom2teams/tree/4.2.0)
[Full Changelog](https://github.com/idealista/prom2teams/compare/4.1.0...4.2.0)
### Added
Expand Down
15 changes: 10 additions & 5 deletions docker/rootfs/replace_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
filedata = filedata.replace("prom2teamsgroupalertsby", os.environ.get("PROM2TEAMS_GROUP_ALERTS_BY"))
filedata = filedata.replace("prom2teamslogslevel", os.environ.get("PROM2TEAMS_LOGLEVEL"))

with open('/opt/prom2teams/config.ini', 'w') as file:
file.write(filedata)
try:
with open('/opt/prom2teams/config.ini', 'w') as file:
file.write(filedata)
except (PermissionError, OSError) as error:
pass

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you bypassing error handling ? If there is actual error, why we ignore it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to tmp config files in case of config file from docker volume.


with open('/opt/prom2teams/uwsgi.ini', 'r') as file:
uwsgi_filedata = file.read()
Expand All @@ -22,6 +25,8 @@
uwsgi_filedata = uwsgi_filedata.replace("uwsgihost", os.environ.get("UWSGI_HOST"))
uwsgi_filedata = uwsgi_filedata.replace("uwsgiprotocol", os.environ.get("UWSGI_PROTOCOL"))


with open('/opt/prom2teams/uwsgi.ini', 'w') as file:
file.write(uwsgi_filedata)
try:
with open('/opt/prom2teams/uwsgi.ini', 'w') as file:
file.write(uwsgi_filedata)
except (PermissionError, OSError) as error:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same same here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to tmp config files in case of config file from docker volume.

pass