Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lisa Casino
slapos
Commits
761615e2
Commit
761615e2
authored
Sep 11, 2019
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up generic.mysql.wrap_update_mysql
--user=root is redundant and it will break with MariaDB 10.4
parent
7eb9c746
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
44 deletions
+20
-44
slapos/recipe/generic_mysql/__init__.py
slapos/recipe/generic_mysql/__init__.py
+2
-2
slapos/recipe/generic_mysql/mysql.py
slapos/recipe/generic_mysql/mysql.py
+18
-42
No files found.
slapos/recipe/generic_mysql/__init__.py
View file @
761615e2
...
@@ -32,10 +32,10 @@ class WrapUpdateMySQL(GenericBaseRecipe):
...
@@ -32,10 +32,10 @@ class WrapUpdateMySQL(GenericBaseRecipe):
self
.
createPythonScript
(
self
.
createPythonScript
(
self
.
options
[
'output'
],
self
.
options
[
'output'
],
__name__
+
'.mysql.updateMysql'
,
__name__
+
'.mysql.updateMysql'
,
[
{
kw
=
{
'mysql_upgrade_binary'
:
self
.
options
[
'binary'
],
'mysql_upgrade_binary'
:
self
.
options
[
'binary'
],
'mysql_binary'
:
self
.
options
[
'mysql'
],
'mysql_binary'
:
self
.
options
[
'mysql'
],
'mysql_script_file'
:
self
.
options
[
'init-script'
],
'mysql_script_file'
:
self
.
options
[
'init-script'
],
}
]
}
),
),
]
]
slapos/recipe/generic_mysql/mysql.py
View file @
761615e2
...
@@ -4,69 +4,45 @@ import time
...
@@ -4,69 +4,45 @@ import time
import
sys
import
sys
import
pytz
import
pytz
def
updateMysql
(
conf
):
def
updateMysql
(
mysql_upgrade_binary
,
mysql_binary
,
mysql_script_file
):
sleep
=
30
sleep
=
30
is_succeed
=
False
with
open
(
mysql_script_file
)
as
script_file
:
try
:
mysql_script
=
script_file
.
read
()
script_filename
=
conf
.
pop
(
'mysql_script_file'
)
mysql_list
=
mysql_binary
,
'-B'
except
KeyError
:
mysql_tzinfo_to_sql_list
=
(
pass
os
.
path
.
join
(
os
.
path
.
dirname
(
mysql_binary
),
'mysql_tzinfo_to_sql'
),
else
:
os
.
path
.
join
(
os
.
path
.
dirname
(
pytz
.
__file__
),
'zoneinfo'
),
assert
'mysql_script'
not
in
conf
)
with
open
(
script_filename
)
as
script_file
:
conf
[
'mysql_script'
]
=
script_file
.
read
()
is_succeeded
=
False
while
True
:
while
True
:
while
True
:
while
True
:
mysql_upgrade_list
=
[
conf
[
'mysql_upgrade_binary'
],
'--user=root'
]
mysql_upgrade
=
subprocess
.
Popen
(
mysql_upgrade_binary
,
if
'socket'
in
conf
:
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
mysql_upgrade_list
.
append
(
'--socket='
+
conf
[
'socket'
])
mysql_upgrade
=
subprocess
.
Popen
(
mysql_upgrade_list
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
result
=
mysql_upgrade
.
communicate
()[
0
]
result
=
mysql_upgrade
.
communicate
()[
0
]
if
mysql_upgrade
.
returncode
is
None
:
if
mysql_upgrade
.
returncode
:
mysql_upgrade
.
kill
()
print
"Command %r failed with result:
\
n
%s"
%
(
mysql_upgrade_binary
,
result
)
if
mysql_upgrade
.
returncode
==
0
:
print
"MySQL database upgraded with result:
\
n
%s"
%
result
elif
'is already upgraded'
in
result
:
print
"No need to upgrade MySQL database"
else
:
print
"Command %r failed with result:
\
n
%s"
%
(
mysql_upgrade_list
,
result
)
break
break
mysql_list
=
[
conf
[
'mysql_binary'
].
strip
(),
'-B'
,
'--user=root'
]
print
"MySQL database upgraded with result:
\
n
%s"
%
result
if
'socket'
in
conf
:
mysql_list
.
append
(
'--socket='
+
conf
[
'socket'
])
mysql
=
subprocess
.
Popen
(
mysql_list
,
stdin
=
subprocess
.
PIPE
,
mysql
=
subprocess
.
Popen
(
mysql_list
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
result
=
mysql
.
communicate
(
conf
[
'mysql_script'
])[
0
]
result
=
mysql
.
communicate
(
mysql_script
)[
0
]
if
mysql
.
returncode
is
None
:
if
mysql
.
returncode
:
mysql
.
kill
()
if
mysql
.
returncode
!=
0
:
print
'Command %r failed with:
\
n
%s'
%
(
mysql_list
,
result
)
print
'Command %r failed with:
\
n
%s'
%
(
mysql_list
,
result
)
break
break
# import timezone database
# import timezone database
mysql_tzinfo_to_sql_binary
=
os
.
path
.
join
(
os
.
path
.
dirname
(
conf
[
'mysql_binary'
].
strip
()),
'mysql_tzinfo_to_sql'
)
zoneinfo_directory
=
'%s/zoneinfo'
%
os
.
path
.
dirname
(
pytz
.
__file__
)
mysql_tzinfo_to_sql_list
=
[
mysql_tzinfo_to_sql_binary
,
zoneinfo_directory
]
mysql_tzinfo_to_sql
=
subprocess
.
Popen
(
mysql_tzinfo_to_sql_list
,
stdin
=
subprocess
.
PIPE
,
mysql_tzinfo_to_sql
=
subprocess
.
Popen
(
mysql_tzinfo_to_sql_list
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
timezone_sql
=
mysql_tzinfo_to_sql
.
communicate
()[
0
]
timezone_sql
=
mysql_tzinfo_to_sql
.
communicate
()[
0
]
if
mysql_tzinfo_to_sql
.
returncode
!=
0
:
if
mysql_tzinfo_to_sql
.
returncode
!=
0
:
print
'Command %r failed with:
\
n
%s'
%
(
mysql_tzinfo_to_sql_list
,
result
)
print
'Command %r failed with:
\
n
%s'
%
(
mysql_tzinfo_to_sql_list
,
result
)
break
break
mysql
=
subprocess
.
Popen
(
mysql_list
+
[
'mysql'
,]
,
stdin
=
subprocess
.
PIPE
,
mysql
=
subprocess
.
Popen
(
mysql_list
+
(
'mysql'
,)
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
result
=
mysql
.
communicate
(
timezone_sql
)[
0
]
result
=
mysql
.
communicate
(
timezone_sql
)[
0
]
if
mysql
.
returncode
is
None
:
if
mysql
.
returncode
:
mysql
.
kill
()
if
mysql
.
returncode
!=
0
:
print
'Command %r failed with:
\
n
%s'
%
(
mysql_list
,
result
)
print
'Command %r failed with:
\
n
%s'
%
(
mysql_list
,
result
)
break
break
is_succeeded
=
True
break
if
is_succeeded
:
print
'SlapOS initialisation script succesfully applied on database.'
print
'SlapOS initialisation script succesfully applied on database.'
break
return
print
'Sleeping for %ss and retrying'
%
sleep
print
'Sleeping for %ss and retrying'
%
sleep
sys
.
stdout
.
flush
()
sys
.
stdout
.
flush
()
sys
.
stderr
.
flush
()
sys
.
stderr
.
flush
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment