On Apr 5, 2007, at 4:48 PM, Alan Robertson wrote:

Alan Robertson wrote:
Lars Marowsky-Bree wrote:
On 2007-04-04T11:41:44, Doug Knight <[EMAIL PROTECTED]> wrote:

The key word in my question was "thinks". It would be useful to the RA if it could know what state the CRM thought it was in, so in case the RA determines on its own that its already in that state, it doesn't have to do anything. But, if the RA finds that the CRM thinks its in a different state, then the RA could set the CRM straight by calling the crm_master
with the appropriate value. Make sense?
No. The state the resource is in is not set via crm_master, but using
the exit code of the monitor operation.

You should only call crm_master when you wish to change the _preference_
for master-state.

But, I think you can use crm_master to retrieve your current preference,
and thereby eliminate unnecessary CIB updates.

Or maybe crm_master should do that filtering on its own??

Attached is a straightforward patch to crm_attribute.c which I believe
does this...

It also eliminates certain other "do-nothing" attribute changes -
because this code is shared by a few different commands.

I recognize that this is slightly less efficient for those cases where
the attribute is actually going to be changed, but it is _vastly_ more
efficient for those cases where the current value is correct - because
it eliminates triggering a computation cycle of the policy engine.

I would prefer to fix this in the CIB (by not always upping the version number unless something actually changed) This has been a long-standing issue which we know we need to work on - along with not syncing the status section.

And until then, why not just use -G to grab the current value and compare it with what you would have set? thats 2 lines of shell script...




--
    Alan Robertson <[EMAIL PROTECTED]>

"Openness is the foundation and preservative of friendship...  Let me
claim from you at all times your undisguised opinions." - William
Wilberforce
diff -r b19bcdc3efa8 crm/admin/crm_attribute.c
--- a/crm/admin/crm_attribute.c Thu Apr 05 08:29:57 2007 -0600
+++ b/crm/admin/crm_attribute.c Thu Apr 05 08:41:07 2007 -0600
@@ -245,9 +245,9 @@ main(int argc, char **argv)
                rsc_id = getenv("OCF_RESOURCE_INSTANCE");

                if(rsc_id == NULL && dest_node == NULL) {
-                       fprintf(stderr, "This program should only ever be "
+                       fprintf(stderr, "This program should normally be "
                                "invoked from inside an OCF resource agent.\n");
- fprintf(stderr, "DO NOT INVOKE MANUALLY FROM THE COMMAND LINE. \n"); + fprintf(stderr, "It is normally an error to invoke it from the command line\n");
                        return 1;

                } else if(dest_node == NULL) {
@@ -350,20 +350,6 @@ main(int argc, char **argv)
XML_CIB_TAG_CRMCONFIG, NULL, NULL, NULL, "last-lrm- refresh", now_s);
                        crm_free(now_s);
                }
-                       
-       } else if(DO_WRITE) {
-               int cib_opts = cib_sync_call;
-               CRM_DEV_ASSERT(type != NULL);
-               CRM_DEV_ASSERT(attr_name != NULL);
-               CRM_DEV_ASSERT(attr_value != NULL);
-
-               if(inhibit_pe) {
-                       crm_warn("Inhibiting notifications for this update");
-                       cib_opts |= cib_inhibit_notify;
-               }
-               rc = update_attr(the_cib, cib_opts, type, dest_node, set_name,
-                                attr_id, attr_name, attr_value);
-
        } else {
                char *read_value = NULL;
                rc = read_attr(the_cib, type, dest_node, set_name,
@@ -385,9 +371,28 @@ main(int argc, char **argv)
                                attr_name?"name=":"", attr_name?attr_name:"",
                                read_value?read_value:"(null)");

-               } else if(read_value != NULL) {
+               } else if(read_value != NULL && ! DO_WRITE) {
                        fprintf(stdout, "%s\n", read_value);
                }
+               if (DO_WRITE) {
+                       if (read_value != NULL && strcmp(read_value, 
attr_value) == 0 ){
+                               crm_info("%s: Attribute %s=%s is unchanged",
+                                       __FUNCTION__, attr_name, attr_value);
+                       }else{
+                               int cib_opts = cib_sync_call;
+                               CRM_DEV_ASSERT(type != NULL);
+                               CRM_DEV_ASSERT(attr_name != NULL);
+                               CRM_DEV_ASSERT(attr_value != NULL);
+
+                               if(inhibit_pe) {
+                                       crm_warn("Inhibiting notifications for this 
update");
+                                       cib_opts |= cib_inhibit_notify;
+                               }
+                               rc = update_attr(the_cib, cib_opts, type, 
dest_node, set_name,
+                                        attr_id, attr_name, attr_value);
+                       }
+               }
+
        }
        the_cib->cmds->signoff(the_cib);
        if(rc != cib_ok) {

_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/

Reply via email to