Changeset 1153


Ignore:
Timestamp:
Jan 12, 2011, 2:42:12 AM (9 years ago)
Author:
Bruno Cornec
Message:
  • Avoid File::MimeInfo? hard requirement. Only abort if not found when needed.
  • Improve report when a perl module is missing
  • Kill an existing crashed VM using an SSH port needed for another VM (should avoid crashed VM to stay when building for all VMs)
  • Use a new parameter vmbuildtm as a timeout before killing the VM (shoudl correspond to build + transfer time)
  • use twice the number of VMs for ports in the range for SSH communication to allow for VMs to finish in an unordered way.
  • Fix a bug in test modules when using Test simple only
  • Mail::Sendmail is now optional for Log module as well, even if not used yet
  • Update pb.conf doc with info for vmbuildtm and vmmem
  • Ready for 0.10.1
Location:
devel
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • devel/pb-modules/etc/pb.conf.pod

    r1133 r1153  
    491491 Example: vertype default = chroot
    492492
     493=item B<vmbuildtm>
     494
     495 Nature: Optional
     496 Key: OS (could be from the most generic up to the most specific from ostype, osfamily, os, os-ver, os-ver-arch). Default value is set to vmtmout
     497 Value: Time in seconds to wait before killing the VM if SSH port already used. This should corresponds to the time to send files, build the project and get packages in the VM.
     498 Conffile: project
     499 Example: vmbuildtm default = 600,vmbuildtm mandriva-2009.0-x86_64 = 1200
     500
    493501=item B<vmcmd>
    494502
     
    524532 Example: vmlogin default = pb
    525533
     534=item B<vmmem>
     535
     536 Nature: Optional
     537 Key: project (as defined in the -p option or PBPROJ environment variable)
     538 Value: Memory size in MB to allocate to the VM.
     539 Conffile: vm
     540 Example: vmmem default = 512
     541
    526542=item B<vmmonport>
    527543
     
    592608 Nature: Optional
    593609 Key: OS (could be from the most generic up to the most specific from ostype, osfamily, os, os-ver, os-ver-arch). NB: a default value is highly interesting here.
    594  Value: Time in seconds to way beofre interacting with the VM. This should corresponds to the time the VM takes to boot.
     610 Value: Time in seconds to wait before interacting with the VM. This should correspond to the time the VM takes to boot.
    595611 Conffile: vm
    596612 Example: vmtmout default = 180,vmtmout mandriva-2009.0-x86_64 = 500
  • devel/pb-modules/lib/ProjectBuilder/Log.pm

    r1148 r1153  
    227227# mails the summary to $to
    228228sub mailSummary {
    229     require Mail::Sendmail;
    230     my $self = shift;
    231     my $to = shift || "";
    232 
    233     if ($to eq "") {
    234         pb_log(0,"Please give a To: address\n");
    235         return;
    236     }
    237     my %mail = (   
    238         To => $to,
    239         From => "pb\@localhost",
    240         Message => $self->summary()
    241     );
    242     if (! sendmail(%mail)) {
    243         if (defined $Mail::Sendmail::error) {
    244             return $Mail::Sendmail::error;
    245         } else {
    246             return "Unkown error";
    247         }
    248     }
    249     pb_log(0,"Mail send to ". $to ."\n");
     229    eval
     230    {
     231        require Mail::Sendmail;
     232        Mail::Sendmail->import();
     233    };
     234    if ($@) {
     235        # Mail::Sendmail not found not sending mail !
     236        pb_log(0,"No Mail::Sendmail module found so not sending any mail !\n");
     237    } else {
     238        my $self = shift;
     239        my $to = shift || "";
     240
     241        if ($to eq "") {
     242            pb_log(0,"Please give a To: address\n");
     243            return;
     244        }
     245        my %mail = (   
     246            To => $to,
     247            From => "pb\@localhost",
     248            Message => $self->summary()
     249        );
     250        if (! sendmail(%mail)) {
     251            if (defined $Mail::Sendmail::error) {
     252                return $Mail::Sendmail::error;
     253            } else {
     254                return "Unkown error";
     255            }
     256        }
     257        pb_log(0,"Mail send to ". $to ."\n");
     258    }
    250259}
    251260
  • devel/pb-modules/t/Base.t

    r1147 r1153  
    1919if ($@) {
    2020    require Test;
     21    Test->import();
    2122    plan(tests => 1);
    2223    print "# Faking tests as Test::More is not available in an appropriate version\n";
  • devel/pb-modules/t/Log.t

    r1147 r1153  
    1919if ($@) {
    2020    require Test;
     21    Test->import();
    2122    plan(tests => 1);
    2223    print "# Faking tests as test::More is not available in an appropriate version\n";
  • devel/pb/bin/pb

    r1146 r1153  
    523523    if ($@) {
    524524        # Sys::CPU not found, defaulting to 1
     525        pb_log(1,"ADVISE: Install Sys::CPU to benefit from automatic parallelism optimization.\nOr use pbparallel in your pb.conf file\nOnly 1 process at a time for the moment\n");
    525526        $pbparallel = 1;
    526527    } else {
    527528        # Using the number of cores
    528529        $pbparallel = Sys::CPU::cpu_count();
     530        pb_log(1,"Using parallel mode with $pbparallel processes\n");
    529531    }
    530532}
     
    538540if ($@) {
    539541    $pbparallel = undef;
     542    pb_log(1,"ADVISE: Install Parallel::ForkManager to benefit from automatic parallelism optimization.\nOnly 1 process at a time for the moment\n");
    540543}
    541544
     
    18051808            # For monitoring control
    18061809            if ((($vmtype->{$ENV{'PBPROJ'}}) eq "kvm") || (($vmtype->{$ENV{'PBPROJ'}}) eq "qemu")) {
     1810                eval
     1811                {
    18071812                require Net::Telnet;
    1808                 my $t = new Net::Telnet (Timeout => 120, Host => "localhost", Port => $vmmonport->{$ENV{'PBPROJ'}}) || die "Unable to dialog on the monitor";
    1809                 # move to monitor mode
    1810                 my @lines = $t->cmd("c");
    1811                 # Create a snapshot named pb
    1812                 @lines = $t->cmd("savevm pb");
    1813                 # Write the new status in the VM
    1814                 @lines = $t->cmd("commit all");
    1815                 # End
    1816                 @lines = $t->cmd("quit");
     1813                Net::Telnet->import();
     1814                };
     1815                if ($@) {
     1816                    # Net::Telnet not found
     1817                    pb_log(1,"ADVISE: Install Net::Telnet to benefit from monitoring control and snapshot feature.\nWARNING: No snapshot created");
     1818                } else {
     1819                    my $t = new Net::Telnet (Timeout => 120, Host => "localhost", Port => $vmmonport->{$ENV{'PBPROJ'}}) || die "Unable to dialog on the monitor";
     1820                    # move to monitor mode
     1821                    my @lines = $t->cmd("c");
     1822                    # Create a snapshot named pb
     1823                    @lines = $t->cmd("savevm pb");
     1824                    # Write the new status in the VM
     1825                    @lines = $t->cmd("commit all");
     1826                    # End
     1827                    @lines = $t->cmd("quit");
     1828                }
    18171829            }
    18181830        }
     
    19111923        # TODO: vmmonport should be optional
    19121924        my ($ptr,$ptr2,$vmpath,$vmport,$vmsize,$vmmonport) = pb_conf_get("vmtype","vmcmd","vmpath","vmport","vmsize","vmmonport");
    1913         my ($vmopt,$vmmem,$vmtmout,$vmsnap) = pb_conf_get_if("vmopt","vmmem","vmtmout","vmsnap");
     1925        my ($vmopt,$vmmem,$vmtmout,$vmsnap,$vmbuildtm) = pb_conf_get_if("vmopt","vmmem","vmtmout","vmsnap","vmbuildtm");
    19141926
    19151927        my $vmtype = $ptr->{$ENV{'PBPROJ'}};
     
    20012013                pb_log(0,"Unable to find VM $vmm\n");
    20022014            } else {
     2015                # Is the SSH port free? if not kill the existing process using it after a build timeout period
     2016                my $vmssh = pb_check_ps($tmpcmd,"tcp:$nport:10.0.2.15:22");
     2017                if ($vmssh) {
     2018                    my $buildtm = $ENV{'PBVMTMOUT'};
     2019                    if (defined $vmbuildtm->{$v}) {
     2020                        $buildtm = $vmbuildtm->{$v};
     2021                    } elsif (defined $vmbuildtm->{$ENV{'PBPROJ'}}) {
     2022                        $buildtm = $vmbuildtm->{$ENV{'PBPROJ'}};
     2023                    }
     2024
     2025                    sleep $buildtm;
     2026                    pb_log(0,"WARNING: Killing the process ($vmssh) using port $nport (previous failed VM ?)\n");
     2027                    kill 15,$vmssh;
     2028                }
    20032029                pb_system("$cmd &","Launching the VM $vmm");
     2030                # Using system allows to kill it externaly if needed
    20042031                pb_system("sleep $ENV{'PBVMTMOUT'}","Waiting $ENV{'PBVMTMOUT'} s for VM $v to come up");
    20052032                $vmpid = pb_check_ps($tmpcmd,$vmm);
     
    22382265foreach my $v (@$v) {
    22392266    $counter++;
    2240     # Modulo pbparallel
    2241     $counter = 1 if ($counter > $pbparallel);
     2267    # Modulo 2 * pbparallel (to avoid synchronization problems)
     2268    $counter = 1 if ($counter > 2 * $pbparallel);
    22422269    $pm->start($counter) and next if (defined $pbparallel);
    22432270    # Prepare the script to be executed on the VM/VE
     
    34983525    };
    34993526    if ($@) {
    3500         # Linux::SysInfo not found, defaulting to 4
    3501         $pbparallel = 4;
     3527        # Linux::SysInfo not found
     3528        pb_log(1,"ADVISE: Install Linux::SysInfo to benefit from automatic parallelism optimization.\nOr optimize manually pbparallel in your pb.conf file\nUsing $pbparallel processes max at a time for the moment\nWARNING: This may consume too much memory for your system");
    35023529    } else {
    35033530        # Using the memory size
    35043531        my $si = Linux::SysInfo::sysinfo();
    35053532        if (not defined $si) {
    3506             $pbparallel = 4
     3533            pb_log(1,"ADVISE: Install Linux::SysInfo to benefit from automatic parallelism optimization.\nOr optimize manually pbparallel in your pb.conf file\nUsing $pbparallel processes max at a time for the moment\nWARNING: This may consume too much memory for your system");
    35073534        } else {
    35083535            # Keep the number of VM whose memory can be allocated
    35093536            my $ram = $si->{"totalram"}-$si->{"sharedram"}-$si->{"bufferram"};
    35103537            my $ram2;
    3511             my ($pbvmmem) = pb_conf_get_if("pbvmmem");
    3512 
    3513             if ((defined $pbvmmem) and (defined $pbvmmem->{$ENV{'PBPROJ'}})) {
    3514                 $ram2 = $pbvmmem->{$ENV{'PBPROJ'}};
     3538            my ($vmmem) = pb_conf_get_if("vmmem");
     3539
     3540            my $v = "default";
     3541            if ((defined $vmmem) and (defined $vmmem->{$v})) {
     3542                $ram2 = $vmmem->{$v};
    35153543            } else {
    35163544                # Default for KVM/QEMU
     
    35193547            $pbparallel = sprintf("%d",$ram/$ram2);
    35203548        }
     3549        pb_log(1,"Using $pbparallel processes at a time\n");
    35213550    }
    35223551}
  • devel/pb/lib/ProjectBuilder/CMS.pm

    r1148 r1153  
    209209    return("$ENV{'PBTMP'}/$f");
    210210} elsif ($scheme eq "file") {
    211     use File::MimeInfo;
     211    eval
     212    {
     213        require File::MimeInfo;
     214        File::MimeInfo->import();
     215    };
     216    if ($@) {
     217        # File::MimeInfo not found
     218        die("ERROR: Install File::MimeInfo to handle scheme $scheme\n");
     219    }
     220
    212221    my $mm = mimetype($path);
    213222    pb_log(2,"mimetype: $mm\n");
Note: See TracChangeset for help on using the changeset viewer.