Subversion Repositories DevTools

Rev

Rev 7539 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7539 Rev 7544
Line 85... Line 85...
85
                                        # The following are reset each day
85
                                        # The following are reset each day
86
    dayStart => 0,                      # DateTime when daily data was reset
86
    dayStart => 0,                      # DateTime when daily data was reset
87
    linkErrors => 0,                    # Transfer (S3) errors
87
    linkErrors => 0,                    # Transfer (S3) errors
88
    dbErrors => 0,                      # Database errors
88
    dbErrors => 0,                      # Database errors
89
    processLoops => 0,                  # Number of time the quarantine process was run
89
    processLoops => 0,                  # Number of time the quarantine process was run
-
 
90
    QuarantineCount => 0,               # Packages quarantined today
-
 
91
    QuarantineTxRequested => 0,         # Requests for transfer to S3 (unexpected)
-
 
92
    QuarantineError => 0,               # Errors encountered today
-
 
93
    
90
);
94
);
91
 
95
 
92
#
96
#
93
#   Stats gatthered during the quarantine process
97
#   Stats gatthered during the quarantine process
94
#   Held in a seperate structure to simplify handling
98
#   Held in a seperate structure to simplify handling
-
 
99
#   Per Cycle Data - Calculated each processing Cycle
95
#   
100
#   
96
my %qStats = (
101
my %qStats = (
97
                                        # 
-
 
98
                                        # Per Cycle Data - Calculated each processing Cycle
-
 
99
    # Error counters
102
    # Error counters
100
    QuarantineError         => 0,
103
    QuarantineError         => 0,
101
 
104
 
102
    # Major Statistics
105
    # Major Statistics
103
    Quarantine              => 0,
106
    Quarantine              => 0,                       # Total packages to be quarantined
-
 
107
    QuarantineCount         => 0,                       # Packages quarantined in this cycle
104
    QuarantineTxRequested   => 0,
108
    QuarantineTxRequested   => 0,                       # Requests for transfer to S3 (unexpected)
-
 
109
    QuarantineToDo          => 0,                       # Remaining to be processed
105
 
110
 
106
    # Minor Statistics
111
    # Minor Statistics
-
 
112
    #   Reasons that packages are retained
107
    'Reason.fileNotInReleaseManager' => 0,
113
    ReasonFileNotInReleaseManager => 0,
108
    'Reason.inDeploymentManager'     => 0,
114
    ReasonInDeploymentManager     => 0,
109
    'Reason.inSdk'                   => 0,
115
    ReasonInSdk                   => 0,
110
    'Reason.isPatch'                 => 0,
116
    ReasonIsPatch                 => 0,
111
    'Reason.ManualBuild'             => 0,
117
    ReasonManualBuild             => 0,
112
    'Reason.RetainTime'              => 0,
118
    ReasonRetainTime              => 0,
113
    'Reason.NoBuildStandard'         => 0,
119
    ReasonNoBuildStandard         => 0,
114
    'Reason.NoPackageEntry'          => 0,
120
    ReasonNoPackageEntry          => 0,
115
    'Reason.NoPVid'                  => 0,
121
    ReasonNoPVid                  => 0,
116
    'Reason.NotInArchive'            => 0,
122
    ReasonNotInArchive            => 0,
117
    'Reason.NotInReleaseManager'     => 0,
123
    ReasonNotInReleaseManager     => 0,
118
    'Reason.NotLocked'               => 0,
124
    ReasonNotLocked               => 0,
119
    'Reason.SecondLevelPackage'      => 0,
125
    ReasonSecondLevelPackage      => 0,
120
    'Reason.TopLevelPackage'         => 0,
126
    ReasonTopLevelPackage         => 0,
121
 
-
 
122
    TotalPackages           => 0,
127
    ReasonTotalPackages           => 0,
123
 
128
 
124
    dpkgPackageCount        => 0,                       # Number of packages in dpkg_archive
129
    DpkgPackageCount        => 0,                       # Number of packages in dpkg_archive
125
    dpkgArchiveCount        => 0,                       # Number of package-versions in dpkg_archive
130
    DpkgArchiveCount        => 0,                       # Number of package-versions in dpkg_archive
126
    ReleaseCount            => 0,                       # Number of releases to process
131
    ReleaseCount            => 0,                       # Number of releases to process
127
    RmPackageCount          => 0,                       # Number of packages extracted from RM
132
    RmPackageCount          => 0,                       # Number of packages extracted from RM
128
    topLevelCount           => 0,                       # Number of top level packages extracted from RM
133
    TopLevelCount           => 0,                       # Number of top level packages extracted from RM
129
    dmPackageCount          => 0,                       # Number of packages from Recent DM SBoms
134
    DmPackageCount          => 0,                       # Number of packages from Recent DM SBoms
130
    sdkCount                => 0,                       # Number of packages in SDKs 
135
    SdkCount                => 0,                       # Number of packages in SDKs 
131
    StrayCount              => 0,                       # Number of stray packages discovered
136
    StrayCount              => 0,                       # Number of stray packages discovered
132
);
137
);
133
 
138
 
134
#
139
#
135
#   Describe configuration parameters
140
#   Describe configuration parameters
Line 672... Line 677...
672
        # Note: Must match @recoverTags in readStatistics
677
        # Note: Must match @recoverTags in readStatistics
673
        $statistics{dayStart} = $time;
678
        $statistics{dayStart} = $time;
674
        $statistics{linkErrors} = 0;
679
        $statistics{linkErrors} = 0;
675
        $statistics{dbErrors} = 0;
680
        $statistics{dbErrors} = 0;
676
        $statistics{processLoops} = 0;
681
        $statistics{processLoops} = 0;
-
 
682
        $statistics{QuarantineCount} = 0;
-
 
683
        $statistics{QuarantineTxRequested} = 0;
-
 
684
        $statistics{QuarantineError} = 0;
677
    }
685
    }
678
}
686
}
679
 
687
 
680
#-------------------------------------------------------------------------------
688
#-------------------------------------------------------------------------------
681
# Function        : readStatistics 
689
# Function        : readStatistics 
Line 687... Line 695...
687
#
695
#
688
# Returns         : 
696
# Returns         : 
689
#
697
#
690
sub readStatistics
698
sub readStatistics
691
{
699
{
692
    my @recoverTags = qw(dayStart linkErrors dbErrors processLoops);
700
    my @recoverTags = qw(dayStart linkErrors dbErrors processLoops QuarantineCount QuarantineTxRequested QuarantineError);
693
 
701
 
694
    if ($conf->{'statsfile'} and -f $conf->{'statsfile'})
702
    if ($conf->{'statsfile'} and -f $conf->{'statsfile'})
695
    {
703
    {
696
        if (open my $fh, $conf->{'statsfile'})
704
        if (open my $fh, $conf->{'statsfile'})
697
        {
705
        {
Line 738... Line 746...
738
         $statistics{state} = 'Wedged';
746
         $statistics{state} = 'Wedged';
739
    } elsif(!$dbUp){
747
    } elsif(!$dbUp){
740
        $statistics{state} = 'RM Access error';
748
        $statistics{state} = 'RM Access error';
741
    } elsif(!$linkUp){
749
    } elsif(!$linkUp){
742
        $statistics{state} = 'S3 Bucket Read Error';
750
        $statistics{state} = 'S3 Bucket Read Error';
-
 
751
    } elsif($statistics{QuarantineError}){
-
 
752
        $statistics{state} = 'Error quarantining a package';
743
    } else {
753
    } else {
744
        $statistics{state} = 'OK';
754
        $statistics{state} = 'OK';
745
    }
755
    }
746
 
756
 
747
 
757
 
Line 773... Line 783...
773
            #
783
            #
774
            #   Also dump the stats related to the current (last)
784
            #   Also dump the stats related to the current (last)
775
            #   
785
            #   
776
            foreach my $key ( sort { lc($a) cmp lc($b) } keys %qStats)
786
            foreach my $key ( sort { lc($a) cmp lc($b) } keys %qStats)
777
            {
787
            {
778
                my $txt = 'Qstats.' . $key . ':' . $qStats{$key};
788
                my $txt = 'Qstats' . $key . ':' . $qStats{$key};
779
                print $fh  $txt . "\n";
789
                print $fh  $txt . "\n";
780
                $logger->verbose2('Statistics:'. $txt);
790
                $logger->verbose2('Statistics:'. $txt);
781
            }
791
            }
782
            #
792
            #
783
 
793
 
Line 1181... Line 1191...
1181
    {
1191
    {
1182
        $logger->warn("getTopLevelPackages:Prepare failure" );
1192
        $logger->warn("getTopLevelPackages:Prepare failure" );
1183
    }
1193
    }
1184
 
1194
 
1185
    $logger->verbose ("Extract toplevel dependencies: $count rows");
1195
    $logger->verbose ("Extract toplevel dependencies: $count rows");
1186
    $qStats{topLevelCount} = $count;
1196
    $qStats{TopLevelCount} = $count;
1187
}
1197
}
1188
 
1198
 
1189
#-------------------------------------------------------------------------------
1199
#-------------------------------------------------------------------------------
1190
# Function        : GetRecentDMPackages
1200
# Function        : GetRecentDMPackages
1191
#
1201
#
Line 1272... Line 1282...
1272
    {
1282
    {
1273
        $logger->warn("GetRecentDMPackages:Prepare failure" );
1283
        $logger->warn("GetRecentDMPackages:Prepare failure" );
1274
    }
1284
    }
1275
 
1285
 
1276
    $logger->verbose ("Extract Deployed Packages: $count rows");
1286
    $logger->verbose ("Extract Deployed Packages: $count rows");
1277
    $qStats{dmPackageCount} = $count;
1287
    $qStats{DmPackageCount} = $count;
1278
}
1288
}
1279
 
1289
 
1280
#-------------------------------------------------------------------------------
1290
#-------------------------------------------------------------------------------
1281
# Function        : LocateStrays
1291
# Function        : LocateStrays
1282
#
1292
#
Line 1437... Line 1447...
1437
    {
1447
    {
1438
        $logger->warn("GetSdkPackageData:Prepare failure" );
1448
        $logger->warn("GetSdkPackageData:Prepare failure" );
1439
    }
1449
    }
1440
 
1450
 
1441
    $logger->verbose ("Extract SDK Packages: $count rows");
1451
    $logger->verbose ("Extract SDK Packages: $count rows");
1442
    $qStats{sdkCount} = $count;
1452
    $qStats{SdkCount} = $count;
1443
}
1453
}
1444
 
1454
 
1445
#-------------------------------------------------------------------------------
1455
#-------------------------------------------------------------------------------
1446
# Function        : GeneratePvidLookup  
1456
# Function        : GeneratePvidLookup  
1447
#
1457
#
Line 1494... Line 1504...
1494
        my $pkgDir = join('/', $conf->{dpkg_archive}, $pkgName );
1504
        my $pkgDir = join('/', $conf->{dpkg_archive}, $pkgName );
1495
        if ( -d $pkgDir )
1505
        if ( -d $pkgDir )
1496
        {
1506
        {
1497
            if (opendir (PV, $pkgDir ) )
1507
            if (opendir (PV, $pkgDir ) )
1498
            {
1508
            {
1499
                $qStats{dpkgPackageCount}++;
1509
                $qStats{DpkgPackageCount}++;
1500
                while ( my $pkgVersion = readdir(PV) )
1510
                while ( my $pkgVersion = readdir(PV) )
1501
                {
1511
                {
1502
                    next if ( $pkgVersion eq '.' );
1512
                    next if ( $pkgVersion eq '.' );
1503
                    next if ( $pkgVersion eq '..' );
1513
                    next if ( $pkgVersion eq '..' );
1504
                    next if ( $pkgVersion eq 'latest' );            # Keep latest (often symlink for build system)
1514
                    next if ( $pkgVersion eq 'latest' );            # Keep latest (often symlink for build system)
1505
                    $qStats{dpkgArchiveCount}++;
1515
                    $qStats{DpkgArchiveCount}++;
1506
 
1516
 
1507
                    my $pkgPath = join('/', $conf->{dpkg_archive}, $pkgName,$pkgVersion );
1517
                    my $pkgPath = join('/', $conf->{dpkg_archive}, $pkgName,$pkgVersion );
1508
                    my $mtime = checkTime($pkgPath);
1518
                    my $mtime = checkTime($pkgPath);
1509
 
1519
 
1510
                    my $pvid;
1520
                    my $pvid;
Line 1518... Line 1528...
1518
                    {
1528
                    {
1519
                        #
1529
                        #
1520
                        #   Package is in dpkg-archive, but not in Release
1530
                        #   Package is in dpkg-archive, but not in Release
1521
                        #   Manager. Allow for a short while
1531
                        #   Manager. Allow for a short while
1522
                        #
1532
                        #
1523
                        $qStats{TotalPackages}++;
1533
                        $qStats{ReasonTotalPackages}++;
1524
                        $qStats{'Reason.' . 'NotInReleaseManager'}++;
1534
                        $qStats{'Reason' . 'NotInReleaseManager'}++;
1525
                        if ( $mtime > $conf->{retainNoRm} )
1535
                        if ( $mtime > $conf->{retainNoRm} )
1526
                        {
1536
                        {
1527
                            #Log("Package not in RM: $pkgName, $pkgVersion, Age: $mtime");
1537
                            #Log("Package not in RM: $pkgName, $pkgVersion, Age: $mtime");
1528
                            quarantineItem( 'X', $pkgName, $pkgVersion );
1538
                            quarantineItem( 'X', $pkgName, $pkgVersion );
1529
                            $qStats{'Quarantine'}++;
-
 
1530
                        }
1539
                        }
1531
 
1540
 
1532
                        explain ("Reason:-, $pkgName, $pkgVersion, Reason:NotInReleaseManager");
1541
                        explain ("Reason:-, $pkgName, $pkgVersion, Reason:NotInReleaseManager");
1533
                    }
1542
                    }
1534
 
1543
 
Line 1541... Line 1550...
1541
        {
1550
        {
1542
            $logger->warn("Unexpected file in dpkg_archive: $pkgName");
1551
            $logger->warn("Unexpected file in dpkg_archive: $pkgName");
1543
 
1552
 
1544
            # Ideally we should delete the file
1553
            # Ideally we should delete the file
1545
#            quarantineItem( 'F', -1, $pkgDir );
1554
#            quarantineItem( 'F', -1, $pkgDir );
1546
            $qStats{'Reason.' .'fileNotInReleaseManager'}++;
1555
            $qStats{'Reason' .'FileNotInReleaseManager'}++;
1547
            $qStats{'Quarantine'}++;
-
 
1548
            $qStats{'Reason.' .'NotInReleaseManager'}++;
-
 
1549
            explain("Reason:-, $pkgDir, -, Reason:fileNotInReleaseManager");
1556
            explain("Reason:-, $pkgDir, -, Reason:FileNotInReleaseManager");
1550
        }
1557
        }
1551
        else
1558
        else
1552
        {
1559
        {
1553
            $logger->warn("Unexpected entry in dpkg_archive: $pkgName");
1560
            $logger->warn("Unexpected entry in dpkg_archive: $pkgName");
1554
        }
1561
        }
Line 1588... Line 1595...
1588
                unless ($entry) { $keepReason ='NoPackageEntry'; last;}
1595
                unless ($entry) { $keepReason ='NoPackageEntry'; last;}
1589
                unless ($entry->{dpkg_archive}) { $keepReason ='NotInArchive'; last;}
1596
                unless ($entry->{dpkg_archive}) { $keepReason ='NotInArchive'; last;}
1590
                unless ($pvid) { $keepReason = 'NoPVid'; last;}
1597
                unless ($pvid) { $keepReason = 'NoPVid'; last;}
1591
                if (exists $entry->{tlp}) { $keepReason = 'TopLevelPackage'; last;}
1598
                if (exists $entry->{tlp}) { $keepReason = 'TopLevelPackage'; last;}
1592
                if (exists $entry->{slp}) { $keepReason = 'SecondLevelPackage'; last;}
1599
                if (exists $entry->{slp}) { $keepReason = 'SecondLevelPackage'; last;}
1593
                if (exists $entry->{sdk}) { $keepReason ='inSdk'; last;}
1600
                if (exists $entry->{sdk}) { $keepReason ='InSdk'; last;}
1594
                if (exists $entry->{dm}) { $keepReason = 'inDeploymentManager'; last;}
1601
                if (exists $entry->{dm}) { $keepReason = 'InDeploymentManager'; last;}
1595
                if ($entry->{isPatch}) { $keepReason = 'isPatch'; last;}
1602
                if ($entry->{isPatch}) { $keepReason = 'IsPatch'; last;}
1596
                if ($mtime <= $conf->{retain}) { $keepReason ='RetainTime:' . ($conf->{retain} - $mtime); last;}
1603
                if ($mtime <= $conf->{retain}) { $keepReason ='RetainTime:' . ($conf->{retain} - $mtime); last;}
1597
                #unless ($entry->{buildStandard}) { $keepReason ='NoBuildStandard:' . $mtime; last;}
1604
                #unless ($entry->{buildStandard}) { $keepReason ='NoBuildStandard:' . $mtime; last;}
1598
                if ($entry->{locked} ne 'Y') { $keepReason ='NotLocked:' . $entry->{locked}; last;}
1605
                if ($entry->{locked} ne 'Y') { $keepReason ='NotLocked:' . $entry->{locked}; last;}
1599
                #if ($entry->{buildType} eq 'M') { $keepReason ='ManualBuild:' . $entry->{buildType}; last;}
1606
                #if ($entry->{buildType} eq 'M') { $keepReason ='ManualBuild:' . $entry->{buildType}; last;}
1600
 
1607
 
Line 1614... Line 1621...
1614
            #   Maintain Stats
1621
            #   Maintain Stats
1615
            #       Only use the Base Reason - remove details after the ':' character
1622
            #       Only use the Base Reason - remove details after the ':' character
1616
            #
1623
            #
1617
            my $sReason = $keepReason;
1624
            my $sReason = $keepReason;
1618
            $sReason =~ s~:.*$~~;
1625
            $sReason =~ s~:.*$~~;
1619
            $qStats{'Reason.' . $sReason}++;
1626
            $qStats{'Reason' . $sReason}++;
1620
            $qStats{TotalPackages}++;
1627
            $qStats{ReasonTotalPackages}++;
1621
        }
1628
        }
1622
    }
1629
    }
1623
}
1630
}
1624
 
1631
 
1625
#-------------------------------------------------------------------------------
1632
#-------------------------------------------------------------------------------
Line 1642... Line 1649...
1642
    $data{age} = $age ;
1649
    $data{age} = $age ;
1643
    $data{name} = $pkgName;
1650
    $data{name} = $pkgName;
1644
    $data{version} = $pkgVersion;
1651
    $data{version} = $pkgVersion;
1645
 
1652
 
1646
    push @quarantineItems, \%data;
1653
    push @quarantineItems, \%data;
-
 
1654
    $qStats{'Quarantine'}++;
1647
}
1655
}
1648
 
1656
 
1649
#-------------------------------------------------------------------------------
1657
#-------------------------------------------------------------------------------
1650
# Function        : checkTime
1658
# Function        : checkTime
1651
#
1659
#
Line 1722... Line 1730...
1722
        if (pkgInS3($entry->{name}, $entry->{version}) ) {
1730
        if (pkgInS3($entry->{name}, $entry->{version}) ) {
1723
            #   Package is safely in S3 - can simply delete it
1731
            #   Package is safely in S3 - can simply delete it
1724
            if ($conf->{test}) {
1732
            if ($conf->{test}) {
1725
                $emsg = ' - Not deleted in test mode';
1733
                $emsg = ' - Not deleted in test mode';
1726
                $qStats{'QuarantineCount'}++;      
1734
                $qStats{'QuarantineCount'}++;      
-
 
1735
                $statistics{'QuarantineCount'}++;      
1727
 
1736
 
1728
            } else {
1737
            } else {
1729
                delete_version($entry->{name}, $entry->{version});
1738
                delete_version($entry->{name}, $entry->{version});
1730
                my $path = join('/', $conf->{dpkg_archive}, $entry->{name}, $entry->{version} );
1739
                my $path = join('/', $conf->{dpkg_archive}, $entry->{name}, $entry->{version} );
1731
                if (-d $path) {
1740
                if (-d $path) {
1732
                    $logger->warn("Could not delete package: $path");
1741
                    $logger->warn("Could not delete package: $path");
1733
                    $qStats{'QuarantineError'}++;      
1742
                    $qStats{'QuarantineError'}++;      
-
 
1743
                    $statistics{'QuarantineError'}++;      
1734
                    $emsg = ' - Delete error';
1744
                    $emsg = ' - Delete error';
1735
 
1745
 
1736
                } else {
1746
                } else {
1737
                    $qStats{'QuarantineCount'}++;      
1747
                    $qStats{'QuarantineCount'}++;      
-
 
1748
                    $statistics{'QuarantineCount'}++;      
1738
                    $emsg = '';
1749
                    $emsg = '';
1739
                }
1750
                }
1740
            }
1751
            }
1741
 
1752
 
1742
        } else {
1753
        } else {
Line 1746... Line 1757...
1746
            # Request that it be transferred
1757
            # Request that it be transferred
1747
            # With luck (or by design) the package will be in S3 by the time the process runs again.
1758
            # With luck (or by design) the package will be in S3 by the time the process runs again.
1748
            # 
1759
            # 
1749
            requestS3Transfer($entry->{name}, $entry->{version});
1760
            requestS3Transfer($entry->{name}, $entry->{version});
1750
            $qStats{'QuarantineTxRequested'}++;
1761
            $qStats{'QuarantineTxRequested'}++;
-
 
1762
            $statistics{'QuarantineTxRequested'}++;
1751
            $emsg = ' - Not in S3. Transfer requested';
1763
            $emsg = ' - Not in S3. Transfer requested';
1752
        }
1764
        }
1753
 
1765
 
1754
        # Log operation with frills
1766
        # Log operation with frills
1755
        $logger->logmsg (sprintf("Quarantined:%s%s,%10.10s,%s %s%s", $testMsg, $entry->{reason}, $entry->{age}, $entry->{name}, $entry->{version}, $emsg ));
1767
        $logger->logmsg (sprintf("Quarantined:%s%s,%10.10s,%s %s%s", $testMsg, $entry->{reason}, $entry->{age}, $entry->{name}, $entry->{version}, $emsg ));