File pacemaker-tools-clean-up-dry-run-correctly.patch of Package pacemaker.openSUSE_Leap_42.3_Update

commit f0c29a2301c5feeb9d3fbd576bc5161ec71acf9f
Author: Ken Gaillot <kgaillot@redhat.com>
Date:   Thu Nov 2 15:02:02 2017 -0500

    Low: tools: implement clean-up dry-run correctly
    
    047a6611 implemented a dry-run for clean-ups using cli_resource_delete(), but
    overlooked that crmd_channel is independently needed by atomic-attrd
    host clean-ups and --fail.

Index: pacemaker-1.1.16+20170320.77ea74d/tools/crm_resource.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/tools/crm_resource.c
+++ pacemaker-1.1.16+20170320.77ea74d/tools/crm_resource.c
@@ -415,6 +415,7 @@ main(int argc, char **argv)
     const char *longname = NULL;
     const char *operation = NULL;
     const char *interval = NULL;
+    const char *cib_file = getenv("CIB_file");
     GHashTable *override_params = NULL;
 
     char *xml_file = NULL;
@@ -614,7 +615,9 @@ main(int argc, char **argv)
             case 'P':
                 crm_log_args(argc, argv);
                 require_resource = FALSE;
-                require_crmd = TRUE;
+                if (cib_file == NULL) {
+                    require_crmd = TRUE;
+                }
                 rsc_cmd = 'C';
                 break;
 
@@ -788,7 +791,7 @@ main(int argc, char **argv)
     }
 
     /* Establish a connection to the CRMd if needed */
-    if (getenv("CIB_file") == NULL && require_crmd) {
+    if (require_crmd) {
         xmlNode *xml = NULL;
         mainloop_io_t *source =
             mainloop_add_ipc_client(CRM_SYSTEM_CRMD, G_PRIORITY_DEFAULT, 0, NULL, &crm_callbacks);
@@ -1155,6 +1158,13 @@ main(int argc, char **argv)
             }
         }
 
+        if (crmd_channel == NULL) {
+            printf("Dry run: skipping clean-up of %s due to CIB_file\n",
+                   host_uname? host_uname : "all nodes");
+            rc = pcmk_ok;
+            goto bail;
+        }
+
         msg_data = create_xml_node(NULL, "crm-resource-reprobe-op");
         crm_xml_add(msg_data, XML_LRM_ATTR_TARGET, host_uname);
         if (safe_str_neq(router_node, host_uname)) {
Index: pacemaker-1.1.16+20170320.77ea74d/tools/crm_resource_runtime.c
===================================================================
--- pacemaker-1.1.16+20170320.77ea74d.orig/tools/crm_resource_runtime.c
+++ pacemaker-1.1.16+20170320.77ea74d/tools/crm_resource_runtime.c
@@ -651,8 +651,9 @@ cli_resource_delete(crm_ipc_t *crmd_chan
         return -EOPNOTSUPP;
     }
 
-    if(getenv("CIB_file") != NULL) {
-        printf("Would have cleaned up %s on %s\n", rsc->id, host_uname);
+    if (crmd_channel == NULL) {
+        printf("Dry run: skipping clean-up of %s on %s due to CIB_file\n",
+               rsc->id, host_uname);
         return rc;
      }
 
openSUSE Build Service is sponsored by