IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41172 for trunk/Nebulous/lib


Ignore:
Timestamp:
Nov 27, 2019, 12:04:14 PM (7 years ago)
Author:
eugene
Message:

merging updates to Nebulous from EAM dev branch ipp-20191011

Location:
trunk/Nebulous/lib/Nebulous
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/lib/Nebulous/Client.pm

    r40680 r41172  
    209209        },
    210210    );
    211 
     211   
    212212    $log->debug( "entered - @_" );
    213213
     
    310310    my $stats = $self->stat($key);
    311311    my $instances = $stats->[6];
     312
    312313    if ((not defined $instances) or ($instances == 0)) {
    313314        $self->set_err("can not cull - no instances");
     
    315316        return;
    316317    }
    317     if ($instances < $min_copies) {
     318    if ($instances <= $min_copies) {
    318319        $self->set_err("can not cull - not enough instances");
    319320        $log->debug("leaving");
    320 
    321321        return;
    322322    }
     
    334334
    335335    unless (defined $locations) {
    336         $self->set_err( "no instances" );
    337336        $log->debug( "leaving" );
    338 
    339337        return;
    340338    }
     
    351349        }
    352350    }
     351
    353352    # If we don't have two copies on one volume, see if we have two copies on a single
    354353    # cabinet. If so, delete the first of those copies.
     
    362361        }
    363362    }
     363
    364364    # Fail-safe. We didn't have any duplicates (the instances are "well-mixed"), so
    365365    # delete the first.
     
    403403    eval {
    404404        # first - strip off any inaccesible instances
     405        # these are not counted in the 'removed' number
    405406        if (not defined $self->prune($key)) {
    406407            # use the prune() method to also determine if $key is valid
    407408            die "invalid key: $key";
    408409        }
    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
    412416        if (defined $vol_name) {
    413417            $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            }
    414424        }
    415425
     
    418428
    419429        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?
    426435                die "no instances";
    427436            }
    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";
    432440            }
     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;
    433452        } else {
    434453            # nuke whatever
     
    448467            }
    449468        }
    450 
    451469    };
    452470    if ($@) {
     
    663681    if ($response->fault) {
    664682        $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
    665696        $log->logdie("unhandled fault - ", $self->err);
    666697    }
     
    690721    if ( $response->fault ) {
    691722        $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        }
    692741        $log->logdie("unhandled fault - ", $self->err);
    693742    }
     
    747796    if ( $response->fault ) {
    748797        $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
    749817        $log->logdie("unhandled fault - ", $self->err);
    750818    }
     
    865933    unless(defined($params[0])) {
    866934        $params[0] = hostname() . ".0";
    867 #       print STDERR "Setting host to $params[0]\n";
     935        # print STDERR "Setting host to $params[0]\n";
    868936    }
    869937
     
    871939    if ( $response->fault ) {
    872940        $self->set_err($response->faultstring);
     941
    873942        # check to see if this failure is because $key doesn't exist
    874943        if ($response->faultstring =~ /is valid object key/) {
     
    878947        # key is valid but no instances are on the specified volume
    879948        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/) {
    880959            $log->debug( "leaving" );
    881960            return;
     
    9491028        $self->set_err($response->faultstring);
    9501029        # check to see if this failure is because $key doesn't exist
     1030        my $string = $response->faultstring;
    9511031        if ($response->faultstring =~ /is valid object key/) {
     1032            $self->set_err("invalid object key");
    9521033            $log->debug( "leaving" );
    9531034            return;
     
    9551036        # key is valid but no instances are on the specified volume
    9561037        if ($response->faultstring =~ /no instances on storage volume/) {
     1038            $self->set_err("no instances on storage volume or volume is not available");
    9571039            $log->debug( "leaving" );
    9581040            return;
     
    9721054
    9731055
     1056## this is used by PS:IPP:Config nebulous functions
    9741057sub find
    9751058{
     
    10141097    return $path;
    10151098}
    1016 
    10171099
    10181100sub open
     
    11241206    $log->debug( "entered - @_" );
    11251207
    1126 
    11271208    my $locations;
    11281209    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);
    11301212    }
    11311213    else {
     
    13151397        }
    13161398
     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
    13171403        $log->logdie("unhandled fault - ", $self->err);
    13181404    }
     
    14771563}
    14781564
     1565sub 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
    14791576
    148015771;
  • trunk/Nebulous/lib/Nebulous/Util.pm

    r23934 r41172  
    7878    # The instance file attempting to be opened should always exist as it was
    7979    # created by the Nebulous server.
     80
    8081    my $fh;
    8182    for (my $i = 0; $i < 60; $i++) {
     
    160161        die "can not process $arg because it is not in name:value form"
    161162            unless defined $name and defined $value;
    162         die "xattr name: $name is not in to the form user.name"
     163        die "xattr name: $name is not in the form user.name"
    163164            unless $name =~ /^user\./;
    164165        $neb->setxattr($key, $name, $value, "replace")
Note: See TracChangeset for help on using the changeset viewer.