On Mon, Feb 16, 2015 at 01:12:55PM +0100, Kristoffer Grönlund wrote: > Lars Marowsky-Bree <l...@suse.com> writes: > > > On 2015-02-16T09:20:22, Kristoffer Grönlund <kgronl...@suse.com> wrote: > > > >> Actually, I decided that it does make sense to return 0 as the error > >> code even if the resource to delete doesn't exist, so I pushed a commit > >> to change this. The error message is still printed, though. > > > > I'm not sure I agree, for once. > > > > Idempotency is for resource agent operations, not necessarily all > > operations everywhere. Especially because crmsh doesn't know whether the > > object doesn't exist because it was deleted, or because it was > > misspelled.
That's a good point. > > Compare the Unix-as-little-else rm command; rm -f /tmp/idontexist will > > give an error code. I guess you meant that it won't. > > Now a caller of crmsh has to *parse the output* to know whether the > > delete command succeeded or not, which is rather non-trivial. > > > > If the caller doesn't care whether the command succeeded or not, it > > should be the caller that ignores the error code. > > > > Or if you want to get real fancy, return different exit codes for > > "referenced object does not exist", or "generic syntax error". > > I suppose the point of argument is the definition of success here. If > asked to remove something and that something does not exist, is that > success? That sounds like a philosophical question :) > But, maybe you are right! Doing all of the removes at once would also > solve this use case, with the added benefit of performing the remove > with a single CIB modification. > > If Dejan also votes to revert this change, I will do so. Must say that I somehow missed the change. The most useful thing to do seems be to exit with 0 in case --force (or crm -F) is in effect (perhaps to suppress the error message too), just like "rm -f", which Lars brought up. Otherwise to keep the existing behaviour (error code, error message). > As a sidenote, I find the automatic removal of related constraints > somewhat strange... What good could there be from a constraint if the referenced resource left the stage? I may have found the idea strange too, but then ended up with an illegal CIB, which was not the best way forward either. To the best of my knowledge, crm_verify doesn't allow constraints pointing to nowhere. > To continue the filesystem analogy, it is as if soft > links would be deleted when the file they point to is removed. ;) > > > > >> >> Following fails with the current crmsh (e4b10ee). > >> >> # crm resource stop cl-http-lv > >> >> # crm resource stop cl-http-lv > >> >> ERROR: crm_diff apparently failed to produce the diff (rc=0) > >> >> ERROR: Failed to commit updates to cl-http-lv > >> >> # echo $? > >> >> 1 > > > > And, yeah, well, this shouldn't happen. Here idempotency applies ;-) It's not intentional really. This is a bug when interpreting the result of a crm_diff(1) invocation. But I think that Kristoffer already fixed it. Thanks, Dejan > > > > > > Regards, > > Lars > > > > -- > > Architect Storage/HA > > SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Jennifer Guild, > > Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nürnberg) > > "Experience is the name everyone gives to their mistakes." -- Oscar Wilde > > > > _______________________________________________ > > Linux-HA mailing list > > Linux-HA@lists.linux-ha.org > > http://lists.linux-ha.org/mailman/listinfo/linux-ha > > See also: http://linux-ha.org/ReportingProblems > > > > -- > // Kristoffer Grönlund > // kgronl...@suse.com > _______________________________________________ > Linux-HA mailing list > Linux-HA@lists.linux-ha.org > http://lists.linux-ha.org/mailman/listinfo/linux-ha > See also: http://linux-ha.org/ReportingProblems _______________________________________________ Linux-HA mailing list Linux-HA@lists.linux-ha.org http://lists.linux-ha.org/mailman/listinfo/linux-ha See also: http://linux-ha.org/ReportingProblems