>>> Lars Marowsky-Bree <[email protected]> schrieb am 16.02.2015 um 12:34 in Nachricht <[email protected]>: > On 2015-02-16T09:20:22, Kristoffer Grönlund <[email protected]> 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.
So far I was assuming we are talking about "stopping a stopped resource", not "stopping a non-existing resource". I thought that crm shell would clearly distinguish between those. The latter should be an error, of course. > > Compare the Unix-as-little-else rm command; rm -f /tmp/idontexist will > give an error code. You are wrong: windl@v04:~> rm -f /tmp/foobar windl@v04:~> echo $? 0 > > Now a caller of crmsh has to *parse the output* to know whether the > delete command succeeded or not, which is rather non-trivial. Well ,doesn't crm shell parse the CIB all the time? If so it should be able to find out whether the resource is still there. Anyway now you are talking about deleting a resource while the subject is on stopping a stopped resource. > > If the caller doesn't care whether the command succeeded or not, it > should be the caller that ignores the error code. Who is "the caller" for you now? I don't quite get is: The caller of crm shell, or the crm shell? > > Or if you want to get real fancy, return different exit codes for > "referenced object does not exist", or "generic syntax error". I Agree. > >> >> 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 I'm not happy with the error messages: Whil technically quite correct, they are confusing for the user: If the resource doesn't exist, can't crm shell find out before trying to create/apply a diff? And "apparently failed": Did it, or didn't it? crm shell should be able to find out! > > And, yeah, well, this shouldn't happen. Here idempotency applies ;-) Sometimes 90% of the code are about things that shouldn't happen; if they do, it's good to have that code ;-) Regards, Ulrich _______________________________________________ Linux-HA mailing list [email protected] http://lists.linux-ha.org/mailman/listinfo/linux-ha See also: http://linux-ha.org/ReportingProblems
