SDP-223

tom_tyler (C. Thomas Tyler)
C. Thomas Tyler created this job , modified by Perforce maintenance
Closed
Fix EDGESERVER check in p4d_base regression.

Fix an issue introduced in @22215.  The change introduces a
check of the $EDGESERVER environment var in p4d_base, which
isn't reliably set when p4d_base is called.  Though p4d_base
now sources in backup_functions.sh, which has logic to set the
EDGESERVER variable in the set_vars() function, that set_vars()
function is never actually called.

We can't just call the set_vars() function, because it makes
'front door' checks (i.e. calls 'p4' commands) to determine if
the current instances is an edge server.  There are a few
problems here: 1) The p4d_base is an init script, and so can't
assume that front-door commands will work, since the server
might be down.  So the call to determine if it is an edge
server won't give the right result, and the 'p4login' call
will hang unnecessarily for a while.

Proposed fixes:
* Rewrite the logic in set_vers that sets EDGESERVER. It
should detect whether the current server is an edge server
in a way that runs fast and reliably even when 'p4d' is
down.  Do something like 'p4d -k db.<whatever> -jd -' and
find which database has server specs, and match that value
in th schema to the server spec (named $SERVERID), and check
that the value for the 'Services:' field of the server spec
has the code for 'edge-server.'

* Rewite the set_vars() so it only does innocuous things like
set variables (as the name implies), and doesn't try a 'p4 login'.
or anything else "active." Warnign: Need to make sure that doesn't
break anything, i.e. if any place calling set_vars() relies on
it doing 'p4login'.  This may need some refactoring and further
testing.
22271Attempting fix of build failure.
Bypassing pre-commit review.
22243Further refinements to the new 'rotate journal on p4d start' change:
* Fixed p4d_truncate_journal so it has less environment dependencies
(e.g. doesn't depend on LOGFILE, etc.) and doesn't try sending email.
* Introduced msg() and bail(), counterparts to log() and die() which
don't try to write to LOGFILE and don't try to send email.
* Added call to get_journalnum() before call to p4d_truncate_journal().
* Fixed logic in get_journalnum() so it gets the journal number w/o
needing p4d to be up.
 * I think I fixed the syntax error in bitwise operator check when
setting EDGE_SERVER.  It works on a non-edge server (sets
EDGESERVER=0).  For now I have it doing an
'echo EDGESERVER=$EDGESERVER', but need to test that it correctly
sets EDGESERVER=1 on an edge server.

TO DO: Remove that 'echo EDGESERVER=$EDGESERVER' once we verify it
correctly sets the value for $EDGESERVER. (Or not?)
22221Change set_vars to look up the edge server directly in the database so the server does
not have to be on-line to check.

Fix for Job: SDP-223
22270Attempting fix of build failure.
Bypassing pre-commit review.

#review-22271
22250Further refinements to the new 'rotate journal on p4d start' change:
* Fixed p4d_truncate_journal so it has less environment dependencies
(e.g. doesn't depend on LOGFILE, etc.) and doesn't try sending email.
* Introduced msg() and bail(), counterparts to log() and die() which
don't try to write to LOGFILE and don't try to send email.
* Added call to get_journalnum() before call to p4d_truncate_journal().
* Fixed logic in get_journalnum() so it gets the journal number w/o
needing p4d to be up.
 * I think I fixed the syntax error in bitwise operator check when
setting EDGE_SERVER.  It works on a non-edge server (sets
EDGESERVER=0).  For now I have it doing an
'echo EDGESERVER=$EDGESERVER', but need to test that it correctly
sets EDGESERVER=1 on an edge server.

TO DO: Remove that 'echo EDGESERVER=$EDGESERVER' once we verify it
correctly sets the value for $EDGESERVER. (Or not?)
22239Change set_vars to look up the edge server directly in the database so the server does
not have to be on-line to check.

Fix for Job: SDP-223
22220Change set_vars to look up the edge server directly in the database so the server does
not have to be on-line to check.

Fix for Job: SDP-223

#review-22221
  • Details
  • Comments -
Status
Closed
Project
perforce-software-sdp
Severity
C
Reported By
C. Thomas Tyler
Reported Date
Modified By
Perforce maintenance
Modified Date
Owned By
russell_jackson
Component
init
Type
Bug