Hi Dan, On 04/03/2012 15:24, Daniel V. Klein wrote: > Jonathan- > > Looking naively at FnCallNow() in evalfunction.c, I believe you are correct > in your suspicion that cf-agent uses the start time as "now". Now, I say > "naively" because I am not that familiar with the Cfengine core code, and I > have a not-quite up-to-date version. For a long-running agent, this is > possibly a mistake, and I suggest the developers look at it (and either > change the code or the documentation, because it is not a true bug, it is > merely a confusing feature).
Thanks for looking into this. > However, there being two sides to every coin (and sometimes three or four), I > notice that you are using mtime in your file_select body, which is the > modification time of the file. In this case, I think that you need to add > ctime into the mix. If you change the contents of a file, you change both > the ctime and mtime, but if you just change the permissions, you only change > the ctime. Do you want the time a file was changed? Or created/perm-changed? Well, I'm mostly interested in there not being unexpected behavior in CFEngine, but I am indeed interested in the mtime - when the contents of the file changed. > The third side of the coin is that I don't see how either "bug" will cause > your problem. Unless you started cf-agent 30 days ago, your > currently-being-modified files should not be selected (and even though > cf-execd may be old, each run of cf-agent starts anew). I think that the "sloppy" selection may happen at the other end of the interval. Note the expression in the select_files body: "between 'now' and 30 days ago". So consider CFEngine starts running at 01:40. This statement would then be roughly equivalent to "mtime < 01:40 Today && mtime < 01:40 30 days ago". But, what if cf-agent takes several minutes to run, and my file is changed at the same time. It's mtime is then 01:41, so not "< 01:40" ! I think this maybe where the use of 'now' is confusing. Thinking about a possible fix, maybe the code could only use the "if mtime < 30 days ago" part, and ignore the "mtime < now" part, as this should always be in the case. I have no idea how to go about this, for now anyway, though. > Finally, with the fourth side bringing us from coins to Euclidean solids, > look at your file_select body. What you have is legal and I think correct, > but I feel it would be clearer as what follows (changing the easy to miss > negation, and changing the mtime range): > > body file_select date_pattern(age, pattern) > { > mtime => irange(0, ago(0,0,"$(age)",0,0,0)); > leaf_name => { "$(pattern)" }; > > file_result => "leaf_name.mtime"; > } > > This might change the behavior, but I don't think so. At least I hope not. > But try it, and let me know... Agreed, but I don't think it should change the behaviour, either. I'll give it a try. Thanks for considering this! Jonathan _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine