Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Only display service information in pretty format
Browse files Browse the repository at this point in the history
  • Loading branch information
ants committed May 10, 2018
1 parent 06726b8 commit 6d848d9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
1 change: 1 addition & 0 deletions RPM/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
mkdir -p /root/rpmbuild/SOURCES
tar -czf /root/rpmbuild/SOURCES/patroni-customizations.tar.gz patroni.2.service patroni-watchdog.service postgres-telia.yml
cp *.patch /root/rpmbuild/SOURCES/
curl -L https://github.com/zalando/patroni/archive/v1.4.3.tar.gz -o /root/rpmbuild/SOURCES/patroni-1.4.3.tar.gz
rpmbuild -bb patroni.spec
mkdir -p rpms
Expand Down
7 changes: 6 additions & 1 deletion RPM/patroni.spec
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
%define debug_package %{nil}
Name: patroni
Version: 1.4.3
Release: 1.rhel7
Release: 2.rhel7
License: MIT
Summary: PostgreSQL high-availability manager
Source: patroni-1.4.3.tar.gz
Source1: patroni-customizations.tar.gz
Patch0: service-info-only-in-pretty-format.patch
BuildRoot: %{_tmppath}/%{buildprefix}-buildroot
Requires: /usr/bin/python2.7, python-psycopg2 >= 2.6.1, postgresql-server, libyaml
BuildRequires: prelink libyaml-devel gcc
Expand All @@ -20,6 +21,7 @@ Packaged version of Patroni HA manager.
%prep
%setup
%setup -D -T -a 1
%patch0 -p1

%build
# remove some things
Expand Down Expand Up @@ -79,6 +81,9 @@ rm -rf $RPM_BUILD_ROOT

%changelog

* Thu May 10 2018 Ants Aasma 1.4.3-2.rhel7
- Only display service info output in pretty format.

* Tue May 8 2018 Ants Aasma 1.4.3-1.rhel7
- Update to 1.4.3

Expand Down
40 changes: 40 additions & 0 deletions RPM/service-info-only-in-pretty-format.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/patroni/ctl.py b/patroni/ctl.py
index 7f97986..b85dfaf 100644
--- a/patroni/ctl.py
+++ b/patroni/ctl.py
@@ -713,20 +713,21 @@ def output_members(cluster, name, extended=False, fmt='pretty'):

print_output(columns, rows, alignment, fmt)

- service_info = []
- if cluster.is_paused():
- service_info.append('Maintenance mode: on')
-
- if cluster.failover and cluster.failover.scheduled_at:
- info = 'Switchover scheduled at: ' + cluster.failover.scheduled_at.isoformat()
- if cluster.failover.leader:
- info += '\n from: ' + cluster.failover.leader
- if cluster.failover.candidate:
- info += '\n to: ' + cluster.failover.candidate
- service_info.append(info)
-
- if service_info:
- click.echo(' ' + '\n '.join(service_info))
+ if fmt == "pretty":
+ service_info = []
+ if cluster.is_paused():
+ service_info.append('Maintenance mode: on')
+
+ if cluster.failover and cluster.failover.scheduled_at:
+ info = 'Switchover scheduled at: ' + cluster.failover.scheduled_at.isoformat()
+ if cluster.failover.leader:
+ info += '\n from: ' + cluster.failover.leader
+ if cluster.failover.candidate:
+ info += '\n to: ' + cluster.failover.candidate
+ service_info.append(info)
+
+ if service_info:
+ click.echo(' ' + '\n '.join(service_info))


@ctl.command('list', help='List the Patroni members for a given Patroni')

0 comments on commit 6d848d9

Please sign in to comment.