How to configure and test dCache GLUE info provider
----

This document describes how to configure the information provider
supplied with dCache so it provides the correct information for WLCG.
This is necessary so that WLCG infrastructure (such as FTS) and
clients using WLCG tools can correctly use the dCache instance.

The process is designed to be the minimum overhead so it can easily be
performed manually; however, you may choose to use an automatic
configuration tool, such as yaim.

Please be aware that changing information provider may result in a
brief interruption to published information.



Ensuring dCache information is available
----

Make sure that both the httpd and info services are running, both are
required for publishing information.  By default, the info service is
started on the admin node; but it is possible to configure dCache so
it runs on a different node.  You should run only one info service per
dCache instance.

  NB the info service is different from, and completely independent
     of, the infoProvider service.

If necessary, you may start the info service manually:

  /opt/d-cache/bin/dcache start info

You can check which services are running on the local node using the
status command:

  /opt/d-cache/bin/dcache status

You can also verify both services (httpd and info) are running with
the following wget command.  This command assumes that you run it on
the node that has the httpd service (by default, the admin node).  If
may run the command on any node by replacing "localhost" with the
hostname of the node running the httpd service.

  wget -O/dev/null http://localhost:2288/info

If you see the following output:

  # wget -O/dev/null http://localhost:2288/info
  --10:05:35--  http://localhost:2288/info
             => `/dev/null'
  Resolving localhost... 127.0.0.1
  Connecting to localhost|127.0.0.1|:2288... failed: Connection refused.

Then the httpd service is not running.  Start the service with the
following command:

  /opt/d-cache/bin/dcache httpd start

If you see the following output:

  # wget -O/dev/null http://localhost:2288/info
  --10:03:13--  http://localhost:2288/info
             => `/dev/null'
  Resolving localhost... 127.0.0.1
  Connecting to localhost|127.0.0.1|:2288... connected.
  HTTP request sent, awaiting response... 503 Unable to contact the info cell.  Please ensure the info cell is running.
  10:03:13 ERROR 503: Unable to contact the info cell.  Please ensure the info cell is running..

Then the info service is not running.  start it with the following
command:

  /opt/d-cache/bin/dcache info start



Configuring info provider
----

In the directory /opt/d-cache/etc you will find a template file
glue-1.3.xml.template.  Copy this file as glue-1.3.xml in the same
directory.

Edit glue-1.3.xml with your favourite text editor.

The file is split into two parts.  The first part contains the
configuration that a site will typically need to configure.  Most
sites may leave the second part alone.  The two parts are separated by
the comment:

    YOU SHOULD NOT NEED TO EDIT ANYTHING BELOW THIS POINT.

Take care when editing the file!  The file must be valid,
well-formed XML.  In particular, be very careful if you add a
less-than symbol ('<') that isn't part of an XML element, or an
ampersand symbol ('&') that isn't part of an entity markup; if you
wish to add these symbol you must use the marked-up version: "&lt;"
and "&amp;" respectively.  For example:

    <constant id="SE-NAME">Simple &amp; small dCache instance for small VOs (typically &lt; 20 users)</constant>

As a hint, you should *only* edit text between two elements or add
more elements (for lists and mappings).  You should *never* edit text
inside double-quote marks.  For example, with the following element
definition:

    <constant id="SITE-UNIQUE-ID">EXAMPLESITE-ID</constant>

you should review the contents between the elements ("EXAMPLESITE-ID")
and edit the contents accordingly.  You should *never* edit the
"SITE-UNIQUE-ID" as it is in double-quote marks.  A valid, edited
value is:

    <constant id="SITE-UNIQUE-ID">DESY-HH</constant>



Testing the info provider
----

Once you have configured glue-1.3.xml to reflect your site's
configuration, you may test that the info provider produces meaningful
results.

Run the script:

  /opt/d-cache/libexec/infoProvider/info-based-infoProvider.sh

This should provide GLUE data in LDIF format, which should look like:

  #
  #  LDIF generated by Xylophone v0.1
  #
  #  XSLT processing using libxslt 1.0 (http://xmlsoft.org/XSLT/)
  #
  
  
  dn: GlueSEUniqueID=dcache-srm.example.org,mds-vo-name=resource,o=grid
  objectClass: GlueSETop
  objectClass: GlueSE
  objectClass: GlueKey
  objectClass: GlueSchemaVersion
  GlueSEStatus: Production
  GlueSEUniqueID: dcache-srm.example.org
  GlueSEArchitecture: multidisk
  GlueSEImplementationName: dcache
  [... etc ...]

The actual values you see will be site-specific and depend on the
contents of the glue-1.3.xml file and your dCache configuration.

To verify that there are no problems, redirect stdout to /dev/null to
show only the error messages

  /opt/d-cache/libexec/infoProvider/info-based-infoProvider.sh >/dev/null
  
If you see two error messages, repeated several times:

  error : Operation in progress
  warning: failed to load external entity "http://localhost:2288/info"

then verify that the httpd service is running, using the above wget
test and also by running:

  /opt/d-cache/bin/dcache status

If you see the single error messages, repeated several times:

  warning: failed to load external entity "http://localhost:2288/info"

then verify that the info service is running.



Decommissioning the old info provider
----

Sites that were previously using the old (Java-based) info provider
should ensure that they no longer use it.  This is because, if so
configured, GIP will attempt to use information from both the (new)
info-based info provider and the Java-based info provider and merge
the results.  This will likely lead to a confusing description of
dCache, which may prevent clients from working correctly.

The Java-based info provider has two configuration files and a
symbolic link within GIP.  They are:

  o    file: /opt/lcg/var/gip/ldif/lcg-info-static-SE.ldif

  o    file: /opt/lcg/var/gip/ldif/lcg-info-static-dSE.ldif

  o    symbolic link: /opt/glite/etc/gip/plugin to
       /opt/d-cache/jobs/infoDynamicSE-plugin-dcache.

The two files (lcg-info-static-SE.ldif and lcg-info-static-dSE.ldif)
may appear within a different directory if the static_dir variable is
configured.  You can find the static_dir variable in either
/opt/glite/etc/gip/glite-info-generic.conf or
/opt/lcg/etc/lcg-info-generic.conf

Delete the above three entries.

The directory defined in the static_dir variable
(/opt/lcg/var/gip/ldif by default) may contain other static LDIF
entries that are relics of previous info-providers.  These may have
filenames like static-file-SE.ldif.

Delete any files that contain information about dCache.

The infoProvider component of dCache, located within the
infoProviderDomain, collects information for the
infoDynamicSE-plugin-dcache program.  Since this program is now
obsolete the infoProvider should be switched off.  This may be
achieved by running the /opt/d-cache/bin/dcache script:

  /opt/d-cache/bin/dcache stop infoProvider

You can confirm that the infoProvider is no longer running by querying
the current status of the components:

  # /opt/d-cache/bin/dcache status | grep ^infoProvider
  infoProviderDomain      stopped         /var/log/infoProviderDomain.log

To prevent dCache from starting the infoProvider when the machine next
boots, you should edit /opt/d-cache/etc/node_config and ensure that
the infoProvider option is configured to "no".  You can verify that
infoProvider is no longer listed as a service:

  # /opt/d-cache/bin/dcache services | grep ^infoProvider

You should see no output from running the command.



Publishing information from (new) info-based info provider
----

By default BDII obtains fresh information by querying GIP.  To allow
BDII to obtain the GLUE information, you must tell GIP where to find
this information.  This is achieved by either copying the above script
into the directory /opt/glite/etc/gip/provider/

  cp /opt/d-cache/libexec/infoProvider/info-based-infoProvider.sh /opt/glite/etc/gip/provider/

or by symbolically linking the script in there:

  ln -s /opt/d-cache/libexec/infoProvider/info-based-infoProvider.sh /opt/glite/etc/gip/provider/

If GIP (glite-info-generic) and BDII are installed, and the BDII
daemons are running, then you will see the information appear in BDII
after a short delay (a minute or so).

You can verify the information is present with the query:

  ldapsearch -LLL -x -H ldap://localhost:2170 -b o=grid

This should give similar results to running the information provider
script manually.



Updating information
----

The information contained within the info service may take a short
time to achieve a complete overview of dCache's state.  For certain
gathered information it may take a few minutes before the information
stabilises.  This is intentional and prevents the gathering of
information from adversely affecting dCache's performance.

The information contained within the LDAP (a.k.a. "BDII") server is
updated periodically from the information contained in the info
service.  By default this is every 60 seconds.  This will introduce an
additional delay between a change in dCache's state and that
information propagating.

A few pieces of information are "hard-coded" within the glue-1.3.xml
file; that is, you will need to edit this file before the published
value(s) will change.  These values are ones that typically a
site-admin must choose independently of dCache's current operations.



Troubleshooting BDII problems
----

The BDII log files may show entries like:

   ==> slapadd: could not parse entry (line=26)
   Error nearby dn:
   GlueVOInfoLocalID=atl[...],o=grid ==>
   str2entry: invalid value for attributeType GlueSATotalOnlineSize #0
   (syntax 1.3.6.1.4.1.1466.115.121.1.27)

This kind of problem comes when BDII is attempting to inject new
information into the OpenLDAP server.  This server is rejecting some
of that information because it is badly formatted.  In this example,
"1.3.6.1.4.1.1466.115.121.1.27" is LDAP-speak for "an integer number".
The offending attribute has a value of "#0", which isn't an integer
number.

It seems that the "nearby dn" description of the report should be
ignored.  It is unclear how the decision is made about which object is
"nearby", but it's usually inaccurate.  Instead, the important piece
of information is the line number ("line=26" in above).  BDII injects
fresh information into the OpenLDAP server from a file and the line
number mentioned in the error message is from this file. 

The following two sections describe how to locate the injection file
for BDII v4 and v5.  When mentioning file locations, defaults have
been included in parentheses.  Since many sites deploy BDII with
minimal changes the default locations are likely correct.



Locating BDII v4 injection LDIF files:

The default location is /opt/bdii/var/cache/1/GIP.ldif

The file /opt/bdii/etc/bdii.conf contains various configuration
options for BDII; for example, if this file has the line
BDII_DIR=/opt/bdii then $bdii_dir is /opt/bdii.

The file $bdii_dir/etc/bdii-update.conf
(/opt/bdii/etc/bdii-update.conf) contains a list describing methods
for obtaining LDIF information.  When updating the contents of a
server, BDII will obtain LDIF information from each source and attempt
to inject the data into the OpenLDAP server.  bdii-update.conf is
likely to contain a single line:

    GIP file:///opt/glite/libexec/glite-info-wrapper

Each line has two parts.  The second part is a URI describing how to
obtain the data.  If the URI starts file:// (as above) then the file
is executed and the LDIF is taken from the process' stdout.  The first
part ("GIP" in above example) is used to specify the file-name for the
combined output ("GIP.ldif") within the $bdii_var_dir/cache directory
(/opt/bdii/var/cache) hierarchy.

The output from the various sources defined in bdii-update.conf is
stored as files within the $bdii_var-dir/cache/0 directory
(/opt/bdii/var/cache/0).  After fresh data is injected, the cache
directories are moved, so cache/0 becomes cache/1, cache/1 becomes
cache/2, and so on.  The result is that, after injecting, the LDIF
output will be in directory $bdii_var-dir/cache/1
(/opt/bdii/var/cache/1).



Locating BDII v5 injection LDIF files:

The default location is /var/bdii/old.ldif

As with BDII v4, the file /opt/bdii/etc/bdii.conf contains high-level
information, such as in which directories information will be stored.

The update process in BDII v5 is different from v4, so the generated
files are different.  With v5, BDII maintains knowledge of the current
state of the LDAP server in the file BDII_VAR_DIR/old.ldif
(/var/bdii/old.ldif).  It uses this information generate a description
of how to modify the local BDII server (by adding, removing and
modifying attributes and objects as necessary).



Once the injection LDIF file is located, the line number may be used
to discover which object is causing the problem, so enabling further
investigation.
