@@ -212,14 +212,16 @@ static struct crm_option long_options[] = {
212
212
},
213
213
{
214
214
"cleanup" , no_argument , NULL , 'C' ,
215
- "\t\tDelete failed operations from a resource's history allowing its current state to be rechecked .\n"
215
+ "\t\tIf resource has any past failures, clear its history and fail count .\n"
216
216
"\t\t\t\tOptionally filtered by --resource, --node, --operation, and --interval (otherwise all).\n"
217
+ "\t\t\t\t--operation and --interval apply to fail counts, but entire history is always cleared,\n"
218
+ "\t\t\t\tto allow current state to be rechecked.\n"
217
219
},
218
220
{
219
221
"refresh" , no_argument , NULL , 'R' ,
220
222
"\t\tDelete resource's history (including failures) so its current state is rechecked.\n"
221
- "\t\t\t\tOptionally filtered by --resource, --node, --operation, and --interval (otherwise all).\n"
222
- "\t\t\t\tUnless --force is specified, resource's group or clone (if any) will also be cleaned "
223
+ "\t\t\t\tOptionally filtered by --resource and --node (otherwise all).\n"
224
+ "\t\t\t\tUnless --force is specified, resource's group or clone (if any) will also be refreshed. "
223
225
},
224
226
{
225
227
"set-parameter" , required_argument , NULL , 'p' ,
@@ -438,7 +440,6 @@ main(int argc, char **argv)
438
440
bool require_resource = TRUE; /* whether command requires that resource be specified */
439
441
bool require_dataset = TRUE; /* whether command requires populated dataset instance */
440
442
bool require_crmd = FALSE; /* whether command requires connection to CRMd */
441
- bool just_errors = TRUE; /* whether cleanup command deletes all history or just errors */
442
443
443
444
int rc = pcmk_ok ;
444
445
int is_ocf_rc = 0 ;
@@ -630,8 +631,7 @@ main(int argc, char **argv)
630
631
if (cib_file == NULL ) {
631
632
require_crmd = TRUE;
632
633
}
633
- just_errors = FALSE;
634
- rsc_cmd = 'C' ;
634
+ rsc_cmd = 'R' ;
635
635
find_flags = pe_find_renamed |pe_find_anon ;
636
636
break ;
637
637
@@ -641,7 +641,6 @@ main(int argc, char **argv)
641
641
if (cib_file == NULL ) {
642
642
require_crmd = TRUE;
643
643
}
644
- just_errors = TRUE;
645
644
rsc_cmd = 'C' ;
646
645
find_flags = pe_find_renamed |pe_find_anon ;
647
646
break ;
@@ -1092,7 +1091,7 @@ main(int argc, char **argv)
1092
1091
rc = cli_resource_delete_attribute (rsc , rsc_id , prop_set , prop_id ,
1093
1092
prop_name , cib_conn , & data_set );
1094
1093
1095
- } else if (rsc_cmd == 'C' && just_errors ) {
1094
+ } else if (rsc_cmd == 'C' ) {
1096
1095
crmd_replies_needed = 0 ;
1097
1096
for (xmlNode * xml_op = __xml_first_child (data_set .failed ); xml_op != NULL ;
1098
1097
xml_op = __xml_next (xml_op )) {
@@ -1102,18 +1101,26 @@ main(int argc, char **argv)
1102
1101
const char * task_interval = crm_element_value (xml_op , XML_LRM_ATTR_INTERVAL );
1103
1102
const char * resource_name = crm_element_value (xml_op , XML_LRM_ATTR_RSCID );
1104
1103
1105
- if (resource_name == NULL ) {
1104
+ if (resource_name == NULL ) {
1106
1105
continue ;
1107
1106
} else if (host_uname && safe_str_neq (host_uname , node )) {
1108
1107
continue ;
1109
- } else if (rsc_id && safe_str_neq (rsc_id , resource_name )) {
1110
- continue ;
1111
1108
} else if (operation && safe_str_neq (operation , task )) {
1112
1109
continue ;
1113
1110
} else if (interval && safe_str_neq (interval , task_interval )) {
1114
1111
continue ;
1115
1112
}
1116
1113
1114
+ if (rsc_id ) {
1115
+ resource_t * fail_rsc = pe_find_resource_with_flags (data_set .resources ,
1116
+ resource_name ,
1117
+ find_flags );
1118
+
1119
+ if (!fail_rsc || safe_str_neq (rsc -> id , fail_rsc -> id )) {
1120
+ continue ;
1121
+ }
1122
+ }
1123
+
1117
1124
crm_debug ("Erasing %s failure for %s (%s detected) on %s" ,
1118
1125
task , rsc -> id , resource_name , node );
1119
1126
rc = cli_resource_delete (crmd_channel , node , rsc , task ,
@@ -1129,16 +1136,16 @@ main(int argc, char **argv)
1129
1136
start_mainloop ();
1130
1137
}
1131
1138
1132
- } else if ((rsc_cmd == 'C ' ) && rsc ) {
1139
+ } else if ((rsc_cmd == 'R ' ) && rsc ) {
1133
1140
if (do_force == FALSE) {
1134
1141
rsc = uber_parent (rsc );
1135
1142
}
1136
1143
1137
1144
crm_debug ("Re-checking the state of %s (%s requested) on %s" ,
1138
1145
rsc -> id , rsc_id , host_uname );
1139
1146
crmd_replies_needed = 0 ;
1140
- rc = cli_resource_delete (crmd_channel , host_uname , rsc , operation ,
1141
- interval , & data_set );
1147
+ rc = cli_resource_delete (crmd_channel , host_uname , rsc , NULL , 0 ,
1148
+ & data_set );
1142
1149
1143
1150
if (rc == pcmk_ok && BE_QUIET == FALSE) {
1144
1151
/* Now check XML_RSC_ATTR_TARGET_ROLE and XML_RSC_ATTR_MANAGED */
@@ -1149,7 +1156,7 @@ main(int argc, char **argv)
1149
1156
start_mainloop ();
1150
1157
}
1151
1158
1152
- } else if (rsc_cmd == 'C ' ) {
1159
+ } else if (rsc_cmd == 'R ' ) {
1153
1160
#if HAVE_ATOMIC_ATTRD
1154
1161
const char * router_node = host_uname ;
1155
1162
xmlNode * msg_data = NULL ;
0 commit comments