[MDEV-17379] galera_new_cluster throws error in 10.3.10 Created: 2018-10-05  Updated: 2018-11-15  Resolved: 2018-11-15

Status: Closed
Project: MariaDB Server
Component/s: Galera, Scripts & Clients
Affects Version/s: 10.3.10
Fix Version/s: 10.3.11

Type: Bug Priority: Major
Reporter: Todd Stoffel (Inactive) Assignee: Jan Lindström (Inactive)
Resolution: Fixed Votes: 6
Labels: None
Environment:

Centos 7.4


Issue Links:
Duplicate
duplicates MDEV-17524 Use 'exit' instead of 'return' Closed
duplicates MDEV-17628 script galera_new_cluster returns err... Closed
duplicates MDEV-17715 Bootstrap script uses return instead ... Closed

 Description   

/bin/galera_new_cluster: line 31: return: can only `return' from a function or sourced script

Galera does seem to bootstrap, but without a successful exit code automation utilities like Puppet, Chef, Ansible, etc may break.



 Comments   
Comment by Paul Namuag [ 2018-10-08 ]

We encountered this as well as running thru automated setup/install using ClusterControl and fails:

Failed to start MySQL daemon: /usr/bin/galera_new_cluster: line 31: return: can only `return' from a function or sourced script

As it contains return command, could be invoked as a source script as follows:

. /usr/bin/galera_new_cluster

However, I think the script should be improved better than the current and maybe use

exit $extcode


in the end of the shell script.

Also using

zsh

does not have an issue but bash does.

Bar.bash

$#> cat /bin/galera_new_cluster 
#!/bin/sh
 
...
......
systemctl set-environment _WSREP_NEW_CLUSTER='--wsrep-new-cluster' && \
    systemctl start ${1:-mariadb}
 
extcode=$?
 
systemctl set-environment _WSREP_NEW_CLUSTER=''
 
return $extcode

Comment by Paul Namuag [ 2018-10-11 ]

Hi Jan,

Do you have any feedback of this issue? We would love to hear from you guys.

Thank you.

Comment by Jason White (AC) [ 2018-10-12 ]

I've also hit this issue - raised it with a solution here: https://github.com/codership/galera/issues/523.

`return $extcode` needs to change to `exit $extcode`.

Comment by Paul Namuag [ 2018-10-12 ]

Same here Jason. I use the same approach to resolve the issue. However, in ClusterControl for new installations on MariaDB 10.3 fails coz it hooks up the new package unless this is fix and committed to the repo itself. That would be great.

Comment by Elena Stepanova [ 2018-10-23 ]

Linked a pull request

Comment by Michal Schorm [ 2018-10-23 ]

As suggested in PR #896, I created PR #897 against branch 10.3

Comment by Stepan Patryshev (Inactive) [ 2018-11-08 ]

Just bumped with it on 10.3.10-1.el7.centos.

Generated at Thu Feb 08 08:36:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.