MDB-40234: added version to logs and metrics#105
Conversation
| try: | ||
| # Try to find package.release in the installation directory | ||
| version_file = '/opt/yandex/pgconsul/package.release' | ||
| if os.path.exists(version_file): |
There was a problem hiding this comment.
No need to check if file exists if you already have try..except
|
|
||
| db_state = _get_db_state(conf) | ||
| return {**db_state, **zk_state} | ||
| return {'version': __version__, **db_state, **zk_state} |
There was a problem hiding this comment.
And... it might be incorrect!
If you have updated package on a system, but didn't restart daemon, it will report newer version, while old one would be maintaining HA of a cluster.
I'd suggest to write daemon version into state file, and read it in cli utility.
And maybe even report versions of cli and daemon separately.
| Version management for pgconsul. | ||
| """ | ||
|
|
||
| STATE_FILE = '/tmp/pgconsul.state' |
There was a problem hiding this comment.
Why do we need to introduce another file, if we already have status file: https://github.com/yandex/pgconsul/blob/main/src/helpers.py#L242?
Let's just add a field to its json contents?
| | xargs sed -i -e 's|$(INSTALL_DIR)|/opt/yandex/pgconsul|' \ | ||
| || true | ||
| # Write version to package.release if VERSION is not "-" | ||
| test "$(VERSION)" != "-" && echo $(VERSION) > $(DESTDIR)/opt/yandex/pgconsul/package.release || true |
There was a problem hiding this comment.
| test "$(VERSION)" != "-" && echo $(VERSION) > $(DESTDIR)/opt/yandex/pgconsul/package.release || true | |
| test "$(VERSION)" != "-" && echo $(VERSION) > $(INSTALL_DIR)/package.release || true |
| """Initialize version: read from package.release file and return it""" | ||
| try: | ||
| # Try to find package.release in the installation directory | ||
| with open('/opt/yandex/pgconsul/package.release', 'r') as f: |
There was a problem hiding this comment.
It should not be a hardcoded final path here in Python code.
Final install path is defined in Makefile, and can be set to some other path, which Python module should adapt to.
I'd suggest to use a common Python method https://docs.python.org/3/library/importlib.resources.html to access this resource file, and install it to corresponding location.
|
Implemented outside the service |
|
we decided to simplify and rewrite the code |
No description provided.