problems with bundle cache in Karaf 4 tmp dir

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

problems with bundle cache in Karaf 4 tmp dir

Frank_S
Hi,

we have written our own URLStreamHandlerService to handle custom urls. The
urls are of the form "almscp://<user>@<host>:<port>/<remote path to a bundle
jar>;keyfile=<ssh keyfile path>,passphrase=<ssh key passphrase>"
for example :
"almscp://ikan@ikan514v:22//opt/ikan/alm5_8_frs/system/phaseCatalog/com.ikanalm.phase.echowebtestparameters/com.ikanalm.phase.echowebtestparameters-1.0.0.jar;keyfile=/home/ikan/.ssh/id_rsa,passphrase=pass"

when we try to install a feature using such an url from a generated feature
repository, like :

<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1"
name="com.ikanalm.phase.echowebtestparameters1.0.0_1517241731122">
  <feature name="com.ikanalm.phase.echowebtestparameters" version="1.0.0">
   
<bundle>almscp://ikan@ikan514v:22//opt/ikan/alm5_8_frs/system/phaseCatalog/com.ikanalm.phase.echowebtestparameters/com.ikanalm.phase.echowebtestparameters-1.0.0.jar;keyfile=/home/ikan/.ssh/id_rsa,passphrase=pass</bundle>
  </feature>
</features>

The feature and bundle are installed ok, but in the $karaf.data/tmp dir, a
file was created with the name "id_rsa,passphrase=pass".
Now, if we try to install another feature, also using an almscp:// url, for
example with bundle name/version
com.ikanalm.phase.echowebtestparameters-2.0.0.jar, then the 2.0.0 bundle
should also be copied to the tmp dir.
However, since the filename that is generated for the 2.0.0 bundle is also
"id_rsa,passphrase=pass", the 2.0.0 bundle is never copied. Instead, karaf
reinstalls the 1.0.0 bundle and then claims that feature 2.0.0 has been
installed.
At this point, we see that feature 1.0.0 and feature 2.0.0 are installed,
but only bundle 1.0.0 is installed.

This happens for every feature of which the bundle url happens to end with
"id_rsa,passphrase=pass". Thus our bundles don't get installed properly.

What part is responsible for creating the file in the $karaf.data/tmp dir ?
Is it Karaf or Felix or something else ? I tried to track it down in the
Karaf source code, but I couldn't find a spot where files got written to the
tmp dir.

If the generated temporary file was deleted from the tmp dir after the
feature was installed, this wouldn't be a problem. Is there a way to change
this behaviour ?

We are using Karaf 4.0.7

Thanks,
Frank 'S Jegers.




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
Reply | Threaded
Open this post in threaded view
|

Re: problems with bundle cache in Karaf 4 tmp dir

jbonofre
Hi Frank,

${karaf.data}/tmp is actually define by the java.io.tmpdir system property (you
can find it in the bin/karaf script for instance).

So, any code that you java.io.tmpdir will end into ${karaf.data}/tmp.

Regards
JB

On 01/30/2018 03:56 PM, Frank_S wrote:

> Hi,
>
> we have written our own URLStreamHandlerService to handle custom urls. The
> urls are of the form "almscp://<user>@<host>:<port>/<remote path to a bundle
> jar>;keyfile=<ssh keyfile path>,passphrase=<ssh key passphrase>"
> for example :
> "almscp://ikan@ikan514v:22//opt/ikan/alm5_8_frs/system/phaseCatalog/com.ikanalm.phase.echowebtestparameters/com.ikanalm.phase.echowebtestparameters-1.0.0.jar;keyfile=/home/ikan/.ssh/id_rsa,passphrase=pass"
>
> when we try to install a feature using such an url from a generated feature
> repository, like :
>
> <features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1"
> name="com.ikanalm.phase.echowebtestparameters1.0.0_1517241731122">
>   <feature name="com.ikanalm.phase.echowebtestparameters" version="1.0.0">
>    
> <bundle>almscp://ikan@ikan514v:22//opt/ikan/alm5_8_frs/system/phaseCatalog/com.ikanalm.phase.echowebtestparameters/com.ikanalm.phase.echowebtestparameters-1.0.0.jar;keyfile=/home/ikan/.ssh/id_rsa,passphrase=pass</bundle>
>   </feature>
> </features>
>
> The feature and bundle are installed ok, but in the $karaf.data/tmp dir, a
> file was created with the name "id_rsa,passphrase=pass".
> Now, if we try to install another feature, also using an almscp:// url, for
> example with bundle name/version
> com.ikanalm.phase.echowebtestparameters-2.0.0.jar, then the 2.0.0 bundle
> should also be copied to the tmp dir.
> However, since the filename that is generated for the 2.0.0 bundle is also
> "id_rsa,passphrase=pass", the 2.0.0 bundle is never copied. Instead, karaf
> reinstalls the 1.0.0 bundle and then claims that feature 2.0.0 has been
> installed.
> At this point, we see that feature 1.0.0 and feature 2.0.0 are installed,
> but only bundle 1.0.0 is installed.
>
> This happens for every feature of which the bundle url happens to end with
> "id_rsa,passphrase=pass". Thus our bundles don't get installed properly.
>
> What part is responsible for creating the file in the $karaf.data/tmp dir ?
> Is it Karaf or Felix or something else ? I tried to track it down in the
> Karaf source code, but I couldn't find a spot where files got written to the
> tmp dir.
>
> If the generated temporary file was deleted from the tmp dir after the
> feature was installed, this wouldn't be a problem. Is there a way to change
> this behaviour ?
>
> We are using Karaf 4.0.7
>
> Thanks,
> Frank 'S Jegers.
>
>
>
>
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html
>

--
Jean-Baptiste Onofré
[hidden email]
http://blog.nanthrax.net
Talend - http://www.talend.com
Reply | Threaded
Open this post in threaded view
|

Re: problems with bundle cache in Karaf 4 tmp dir

Frank_S
Hi,

yes, I noticed that java.io.tmpdir was set to ${karaf.data}/tmp. Since we
control the Karaf installation, we can make sure it is always set to
${karaf.data}/tmp, so that shouldn't be a problem.
The question is what filename is going to be used in that tmp dir. If I have
to cleanup the temp file after the feature is installed, I need to know the
filename. Clearing out the entire ${karaf.data}/tmp after each feature
install seems like a bad idea.

Empirically, I see that the url
almscp://ikan@ikan514v:22//opt/ikan/alm5_8_frs/system/phaseCatalog/com.ikanalm.phase.echowebtestparameters/com.ikanalm.phase.echowebtestparameters-1.0.0.jar;keyfile=/home/ikan/.ssh/id_rsa,passphrase=pass
maps to a file named "id_rsa,passphrase=pass"

and
almftp://administrator:*****@ikan143/alm5_8/system/phase
Catalog/echoParam5/echoParam5-1.1.0.jar;mode=p
maps to "echoParam5-1.1.0.jar;mode=p"

and
file://ikan143/alm5_8/system/phase%20Catalog/echoParam5/echoParam5-1.1.0.jar
maps to "echoParam5-1.1.0.jar"

So I'm assuming that the filename is the part of the URL after the last
occurrence of "/". But I'd like to verify this in the source code (or by one
of you telling me), so as to be sure.

Thanks,
Frank 'S Jegers.




--
Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html