From d551da949d1f284d813ff4ad5e7c78f2aae7897f Mon Sep 17 00:00:00 2001
From: diwakar thyagaraj <diwakar.chitoor.thyagaraj@att.com>
Date: Thu, 12 Dec 2019 22:42:35 +0000
Subject: [PATCH] Postgresql UC Python and Ubuntu upgrade.

    This Patchset updates ubuntu from xenial to Bionic,
     and Python from 2.0 to 3.7.

Change-Id: Id79cb21eec820f6505b0287616ed399c1898da4b
---
 charts/postgresql-utility/templates/bin/_start.sh.tpl     | 8 ++++----
 .../bin/utility/_postgresql-utility-rootwrap.tpl          | 2 +-
 charts/postgresql-utility/values.yaml                     | 2 +-
 ...{Dockerfile.ubuntu_xenial => Dockerfile.ubuntu_bionic} | 7 +++----
 zuul.d/postgresql-utility.yaml                            | 2 +-
 5 files changed, 10 insertions(+), 11 deletions(-)
 rename images/postgresql-utility/{Dockerfile.ubuntu_xenial => Dockerfile.ubuntu_bionic} (87%)

diff --git a/charts/postgresql-utility/templates/bin/_start.sh.tpl b/charts/postgresql-utility/templates/bin/_start.sh.tpl
index 6275346f..f734ef94 100644
--- a/charts/postgresql-utility/templates/bin/_start.sh.tpl
+++ b/charts/postgresql-utility/templates/bin/_start.sh.tpl
@@ -23,7 +23,7 @@ root logger by oslo-rootwrap module, imported in _openstack-utility-rootwrap.tpl
 These lines will get rid of duplicate logs, generated because of the formatter
 attached by oslo-rootwrap.
 */}}
-sed -i "/rootwrap_logger.setLevel/s/.*/#&/" /usr/lib/python2.7/dist-packages/oslo_rootwrap/wrapper.py
-sed -i "/handler.setFormatter/s/.*/#&/" /usr/lib/python2.7/dist-packages/oslo_rootwrap/wrapper.py
-sed -i "/os.path.basename/s/.*/#&/" /usr/lib/python2.7/dist-packages/oslo_rootwrap/wrapper.py
-sed -i "/rootwrap_logger.addHandler/s/.*/#&/" /usr/lib/python2.7/dist-packages/oslo_rootwrap/wrapper.py
+sed -i "/rootwrap_logger.setLevel/s/.*/#&/" /usr/lib/python3/dist-packages/oslo_rootwrap/wrapper.py
+sed -i "/handler.setFormatter/s/.*/#&/" /usr/lib/python3/dist-packages/oslo_rootwrap/wrapper.py
+sed -i "/os.path.basename/s/.*/#&/" /usr/lib/python3/dist-packages/oslo_rootwrap/wrapper.py
+sed -i "/rootwrap_logger.addHandler/s/.*/#&/" /usr/lib/python3/dist-packages/oslo_rootwrap/wrapper.py
diff --git a/charts/postgresql-utility/templates/bin/utility/_postgresql-utility-rootwrap.tpl b/charts/postgresql-utility/templates/bin/utility/_postgresql-utility-rootwrap.tpl
index e5f894fb..53e2e8fe 100644
--- a/charts/postgresql-utility/templates/bin/utility/_postgresql-utility-rootwrap.tpl
+++ b/charts/postgresql-utility/templates/bin/utility/_postgresql-utility-rootwrap.tpl
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/python3
 {{/*
   Copyright 2017 The Openstack-Helm Authors.
 
diff --git a/charts/postgresql-utility/values.yaml b/charts/postgresql-utility/values.yaml
index 3e54ccf5..b8cdbfae 100644
--- a/charts/postgresql-utility/values.yaml
+++ b/charts/postgresql-utility/values.yaml
@@ -25,7 +25,7 @@ release_group: null
 images:
   pull_policy: IfNotPresent
   tags:
-    postgresql_utility: 'quay.io/airshipit/porthole-postgresql-utility:latest-ubuntu_xenial'
+    postgresql_utility: 'quay.io/airshipit/porthole-postgresql-utility:latest-ubuntu_bionic'
     image_repo_sync: docker.io/docker:18.09.02
   local_registry:
     active: false
diff --git a/images/postgresql-utility/Dockerfile.ubuntu_xenial b/images/postgresql-utility/Dockerfile.ubuntu_bionic
similarity index 87%
rename from images/postgresql-utility/Dockerfile.ubuntu_xenial
rename to images/postgresql-utility/Dockerfile.ubuntu_bionic
index 68e2ceb0..9dedcf7d 100644
--- a/images/postgresql-utility/Dockerfile.ubuntu_xenial
+++ b/images/postgresql-utility/Dockerfile.ubuntu_bionic
@@ -1,4 +1,4 @@
-ARG FROM=ubuntu:16.04
+ARG FROM=ubuntu:18.04
 FROM ${FROM}
 
 LABEL org.opencontainers.image.authors='airship-discuss@lists.airshipit.org, irc://#airshipit@freenode' \
@@ -19,13 +19,12 @@ RUN set -xe && \
     moreutils \
     postgresql-client \
     postgresql-common \
-    python-oslo.rootwrap \
+    python3-pip \
     python3-oslo.rootwrap \
     rsyslog \
     screen \
     sudo && \
     apt-get clean -y && \
-    rm -rf /var/cache/debconf/* /var/lib/apt/lists/* \
-    /var/log/* /tmp/* /var/tmp/*
+    rm -rf /var/cache/debconf/* /var/lib/apt/lists/*
 
 CMD ["/bin/bash"]
diff --git a/zuul.d/postgresql-utility.yaml b/zuul.d/postgresql-utility.yaml
index 83be2e83..c5aee5be 100644
--- a/zuul.d/postgresql-utility.yaml
+++ b/zuul.d/postgresql-utility.yaml
@@ -17,7 +17,7 @@
     parent: &parent airship-porthole-images
     vars:
       image_name: &image_name porthole-postgresql-utility
-      distro_suffix: &distro_suffix ubuntu_xenial
+      distro_suffix: &distro_suffix ubuntu_bionic
     files:
       - ^charts/postgresql-utility/.*$
       - ^images/postgresql-utility/.*$