Bug 1625734
| Summary: | spacewalk-setup script crashes on clearing database | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Community] Spacewalk | Reporter: | rhornsby | ||||
| Component: | Installation | Assignee: | Jan Dobes <jdobes> | ||||
| Status: | CLOSED EOL | QA Contact: | Red Hat Satellite QA List <satqe-list> | ||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | unspecified | ||||||
| Version: | 2.8 | CC: | asaunier1, thefiguras | ||||
| Target Milestone: | --- | ||||||
| Target Release: | --- | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | If docs needed, set a value | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | Environment: | ||||||
| Last Closed: | 2020-03-09 13:42:26 UTC | Type: | Bug | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Attachments: |
|
||||||
I had been using an answer file, but hadn't realized until I started digging into the perl code that there were "non-interactive" and "clear-db" flags. It seems like the Spacewalk script is a little confused about this itself. Sometimes it won't prompt, but will just bail (the database exists) and other times it will prompt (the database has schema). Sometimes the script will hint and say "you might want this flag" and other times it won't do that. I am having the same exact issue as stated above with the same steps to reproduce. Spacewalk 2.8 (and older) has already reached it's End Of Life. Thank you for reporting this issue and we are sorry that we were not able to fix it before end of life. If you would still like to see this bug fixed and are able to reproduce it against current version of Spacewalk 2.9, you are encouraged change the 'version' and re-open it. |
Created attachment 1481127 [details] Screenshot showing Perl error messages CentOS 7.5, installing Spacewalk 2.8.2 as per the instructions on the official Spacewalk install guide. Description of problem: When running `spacewalk-setup` generically (embedded pg database, etc) if the database already exists, the script bails and suggests to use `--skip-db-install`. Passing this flag leads to an unexpected interactive prompt: `The Database has schema. Would you like to clear the database [Y]?` If you answer this question in the affirmative, the script fails with this output: --- The Database has schema. Would you like to clear the database [Y]? ** Database: Clearing database. ** Database: Shutting down spacewalk services that may be using DB. ** Database: Services stopped. Clearing DB. DBD::Pg::db do failed: server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. at /usr/share/perl5/vendor_perl/Spacewalk/Setup.pm line 1233, <STDIN> line 1. DBD::Pg::db do failed: no connection to the server at /usr/share/perl5/vendor_perl/Spacewalk/Setup.pm line 1233, <STDIN> line 1. [error message repeats] ** Database: Re-populating database. *** Progress: # Could not populate database. --- If you execute these same steps using an automation tool like Chef, the outcome is the same but there are two additional things that happen: 1. You get two warnings from Perl about uninitialized variables (see attached): Use of uninitialized value in scalar chomp at /usr/share/perl5/vendor_perl/Spacewalk/Setup.pm line 619. Use of uninitialized value in substitution (s///) at /usr/share/perl5/vendor_perl/Spacewalk/Setup.pm line 620. 2. Because there is no tty(?), the setup script with its unexpected request for interactive input, assumes the default 'Y' in response to its query about clearing the database. The Spacewalk setup script then fails in the same manner described above. Version-Release number of selected component (if applicable): 2.8 How reproducible: Always Steps to Reproduce: Described above Actual results: * The setup script encounters and unrecoverable error while attempting to clear the database, and exits abnormally (non-zero). Expected results: The setup script should 1) Default to *not* clearing the database 2) If the request is to wipe the database, it should be handled as such 3) Not prompt the user for interactive input. Additional info: A couple of things I might suggest: * Prompting for input in the *NIX shell should be used extremely sparingly and there should always be a clearly defined flag, argument, or environment variable, etc to allow the script to be provided the answer to any questions before execution begins. It is helpful if this information is presented at the time the action is to be taken/skipped. This sort of behavior already exists earlier in the Spacewalk setup: --- ** Database: Setting up database connection for PostgreSQL backend. Database "rhnschema" already exists The embedded database appears to be already installed. Either rerun this script with the --skip-db-install option, or use the '/usr/bin/spacewalk-setup-postgresql remove --db rhnschema --user rhnuser' script to remove the embedded database and try again. --- * The default behavior should be the _least_ destructive option. In this particular case, that means we should default to preserving the database if it exists, rather than assuming it should be wiped out. Exiting non-zero when there's a legitimate question about what to do is a reasonable least destructive option.