Changeset 1153 in ProjectBuilder for devel/pb/bin/pb


Ignore:
Timestamp:
Jan 12, 2011, 2:42:12 AM (13 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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.