Commit 65cbf6ea authored by Jérome Perrin's avatar Jérome Perrin

Update Release Candidate

parents 30f3f66d 4dcb7327
...@@ -32,7 +32,7 @@ environment = ...@@ -32,7 +32,7 @@ environment =
NO_TCLTK=y NO_TCLTK=y
PATH=${curl:location}/bin:${gettext:location}/bin:${tar:location}/bin:${xz-utils:location}/bin:%(PATH)s PATH=${curl:location}/bin:${gettext:location}/bin:${tar:location}/bin:${xz-utils:location}/bin:%(PATH)s
CPPFLAGS=-I${zlib:location}/include CPPFLAGS=-I${zlib:location}/include
LDFLAGS=-L${zlib:location}/lib -L${openssl:location}/lib -Wl,-rpath=${openssl:location}/lib -Wl,-rpath=${zlib:location}/lib LDFLAGS=-L${zlib:location}/lib -L${openssl:location}/lib -Wl,-rpath=${openssl:location}/lib -Wl,-rpath=${zlib:location}/lib -Wl,-rpath=${curl:location}/lib
[gitweb] [gitweb]
<= git <= git
......
[buildout] [buildout]
extends = extends =
../../stack/slapos.cfg
../defaults.cfg ../defaults.cfg
../babeld/buildout.cfg ../babeld/buildout.cfg
../geoip2/buildout.cfg ../geoip2/buildout.cfg
......
...@@ -28,7 +28,7 @@ from setuptools import setup, find_packages ...@@ -28,7 +28,7 @@ from setuptools import setup, find_packages
import glob import glob
import os import os
version = '1.0.305' version = '1.0.326'
name = 'slapos.cookbook' name = 'slapos.cookbook'
long_description = open("README.rst").read() long_description = open("README.rst").read()
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# #
############################################################################## ##############################################################################
import six
import os import os
import shlex import shlex
from zc.buildout import UserError from zc.buildout import UserError
...@@ -41,7 +42,7 @@ class Cluster(object): ...@@ -41,7 +42,7 @@ class Cluster(object):
for node in sorted(options['nodes'].split()): for node in sorted(options['nodes'].split()):
node = buildout[node] node = buildout[node]
node_list.append(node) node_list.append(node)
for k, v in result_dict.iteritems(): for k, v in six.iteritems(result_dict):
x = node[k] x = node[k]
if x: if x:
v.append(x) v.append(x)
......
...@@ -194,6 +194,28 @@ class Recipe(GenericBaseRecipe): ...@@ -194,6 +194,28 @@ class Recipe(GenericBaseRecipe):
def createDatabase(self): def createDatabase(self):
self.runPostgresCommand(cmd='CREATE DATABASE "%s"' % self.options['dbname']) self.runPostgresCommand(cmd='CREATE DATABASE "%s"' % self.options['dbname'])
def isPosgresServerRunning(self):
pgdata = self.options['pgdata-directory']
postmaster_pid_file = os.path.join(pgdata, 'postmaster.pid')
if os.path.exists(postmaster_pid_file):
pg_ctl_binary = os.path.join(self.options['bin'], 'pg_ctl')
self.check_exists(pg_ctl_binary)
# Check the postgres is running or not
# if not, delete the ppostmaster.pid and run it again
try:
output1 = subprocess.check_output([pg_ctl_binary, 'status', '-D', pgdata], stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
if e.returncode == 3:
# If the server is not running, pg_ctl returns an exit status of 3
# see https://www.postgresql.org/docs/current/app-pg-ctl.html
os.remove(postmaster_pid_file)
return False
else:
raise
return True
else:
return False
def updateSuperuser(self): def updateSuperuser(self):
"""\ """\
...@@ -211,7 +233,7 @@ class Recipe(GenericBaseRecipe): ...@@ -211,7 +233,7 @@ class Recipe(GenericBaseRecipe):
change_password_query = """ALTER USER "%s" ENCRYPTED PASSWORD '%s'""" % (user, enc_password) change_password_query = """ALTER USER "%s" ENCRYPTED PASSWORD '%s'""" % (user, enc_password)
pgdata = self.options['pgdata-directory'] pgdata = self.options['pgdata-directory']
if os.path.exists(os.path.join(pgdata, 'postmaster.pid')): if self.isPosgresServerRunning():
psql_binary = os.path.join(self.options['bin'], 'psql') psql_binary = os.path.join(self.options['bin'], 'psql')
# connect to a running postgres deamon # connect to a running postgres deamon
p = subprocess.Popen([ p = subprocess.Popen([
......
...@@ -90,6 +90,26 @@ class PostgresTest(unittest.TestCase): ...@@ -90,6 +90,26 @@ class PostgresTest(unittest.TestCase):
self.assertEqual(cursor.fetchone(), (2,)) self.assertEqual(cursor.fetchone(), (2,))
cnx.close() cnx.close()
def test_stale_pid_file_does_not_prevent_install(self):
self.recipe.install()
# Malformed postmaster.pid file should not prevent the service running
pgdata_directory = os.path.join(self.pgdata_directory, 'pgdata')
postmaster_pid_file =os.path.join(pgdata_directory, 'postmaster.pid')
content = '''\
1074626
/srv/slapgrid/slappart33/srv/runner/instance/slappart0/srv/postgresql
1686241354
5432
/srv/slapgrid/slappart33/srv/runner/instance/slappart0/srv/postgresql
10.0.156.45
5432001 1179658
ready'''
with open(postmaster_pid_file, 'w') as file:
file.write(content)
self.recipe.install()
def test_update_password(self): def test_update_password(self):
self.recipe.install() self.recipe.install()
self.start_postgres_server() self.start_postgres_server()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment