Changeset 41172 for trunk/Nebulous/lib
- Timestamp:
- Nov 27, 2019, 12:04:14 PM (7 years ago)
- Location:
- trunk/Nebulous/lib/Nebulous
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Nebulous/lib/Nebulous/Client.pm
r40680 r41172 209 209 }, 210 210 ); 211 211 212 212 $log->debug( "entered - @_" ); 213 213 … … 310 310 my $stats = $self->stat($key); 311 311 my $instances = $stats->[6]; 312 312 313 if ((not defined $instances) or ($instances == 0)) { 313 314 $self->set_err("can not cull - no instances"); … … 315 316 return; 316 317 } 317 if ($instances < $min_copies) {318 if ($instances <= $min_copies) { 318 319 $self->set_err("can not cull - not enough instances"); 319 320 $log->debug("leaving"); 320 321 321 return; 322 322 } … … 334 334 335 335 unless (defined $locations) { 336 $self->set_err( "no instances" );337 336 $log->debug( "leaving" ); 338 339 337 return; 340 338 } … … 351 349 } 352 350 } 351 353 352 # If we don't have two copies on one volume, see if we have two copies on a single 354 353 # cabinet. If so, delete the first of those copies. … … 362 361 } 363 362 } 363 364 364 # Fail-safe. We didn't have any duplicates (the instances are "well-mixed"), so 365 365 # delete the first. … … 403 403 eval { 404 404 # first - strip off any inaccesible instances 405 # these are not counted in the 'removed' number 405 406 if (not defined $self->prune($key)) { 406 407 # use the prune() method to also determine if $key is valid 407 408 die "invalid key: $key"; 408 409 } 409 410 # check to see if there is an instance on $vol_name that should be the 411 # sole survivor 410 411 # check to see if there is an instance on $vol_name that 412 # should be the sole survivor. This is a bit dangerous : what 413 # if the only instance is on an invalid volume? what if an 414 # invalid volume is specified? 415 412 416 if (defined $vol_name) { 413 417 $locations = $self->find_instances($key, $vol_name); 418 if (not defined $locations) { 419 die "no instances on requested node"; 420 } 421 if (scalar @$locations == 0) { 422 die "no instances on requested node"; 423 } 414 424 } 415 425 … … 418 428 419 429 if (defined $locations) { 420 my $instances = $self->find_instances($key, undef, 'find them all'); 421 if (scalar @$instances == 1) { 422 # only one instance nothing to do 423 return 0; 424 } 425 if (scalar @$instances == 0) { 430 print "dev: looking for undef volume instances\n"; 431 # first delete the valid instances (except the one we own) 432 my $instances_valid = $self->find_instances($key, undef, 0); # find all valid instances 433 if (not defined $instances_valid) { 434 # there should have been at least one valid instance? 426 435 die "no instances"; 427 436 } 428 foreach my $victim (@$instances) { 429 next if $victim eq $locations->[0]; 430 $self->delete_instance($key, $victim); 431 $removed++; 437 if (scalar @$instances_valid == 0) { 438 # there should have been at least one valid instance? 439 die "no instances"; 432 440 } 441 442 # we have more than one instance, delete the others 443 if (scalar @$instances_valid > 1) { 444 foreach my $victim (@$instances_valid) { 445 next if $victim eq $locations->[0]; 446 $self->delete_instance($key, $victim); 447 $removed ++; 448 } 449 } 450 # the prune above should have deleted any invalid instances, so we only 451 # need to worry about the valid instances; 433 452 } else { 434 453 # nuke whatever … … 448 467 } 449 468 } 450 451 469 }; 452 470 if ($@) { … … 663 681 if ($response->fault) { 664 682 $self->set_err($response->faultstring); 683 684 ## invalid object key 685 if ($response->faultstring =~ /is valid object key/) { 686 $log->debug( "leaving" ); 687 die "invalid key $key, fails 'is valid object key' test\n"; 688 } 689 690 ## invalid object key 691 if ($response->faultstring =~ /xattr is in user. namespace/) { 692 $log->debug( "leaving" ); 693 die "invalid xattr key $name : fails 'xattr is in user. namespace' test\n"; 694 } 695 665 696 $log->logdie("unhandled fault - ", $self->err); 666 697 } … … 690 721 if ( $response->fault ) { 691 722 $self->set_err($response->faultstring); 723 724 ## invalid object key 725 if ($response->faultstring =~ /is valid object key/) { 726 $log->debug( "leaving" ); 727 die "invalid key $key, fails 'is valid object key' test\n"; 728 } 729 730 ## invalid xattr key (not in user. namespace) 731 if ($response->faultstring =~ /xattr is in user. namespace/) { 732 $log->debug( "leaving" ); 733 die "xattr $name is invalid : xattr is in user. namespace\n"; 734 } 735 736 ## invalid xattr key 737 if ($response->faultstring =~ /user\..*? does not exist/) { 738 $log->debug( "leaving" ); 739 die "xattr key $name not found : xattr $name does not exist\n"; 740 } 692 741 $log->logdie("unhandled fault - ", $self->err); 693 742 } … … 747 796 if ( $response->fault ) { 748 797 $self->set_err($response->faultstring); 798 799 ## invalid object key 800 if ($response->faultstring =~ /is valid object key/) { 801 $log->debug( "leaving" ); 802 die "invalid key $key, fails 'is valid object key' test\n"; 803 } 804 805 ## invalid xattr key (not in user. namespace) 806 if ($response->faultstring =~ /xattr is in user. namespace/) { 807 $log->debug( "leaving" ); 808 die "xattr $name is invalid : xattr is in user. namespace\n"; 809 } 810 811 ## invalid xattr key 812 if ($response->faultstring =~ /user\..*? does not exist/) { 813 $log->debug( "leaving" ); 814 die "xattr key $name not found : xattr $name does not exist\n"; 815 } 816 749 817 $log->logdie("unhandled fault - ", $self->err); 750 818 } … … 865 933 unless(defined($params[0])) { 866 934 $params[0] = hostname() . ".0"; 867 #print STDERR "Setting host to $params[0]\n";935 # print STDERR "Setting host to $params[0]\n"; 868 936 } 869 937 … … 871 939 if ( $response->fault ) { 872 940 $self->set_err($response->faultstring); 941 873 942 # check to see if this failure is because $key doesn't exist 874 943 if ($response->faultstring =~ /is valid object key/) { … … 878 947 # key is valid but no instances are on the specified volume 879 948 if ($response->faultstring =~ /no instances on storage volume/) { 949 $log->debug( "leaving" ); 950 return; 951 } 952 # check to see if this failure is volume is unknown 953 if ($response->faultstring =~ /is not a valid volume name/) { 954 $log->debug( "leaving" ); 955 return; 956 } 957 # key is valid but no instances are on the specified volume 958 if ($response->faultstring =~ /no instances available for key/) { 880 959 $log->debug( "leaving" ); 881 960 return; … … 949 1028 $self->set_err($response->faultstring); 950 1029 # check to see if this failure is because $key doesn't exist 1030 my $string = $response->faultstring; 951 1031 if ($response->faultstring =~ /is valid object key/) { 1032 $self->set_err("invalid object key"); 952 1033 $log->debug( "leaving" ); 953 1034 return; … … 955 1036 # key is valid but no instances are on the specified volume 956 1037 if ($response->faultstring =~ /no instances on storage volume/) { 1038 $self->set_err("no instances on storage volume or volume is not available"); 957 1039 $log->debug( "leaving" ); 958 1040 return; … … 972 1054 973 1055 1056 ## this is used by PS:IPP:Config nebulous functions 974 1057 sub find 975 1058 { … … 1014 1097 return $path; 1015 1098 } 1016 1017 1099 1018 1100 sub open … … 1124 1206 $log->debug( "entered - @_" ); 1125 1207 1126 1127 1208 my $locations; 1128 1209 if ($invalid) { 1129 $locations = $self->find_instances( $key, 'any', 'find them all'); 1210 # delete the invalid instances: 1211 $locations = $self->find_instances( $key, 'any', 1); 1130 1212 } 1131 1213 else { … … 1315 1397 } 1316 1398 1399 if ($response->faultstring =~ /is valid object key/) { 1400 $log->logdie("parameter #1 to delete_instance did not pass the 'is valid object key' callback"); 1401 } 1402 1317 1403 $log->logdie("unhandled fault - ", $self->err); 1318 1404 } … … 1477 1563 } 1478 1564 1565 sub set_log_level 1566 { 1567 my $self = shift; 1568 1569 my $log_level = shift; 1570 1571 $log->level($log_level); 1572 1573 return $self; 1574 } 1575 1479 1576 1480 1577 1; -
trunk/Nebulous/lib/Nebulous/Util.pm
r23934 r41172 78 78 # The instance file attempting to be opened should always exist as it was 79 79 # created by the Nebulous server. 80 80 81 my $fh; 81 82 for (my $i = 0; $i < 60; $i++) { … … 160 161 die "can not process $arg because it is not in name:value form" 161 162 unless defined $name and defined $value; 162 die "xattr name: $name is not in t o the form user.name"163 die "xattr name: $name is not in the form user.name" 163 164 unless $name =~ /^user\./; 164 165 $neb->setxattr($key, $name, $value, "replace")
Note:
See TracChangeset
for help on using the changeset viewer.
