Support log for ansible-disaster-recovery #43
Conversation
c0de7a2
to
9ddb99a
Compare
|
Why not do it inside |
0c72857
to
13591f1
Compare
build.sh
Outdated
| @@ -6,12 +6,14 @@ RPM_RELEASE="0.1.$MILESTONE.$(date -u +%Y%m%d%H%M%S)" | |||
|
|
|||
| ROLE_NAME="oVirt.disaster-recovery" | |||
| PACKAGE_NAME="ovirt-ansible-disaster-recovery" | |||
| PREFIX=/usr/local | |||
| LOG_NAME="ovirt-dr" | |||
| PPREFIX=/usr/local | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why it's renamed to PPREFIX? I think it's typo, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ohh damn, you are right, will fix
build.sh
Outdated
|
|
||
| cp -pR defaults/ $PKG_DATA_DIR | ||
| cp -pR library/ $PKG_DATA_DIR | ||
| cp -pR meta/ $PKG_DATA_DIR | ||
| cp -pR tasks/ $PKG_DATA_DIR | ||
| cp -pR examples/ $PKG_DATA_DIR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We store examples in /usr/share/doc for other roles, jut FYI, if you want to have it also in /usr/share/ you can, up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would want to use the ansible play there in the script, that is why I'm copying it.
I will try to copy only the play without the entire example folder.
Let me know if you have a better idea
34c8c50
to
ff101d5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the DR RPM should create directory /var/log/ovirt-dr/. Like follows:
install -d /var/log/ovirt-dr -m 755and in spec file:
%dir /var/log/ovirt-drThen the DR script should always create file disaster-recovery-{timestamp} in /var/log/ovirt-dr directory. Maybe configure logrotate for it? Depends how often it will be used. Or if you think it's better to use single log file and append to it, I am OK with it, but be sure it's simple for users to understand the log, where which part starts/ends.
If you follow your current way don't forget to add %ghost %log_file_path to spec file, and verify it's OK with rpm --verify command.
50630b7
to
9af6fc3
Compare
build.sh
Outdated
| @@ -6,12 +6,14 @@ RPM_RELEASE="0.1.$MILESTONE.$(date -u +%Y%m%d%H%M%S)" | |||
|
|
|||
| ROLE_NAME="oVirt.disaster-recovery" | |||
| PACKAGE_NAME="ovirt-ansible-disaster-recovery" | |||
| LOG_NAME="ovirt-dr" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are going to put logs into /var/log/ovirt-dr then please provide logrotate setup similarly as we do in engine:
https://github.com/oVirt/ovirt-engine/blob/master/packaging/sys-etc/logrotate.d/ovirt-engine.in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the file,
please let me know if there is anything more that should be addressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You also need to add dependency to logrotate, replace relative paths inside it (please take a look at GENERATED list and its usage in engine Makefile [1]) and install it into /etc/logrotate.d [2].
[1] https://github.com/oVirt/ovirt-engine/blob/master/Makefile#L211
[2] https://github.com/oVirt/ovirt-engine/blob/master/ovirt-engine.spec.in#L990
3e0b864
to
8ba4e48
Compare
|
Why do we need to add %dir /var/log/ovirt-dr in the spec file? If I add it the build fails, since it refers '/var/log/ovirt-dr' as a relative path, see below: |
6800434
to
c0b737c
Compare
logrotate.d/ovirt-dr.in
Outdated
| @@ -0,0 +1,8 @@ | |||
| "@PKG_LOG_DIR/LOG_NAME@/ovirt-dr.log" { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where are you replacing @PKG_LOG_DIR/LOG_NAME@ with /var/log/ovirt-dr? Also why is there only single log file? Where are you going to log multiple concurrent invocations of a role from single machine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is what I've defined in the spec, I will try to do that with '/var/log/ovirt-dr'
I've tried to follow how ovirt-engine works, should I do it like this:
"/var/log/ovirt-dr"/*.log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok if the file is located here: logrotate.d/ovirt-dr.in
| @@ -26,10 +26,12 @@ This Ansible role provide funtionality to perform disaster recovery for oVirt en | |||
| export PKG_DATA_DIR_ORIG=%{_datadir}/%{ansible_roles_dir}/%{roleprefix}%{rolename} | |||
| export PKG_DATA_DIR=%{buildroot}$PKG_DATA_DIR_ORIG | |||
| export PKG_DOC_DIR=%{buildroot}%{_pkgdocdir} | |||
| install -dm 755 "$PKG_LOG_DIR/$LOG_NAME/$LOG_NAME.log" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add Requires: logrotate spec file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I add it like this
Requires: logrotate.d/ovirt-dr.in
or is that enough:
Requires: logrotate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to use Requires: logrotate, logrotate is a package name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking of it, I think the best approach for DR would be to have --log-file and --log-level command line options, instead of persistent log directory maybe it will be even more simple. But I will leave this decision on you.
e28823e
to
3ea00d7
Compare
|
Changed the log to be compatible with your suggestion: I haven't understood how would you want me to use the callback plugins. [1] |
712bb4f
to
9b0f64b
Compare
build.sh
Outdated
| @@ -44,6 +44,7 @@ install() { | |||
| cp -pR library/ $PKG_DATA_DIR | |||
| cp -pR meta/ $PKG_DATA_DIR | |||
| cp -pR tasks/ $PKG_DATA_DIR | |||
| cp examples/dr_play.yml $PKG_DATA_DIR | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have this in doc directory already, isn't it enought? Or why is it needed also in usr/share?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted the user to be able to also change this.
It is good that this will be in the doc directory so the user will be able to see that as an example.
For the user to use that as part of the scripts I thought it will be more appropriate to be copied to the DATA_DIR directory so the user will be able to manipulate it.
If you think it is redundant I can remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in /usr/share so his changes will be overriten by update anyway. So the correct use case is to copy the file from doc to some of his directory or /etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that to keep it simple we can also use the dr_play from the examples.
So I will just change the dr.conf to point to the example dr_play which is in the doc directory
examples/dr_play.yml
Outdated
| @@ -3,4 +3,4 @@ | |||
| hosts: localhost | |||
| connection: local | |||
| roles: | |||
| - oVirt.disaster-recovery | |||
| - ovirt-ansible-disaster-recovery | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use oVirt.disaster-recovery
files/dr.conf
Outdated
| [generate_vars] | ||
| site=http://engine.example.com/ovirt-engine/api | ||
| site=http://localhost:8080/ovirt-engine/api |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use engine.example.com
files/fail_over.py
Outdated
| FailOver().run('dr.conf', '/var/log/ovirt-dr/ovirt-dr.log') | ||
| level = logging.getLevelName("DEBUG") | ||
| conf = 'dr.conf' | ||
| log = '/var/log/ovirt-dr/ovirt-dr.log' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This directory don't exist so it should be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will only be used for testing or if the user will try to run that script directly instead through the ovirt-dr script (which initialize the log file)
I can change this to be /tmp if you think it is neccessery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not, but anyone other testing it, will fail, because he won't have that directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code in fail-over should create that directory if it doesn't exists.
but to keep it simple I will change it to /tmp
9379082
to
317eb02
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please rebase before merging
Change dr-play location in dr.conf and change vault location
Using attribute 'ExtendedInterpolation' is not compatible for
configparser.
If it is being used from RHEL 7.4 the following exception
is being thrown:
Traceback (most recent call last):
File "./ovirt-dr", line 145, in <module>
main(sys.argv[1:])
File "./ovirt-dr", line 28, in main
action, conf_file, log_file, log_level = _init_vars(argv)
File "./ovirt-dr", line 88, in _init_vars
log_file, log_level = _get_log_conf(conf_file, log_file, log_level)
File "./ovirt-dr", line 101, in _get_log_conf
settings._interpolation = configparser.ExtendedInterpolation()
AttributeError: 'module' object has no attribute 'ExtendedInterpolation'
Therefore to make the code compatible for RHEL as well, instead of
using configparser, we use SafeConfigParser from ConfigParser.
Configure the report file name to be passed as an argument when running the ovirt_dr script on failover and failback.
317eb02
to
6b27501
Compare
The script default location and level is configured in the dr.conf
Default location is /var/log/ovirt-dr/ovirt-dr.log and default level is "DEBUG"
The user can override it with --log-file and --log-level
If no log file will be specified stdout will be used to print the output.