Bug 809444 - spacewalk-hostname-rename @postrgesql fails (SQL syntax error)
spacewalk-hostname-rename @postrgesql fails (SQL syntax error)
Status: CLOSED CURRENTRELEASE
Product: Spacewalk
Classification: Community
Component: Clients (Show other bugs)
1.7
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Milan Zázrivec
Red Hat Satellite QA List
:
: 842153 (view as bug list)
Depends On:
Blocks: 820123 space18
  Show dependency treegraph
 
Reported: 2012-04-03 07:54 EDT by Lukas Pramuk
Modified: 2012-11-01 12:18 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 820123 (view as bug list)
Environment:
Last Closed: 2012-11-01 12:18:02 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Lukas Pramuk 2012-04-03 07:54:05 EDT
Description of problem:
Against postgresql spacewalk the "spacewalk-hostname-rename" command fails with SQL syntax error. It seems that it uses same sql code for both oracle and postgres.


Version-Release number of selected component (if applicable):
spacewalk-utils-1.7.15-1.el6.noarch
spacewalk-schema-1.7.55-1.el6.noarch

How reproducible: always


Steps to Reproduce:
1.spacewalk-hostname-rename <ip>

  
Actual results:
spacewalk-hostname-rename fails, error msg printed

Expected results:
spacewalk-hostname-rename succeeds, no errors

Additional info:
spacewalk-hostname-rename x.x.x.x
Validating IP ... OK
=============================================
hostname: fqdn
ip: x.x.x.x
=============================================
Stopping rhn-satellite services ... OK
Testing DB connection ... Running: psql -U spaceuser -d spaceschema -v ON_ERROR_STOP=ON -f - -h localhost -p 5432
psql:<stdin>:1: ERROR:  syntax error at or near "off"
LINE 1: set feed off;
                 ^
FAILED
Your database isn't running.
Fix the problem and run /usr/bin/spacewalk-hostname-rename again
Comment 1 Milan Zázrivec 2012-04-03 10:25:58 EDT
spacewalk.git master: af92a3dd2101a0b9759ad63f8abfd138089d5c2f
Comment 3 Paul Robert Marino 2012-04-04 12:10:50 EDT
I ran into this too
Its the QUIT commands in the sql statments that break it.

This diff should break the script in the right so it will work for you.
copy the script into your home directory and apply this diff with the patch command

It disables the database running check and gets rid of the "QUIT" statements which is the only Oracle specific syntax in the functional portion of the code.
unfortunately it will produce errors about the client closing the connection unexpectedly however that's not a really serious problem however i wouldn't try to put it into the core repo because of it. 



--- spacewalk-hostname-rename.orig      2012-04-04 11:49:42.063065418 -0400
+++ spacewalk-hostname-rename   2012-04-04 11:57:35.000096385 -0400
@@ -331,7 +331,6 @@
 UPDATE rhn_sat_cluster SET vip = '$IP' WHERE public_key LIKE '${NOCPULSE_OLD_PUBLIC_KEY}%';
 UPDATE rhn_sat_node SET ip = '$IP' WHERE EXISTS (SELECT 1 FROM rhn_sat_cluster RSC WHERE RSC.public_key LIKE '${NOCPULSE_OLD_PUBLIC_KEY}%' AND sat_cluster_id = RSC.recid);
 COMMIT;
-QUIT
 EOS
 }

@@ -417,7 +416,7 @@
 "  | spacewalk-sql --select-mode -
 )
 # SQL_RET="${SQL_RET#"${SQL_RET%%[![:space:]]*}"}"
-print_status "${SQL_RET}" "Your database isn't running."
+#print_status "${SQL_RET}" "Your database isn't running."

 echo -n "Updating /etc/rhn/rhn.conf ... " | tee -a $LOG
 update_rhn_conf
@@ -450,7 +449,6 @@
 UPDATE rhn_config_macro SET definition='$HOSTNAME' WHERE name='RHN_SAT_HOSTNAME';
 UPDATE rhn_config_macro SET definition='$HOSTNAME' WHERE name='MDOM';
 COMMIT;
-QUIT
 EOS
     print_status 0  # just simulate end
 fi
@@ -479,7 +477,6 @@
 spacewalk-sql --select-mode - >>$LOG <<EOS
 UPDATE rhntemplatestring SET value='$HOSTNAME' WHERE label='hostname';
 COMMIT;
-QUIT
 EOS
 print_status 0  # just simulate end

@@ -493,7 +490,6 @@
 spacewalk-sql --select-mode - >>$LOG <<EOS
 DELETE FROM rhnPushDispatcher WHERE hostname != '$HOSTNAME';
 COMMIT;
-QUIT
 EOS

 for jabber_config_file in c2s.xml s2s.xml sm.xml
Comment 5 Jan Pazdziora 2012-07-22 16:41:45 EDT
*** Bug 842153 has been marked as a duplicate of this bug. ***
Comment 6 Jan Pazdziora 2012-10-30 15:22:59 EDT
Moving ON_QA. Packages that address this bugzilla should now be available in yum repos at http://yum.spacewalkproject.org/nightly/
Comment 7 Jan Pazdziora 2012-11-01 12:18:02 EDT
Spacewalk 1.8 has been released: https://fedorahosted.org/spacewalk/wiki/ReleaseNotes18

Note You need to log in before you can comment on or make changes to this bug.