[augeas-devel] Why does Augeas fail to handle empty files?

Mol, Xavier (SCC) xavier.mol at kit.edu
Tue Feb 23 08:49:23 UTC 2016


Hello David,

 

attached you can find my custom lens that I was talking about.

 

I don't know how to simulate my test cases with this lens through Augeas unit tests, I'm sorry. I'm afraid, that this problem will not be reproducable with them.

 

This module contains two different definitions for the final lens 'lns':

 

- let lns = properties? . ( filler | domain )*

Using this definition, the lens fails to update empty files. It can be used to create new files and update existing non-empty files just fine. To reproduce the error (after you have imported the lens), create an empty file before running augtool (e.g. with 'touch /etc/dcache/layouts/empty.conf', which will be autoloaded, or any other location – you know how to do that ;-) ).

 

- let lns = ( properties? . ( filler | domain )* )?

This definition can handle existing empty files, but augparse generates a huge error that I won't paste here ("illegal optional expression: /…/ matches the empty word").

 

 

If I had any suspicion on what exactly is the problem for this lens, I would have reduced it to that. I'm sorry that you are faced with the full module definition now. Please don't hesitate to ask any questions regarding the definitions or how the configuration files it produces should look like.

 

Thank you for your time!

 

Ciao,

Xavier.

 

From: David Lutterkort [mailto:lutter at watzmann.net] 
Sent: Tuesday, February 23, 2016 12:38 AM
To: Mol, Xavier (SCC)
Cc: Raphaël Pinson; augeas-devel at redhat.com
Subject: Re: [augeas-devel] Why does Augeas fail to handle empty files?

 

Hi Xavier,

this is indeed a bit strange. Is there any way you could send your lens, maybe together with some test cases along the lines of 'test lns get "" = * (* Stuff totally blows up here unexpectedly *)' or similar ?

David

 

On Fri, Feb 12, 2016 at 3:49 AM, Mol, Xavier (SCC) <xavier.mol at kit.edu> wrote:

Hi Raphaël.

 

> An empty file contains "\n", not "".

So what you are saying is, that Augeas doesn't understand the concept of empty files? It will always interpret them as beeing filled with an empty line (which translates into an empty tree node)?

 

Even though, that doesn't explain my question what the difference between

 

let lns = properties? . ( filler | domain )*

 

and

 

let lns = ( properties? . ( filler | domain )* )?

 

is.

 

Ciao,

Xavier.

 

 

 

From: Raphaël Pinson [mailto:raphael.pinson at camptocamp.com] 
Sent: Friday, February 12, 2016 11:00 AM
To: Mol, Xavier (SCC)
Cc: augeas-devel at redhat.com
Subject: Re: [augeas-devel] Why does Augeas fail to handle empty files?

 

 

 

On Fri, Feb 12, 2016 at 10:57 AM, Mol, Xavier (SCC) <xavier.mol at kit.edu> wrote:

Hi again.

 

> let lns = ( properties? . ( filler | domain )* )?

One more note on this: After I have changed this line, augparse compains that a very complicated regular expression "matches the empty word", which actually is the point of the exercise.

 

It shouldn't be. An empty file contains "\n", not "".

 

 

Raphaël

 

 

 

 

From: augeas-devel-bounces at redhat.com [mailto:augeas-devel-bounces at redhat.com] On Behalf Of Mol, Xavier (SCC)
Sent: Friday, February 12, 2016 9:13 AM
To: augeas-devel at redhat.com
Subject: [augeas-devel] Why does Augeas fail to handle empty files?

 

Hello Augeas experts,

 

this issue was mentioned in a previous mail thread on this list (see attached final mail) and I've run into it again: Augeas seems to be quite strict about empty files (as opposed to non-existing files).

 

I have a lens defined like this 'let lns = properties? . ( filler | domain )*'. The actual meaning of the sub-lenses is not important right now, since per regular expression this should successfully match the void. It indeed does create new files, but it fails to update empty files and this is the error message I get:

 

"""

[root ~]# >/etc/dcache/layouts/f01-151-109-e.conf

[root ~]# augtool

augtool> print /files/etc/dcache/layouts/f01-151-109-e.conf

/files/etc/dcache/layouts/f01-151-109-e.conf

augtool> set /files/etc/dcache/layouts/f01-151-109-e.conf/properties/dcache.java.memory.heap 2g

augtool> print /files/etc/dcache/layouts/f01-151-109-e.conf

/files/etc/dcache/layouts/f01-151-109-e.conf

/files/etc/dcache/layouts/f01-151-109-e.conf/properties

/files/etc/dcache/layouts/f01-151-109-e.conf/properties/dcache.java.memory.heap = "2g"

augtool> save

error: Failed to execute command

saving failed (run 'errors' for details)

augtool> errors

Error in /etc/dcache/layouts/f01-151-109-e.conf (put_failed)

  Failed to match

        { /properties/ }?

(    { /#comment/ = /[^\001-\004\t\n\r ][^\001-\004\n]*[^\001-\004\t\n\r ]|[^\001-\004\t\n\r ]/ }

      | { }

      | { /domain/ = /[$.0-9A-Z_a-{}-]+/ })*

  with tree

    {  } { "properties" }

  Lens: /var/lib/puppet/lib/augeas/lenses/dcachelayout.aug:29.12-.46:

"""

 

For some reason, there is an empty node before the properties node, which failes the put direction. For that the lens needs to be written like…

 

let lns = ( properties? . ( filler | domain )* )?

 

As far as regular expressions go, there is no effective change here, right? Yet for Augeas this clearly seems to make a difference. Can someone maybe explain this to me?

 

Thank you for your time,

Xavier.

 

 

****

Karlsruher Institute of Technology (KIT)

Steinbuch Centre for Computing (SCC)

 

B. Sc. Xavier Mol

GridKa Storage Administrator and Support Manager

 

Hermann-von-Helmholtz-Platz 1

Geb. 449

76344 Eggenstein-Leopoldshafen

Phone: +49 721 608 23041 <tel:%2B49%20721%20608%2023041> 

Email:  <mailto:xavier.mol at kit.edu> xavier.mol at kit.edu

 <http://www.kit.edu/> www.kit.edu

KIT - University of the State of Baden-Württemberg and National Large-scale Research Center of the Helmholtz Association

"Since 2010, the KIT has been certified as a family-friendly university."

****

 

 


_______________________________________________
augeas-devel mailing list
augeas-devel at redhat.com
https://www.redhat.com/mailman/listinfo/augeas-devel





 

-- 

Raphaël Pinson

Infrastructure Developer & Training Leader

+33 458 482 013

 

Camptocamp France
Savoie Technolac
BP 352
48, avenue du Lac du Bourget
73372 Le Bourget du Lac, Cedex
www.camptocamp.com


_______________________________________________
augeas-devel mailing list
augeas-devel at redhat.com
https://www.redhat.com/mailman/listinfo/augeas-devel

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20160223/fef022cd/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dcachelayout_old.aug
Type: application/octet-stream
Size: 1147 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20160223/fef022cd/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6401 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/augeas-devel/attachments/20160223/fef022cd/attachment.p7s>


More information about the augeas-devel mailing list