From 686ed029b36cf7ccd680757d474156e4230d756b Mon Sep 17 00:00:00 2001 From: James Adams Date: Thu, 5 Sep 2024 16:30:03 +0100 Subject: [PATCH] ncm-pbsserver: Remove obsolete component --- ncm-pbsserver/ChangeLog | 3 - ncm-pbsserver/pom.xml | 65 --- .../main/pan/components/pbsserver/config.pan | 20 - .../main/pan/components/pbsserver/schema.pan | 265 ---------- ncm-pbsserver/src/main/perl/pbsserver.pm | 496 ------------------ ncm-pbsserver/src/main/perl/pbsserver.pod | 84 --- ncm-pbsserver/src/test/perl/00-load.t | 18 - ncm-pbsserver/src/test/perl/pod-syntax.t | 6 - ncm-pbsserver/src/test/perl/simple.t | 170 ------ ncm-pbsserver/src/test/resources/ccm.cfg | 6 - ncm-pbsserver/src/test/resources/simple.pan | 44 -- pom.xml | 1 - 12 files changed, 1178 deletions(-) delete mode 100644 ncm-pbsserver/ChangeLog delete mode 100644 ncm-pbsserver/pom.xml delete mode 100644 ncm-pbsserver/src/main/pan/components/pbsserver/config.pan delete mode 100644 ncm-pbsserver/src/main/pan/components/pbsserver/schema.pan delete mode 100755 ncm-pbsserver/src/main/perl/pbsserver.pm delete mode 100755 ncm-pbsserver/src/main/perl/pbsserver.pod delete mode 100644 ncm-pbsserver/src/test/perl/00-load.t delete mode 100644 ncm-pbsserver/src/test/perl/pod-syntax.t delete mode 100644 ncm-pbsserver/src/test/perl/simple.t delete mode 100644 ncm-pbsserver/src/test/resources/ccm.cfg delete mode 100644 ncm-pbsserver/src/test/resources/simple.pan diff --git a/ncm-pbsserver/ChangeLog b/ncm-pbsserver/ChangeLog deleted file mode 100644 index 386a64a8..00000000 --- a/ncm-pbsserver/ChangeLog +++ /dev/null @@ -1,3 +0,0 @@ -2010-10-01 (Version 1.0.0) -- B. Gamma - - Initial version of component. diff --git a/ncm-pbsserver/pom.xml b/ncm-pbsserver/pom.xml deleted file mode 100644 index 3d95a589..00000000 --- a/ncm-pbsserver/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - 4.0.0 - - org.quattor.cfg.module - pbsserver - - pom - 23.9.0-rc2-SNAPSHOT - PBS server NCM component. - - - org.quattor.maven - build-profile - 1.62 - - - - - - Apache 2 License - http://www.opensource.org/licenses/apache2.0 - Copyright (c) Responsible Organization - - - - - - Charles Loomis - charles.loomis@cern.ch - - - - - - Jane SMITH - smith@example.com - - author - - - - Joe DOE - doe@example.org - - author - - - - - - - - - org.codehaus.mojo - rpm-maven-plugin - - https://github.com/quattor/configuration-modules-grid/tree/master/ncm-${project.artifactId} - - - - - - - diff --git a/ncm-pbsserver/src/main/pan/components/pbsserver/config.pan b/ncm-pbsserver/src/main/pan/components/pbsserver/config.pan deleted file mode 100644 index 94cc1a38..00000000 --- a/ncm-pbsserver/src/main/pan/components/pbsserver/config.pan +++ /dev/null @@ -1,20 +0,0 @@ -# ${license-info} -# ${developer-info} -# ${author-info} - -unique template components/${project.artifactId}/config; - -include 'components/${project.artifactId}/schema'; - -bind '/software/components/${project.artifactId}' = ${project.artifactId}_component; - -# Install Quattor configuration module via RPM package. -'/software/packages' = pkg_repl('ncm-${project.artifactId}', '${no-snapshot-version}-${rpm.release}', 'noarch'); - -# Set prefix to root of component configuration. -prefix '/software/components/${project.artifactId}'; - -'version' = '${no-snapshot-version}'; -'active' ?= true; -'dispatch' ?= true; -'dependencies/pre' ?= list('spma'); diff --git a/ncm-pbsserver/src/main/pan/components/pbsserver/schema.pan b/ncm-pbsserver/src/main/pan/components/pbsserver/schema.pan deleted file mode 100644 index 07cb0a0c..00000000 --- a/ncm-pbsserver/src/main/pan/components/pbsserver/schema.pan +++ /dev/null @@ -1,265 +0,0 @@ -# ${license-info} -# ${developer-info} -# ${author-info} - -declaration template components/pbsserver/schema; - -include 'pan/types'; -include 'quattor/types/component'; - -type pbs_server_extended_att = { - 'attribute' : string - 'operator' : string with match(SELF, '^(\+\=|\=|\-\=)$') - 'value' : string -}; - -# from man pbs_server_attributes (NOT the read only ones!) -type pbs_server_attlist = { - 'accounting_keep_days'? long(0..) - - 'acl_group_sloppy' ? boolean - 'acl_host_enable' ? boolean = false - 'acl_hosts' ? string - 'acl_logic_or' ? boolean = false - 'acl_user_enable' ? boolean = false - 'acl_roots' ? string - - 'allow_node_submit' ? boolean = false - 'allow_proxy_user' ? boolean = false - - 'auto_node_np' ? boolean - - 'clone_batch_delay' ? long(0..) - 'clone_batch_size' ? long(1..) - - 'credential_lifetime' ? long(1..) - - 'comment' ? string - - 'default_node' ? string - 'default_queue' ? string - - 'down_on_error' ? boolean - - 'disable_server_id_check' ? boolean - - 'extra_resc' ? string - - 'job_force_cancel_time' ? long(0..) - - 'job_nanny' ? boolean = false - - 'job_start_timeout' ? long(1..) - - 'job_stat_rate' ? long(1..) = 150 - - 'keep_completed' ? long(0..) - - 'kill_delay' ? long(0..) - - 'lock_file' ? string - 'lock_file_check_time' ? long(0..) - 'lock_file_update_time' ? long(0..) - - 'log_events' ? long(0..) - 'log_file_max_size' ? long(0..) = 0 - 'log_file_roll_depth' ? long(1..) = 10 - 'log_keep_days' ? long(0..) - 'log_level' ? long(0..) = 0 - - 'mail_body_fmt' ? string - 'mail_domain' ? string - 'mail_from' ? string - 'mail_subject_fmt' ? string - 'mail_uid' ? long(0..) - - 'managers' ? string - - 'max_job_array_size' ? long(0..) - 'max_slot_limit' ? long(0..) - 'max_running' ? long(0..) - 'max_user_run' ? long(0..) - 'max_user_queuable' ? long(1..) - 'max_group_run' ? long(0..) - - 'mom_job_sync' ? boolean = true - - 'next_job_number' ? long(0..) - - 'no_mail_force' ? boolean - - 'node_check_rate' ? long(10..) = 600 - 'node_pack' ? boolean - 'node_ping_rate' ? long(10..) = 300 - 'node_suffix' ? string - - 'np_default' ? long(0..) - - 'operators' ? string - - 'owner_purge' ? boolean - - 'poll_jobs' ? boolean = true - - 'query_other_jobs' ? boolean = false - - # following does not exist in 3.0.X (should all be like resources_available.) - 'resources_available' ? string - 'resources_available.nodect' ? long(1..) = 2048 - - # following 2 are actually a list of - 'resources_default' ? string - 'resources_default.nodect' ? long(1..) - 'resources_default.nodes' ? long(1..) - 'resources_max' ? string - - 'sched_version' ? string - 'scheduler_iteration' ? long(1..) - 'scheduling' ? boolean - - 'server_name' ? type_hostname - - 'submit_hosts' ? string - - 'tcp_timeout' ? long(1..) = 8 - - 'checkpoint_dir' ? string - - 'moab_array_compatible' ? boolean - - 'authorized_users' ? string - - 'record_job_info' ? boolean - 'record_job_script' ? boolean - - 'use_jobs_subdirs' ? boolean - - 'thread_idle_seconds' ? long(-1..) - 'max_threads' ? long(0..) - 'min_threads' ? long(0..) - - 'legacy_vmem' ? boolean -}; - -type pbs_server = { - 'manualconfig' : boolean - 'attlist' ? pbs_server_attlist - 'extended_att' ? pbs_server_extended_att[0..] -}; - -type pbs_queue_attlist = { - 'acl_group_enable' ? boolean - 'acl_group_sloppy' ? boolean - 'acl_groups' ? string - 'acl_host_enable' ? boolean - 'acl_hosts' ? string - 'acl_logic_or' ? boolean - 'acl_user_enable' ? boolean - 'acl_users' ? string - - 'alter_router' ? boolean - - 'checkpoint_defaults' ? string - 'checkpoint_min' ? long(0..) - - ## comma-separated list - 'disallowed' ? string - - 'enabled' ? boolean - - 'from_route_only' ? boolean - - 'is_transit' ? boolean - - 'keep_completed' ? long(0..) - - 'kill_delay' ? long(0..) - - 'max_queuable' ? long(1..) - 'max_group_run' ? long(0..) - 'max_user_run' ? long(0..) - 'max_user_queuable' ? long(1..) - 'max_running' ? long(1..) - - 'Priority' ? long(0..) - - 'queue_type' ? string - - 'resources_available.nodect' ? long(1..) = 2048 - 'resources_default.mem' ? string - 'resources_default.ncpus' ? long(0..) - 'resources_default.neednodes' ? string - 'resources_default.nice' ? long(0..) - 'resources_default.nodect' ? long(1..) - 'resources_default.nodes' ? long(1..) - 'resources_default.pmem' ? string - 'resources_default.procct' ? long(1..) - 'resources_default.pvmem' ? string - 'resources_default.vmem' ? string - 'resources_default.walltime' ? string - 'resources_max.cput' ? string - 'resources_max.file' ? string - 'resources_max.mem' ? string - 'resources_max.nice' ? long(1..) - 'resources_max.nodect' ? long(1..) - 'resources_max.nodes' ? long(1..) - 'resources_max.pcput' ? string - 'resources_max.pmem' ? string - 'resources_max.procct' ? long(1..) - 'resources_max.pvmem' ? string - 'resources_max.vmem' ? string - 'resources_max.walltime' ? string - 'resources_min.mem' ? string - 'resources_min.nice' ? long(1..) - 'resources_min.pmem' ? string - 'resources_min.pvmem' ? string - 'resources_min.vmem' ? string - 'resources_min.walltime' ? string - - 'started' ? boolean - - 'route_destinations' ? string - 'route_held_jobs' ? boolean - 'route_lifetime' ? long(0..) - 'route_retry_time' ? long(0..) - 'route_waiting_jobs' ? boolean -}; - -type pbs_queue = { - 'manualconfig' : boolean - 'attlist' ? pbs_queue_attlist -}; - -type pbs_queuelist = { - 'manualconfig' : boolean - 'queuelist' ? pbs_queue{} -}; - -type pbs_node_attlist = { - 'np' ? long(1..) - 'properties' ? string - 'state' ? string with match(SELF, 'free|down|offline') - 'ntype' ? string -}; - -type pbs_node = { - 'manualconfig' : boolean - 'attlist' ? pbs_node_attlist -}; - -type pbs_nodelist = { - 'manualconfig' : boolean - 'nodelist' ? pbs_node{} -}; - -type ${project.artifactId}_component = { - include structure_component - 'pbsroot' ? string - 'binpath' ? string - 'submitfilter' ? string - 'env' ? string{} - 'server' ? pbs_server - 'queue' ? pbs_queuelist - 'node' ? pbs_nodelist - 'ignoretorquecfg' ? boolean = false -}; diff --git a/ncm-pbsserver/src/main/perl/pbsserver.pm b/ncm-pbsserver/src/main/perl/pbsserver.pm deleted file mode 100755 index 73f87b4b..00000000 --- a/ncm-pbsserver/src/main/perl/pbsserver.pm +++ /dev/null @@ -1,496 +0,0 @@ -#${PMpre} NCM::Component::pbsserver${PMpost} - -use parent qw(NCM::Component CAF::Path); - -our $EC = LC::Exception::Context->new->will_store_all; -our $NoActionSupported = 1; - -use CAF::Process; -use CAF::Service; -use CAF::FileWriter; - -use Readonly; - -# Filter out any matching pbsnodes attributes from further processing -Readonly::Array my @FILTER_PBSNODES_PATTERNS => qw( - state ntype power_state - status jobs note - mom_(manager|service)_port - (total|dedicated)_(sockets|numa_nodes|cores|threads) - gpus gpu_status -); - - -# Location of the qmgr binary (needs to be determined and set once) -my $qmgr; - - -sub Configure -{ - my ($self, $config) = @_; - - # Define paths for convenience and retrieve configuration - my $tree = $config->getTree($self->prefix()); - - - # Retrieve location for pbs working directory and ensure it exists. - my $pbsroot = $tree->{pbsroot} || "/var/torque"; - - if (! $self->directory($pbsroot)) { - $self->error("Can't create directory $pbsroot: $self->{fail}"); - return 1; - } - - my $srv = CAF::Service->new(['pbs_server'], log => $self); - # set to true if service was (re)started - my $started = 0; - - # Determine the location of the pbs commands. - my $binpath = $tree->{binpath} || "/usr/bin"; - - my $serverdb = "$pbsroot/server_priv/serverdb"; - if (! $self->file_exists($serverdb)) { - $self->info("serverdb $serverdb is missing."); - - if (! $srv->stop()) { - $self->warn('pbs_server stop failed before create (normal in not started yet): '. $?); - }; - - # force is ok, because the serverdb is missing - return 1 if (! defined($self->force_create($binpath, $pbsroot))); - - $started = 1; - if (! $srv->start()) { - $self->warn('pbs_server start failed after create (normal because not configured yet): '. $?); - }; - } - - # Retrieve the contents of the envrionment file and update if necessary/ - if ( $tree->{env} ) { - my $fname = "$pbsroot/pbs_environment"; - $self->info("Checking environment file ($fname)..."); - my $contents = "#\n# File generated by ncm-pbsserver. DO NOT EDIT\n#\n"; - foreach my $name (sort keys %{$tree->{env}}) { - $contents .= "$name=$tree->{env}->{$name}\n"; - } - my $fh_env = CAF::FileWriter->new($fname, - backup => ".old", - log => $self, - ); - print $fh_env $contents; - - if($fh_env->close()) { - $self->verbose("$fname updated. Restarting pbs_server..."); - $started = 1; - if (! $srv->restart()) { - $self->error('pbs_server restart failed: '. $?); - }; - } - } - - - # Update the submit filter. This is used only by the qsub - # command, so the server doesn't need to be restarted for changes - # here. - # Be very careful, the file will NOT work with embedded comments. - if ( $tree->{submitfilter} ) { - $self->info("Checking submission filter..."); - my $fh_cfg = CAF::FileWriter->new("$pbsroot/torque.cfg", - backup => ".old", - log => $self, - ); - print $fh_cfg "SUBMITFILTER $pbsroot/submit_filter\n"; - $fh_cfg->close(); - - my $fh_sf = CAF::FileWriter->new("$pbsroot/submit_filter", - backup => ".old", - mode => 0755, - log => $self, - ); - print $fh_sf $tree->{submitfilter}; - $fh_sf->close(); - - # Ensure that any existing filter is removed. Since the - # submitfilter is the only parameter in torque.cfg, this file - # can be removed as well. - # this is far from true. if something else manages torque.cfg, set ignoretorquecfg to true - } else { - $self->info("Removing submission filter..."); - $self->cleanup("$pbsroot/submit_filter"); - - my $removetorquecfg = $self->file_exists("$pbsroot/torque.cfg"); - if ($tree->{ignoretorquecfg}) { - $removetorquecfg = 0; - $self->info("Ignoring torque.cfg file."); - }; - $self->cleanup("$pbsroot/torque.cfg") if ($removetorquecfg); - } - - - $self->set_qmgr("$binpath/qmgr"); - my $pbsnodes = "$binpath/pbsnodes"; - - foreach my $bin ($qmgr, $pbsnodes) { - if (! $self->file_exists($bin)) { - $self->error("$bin does not exist"); - return 1; - } - } - - - my $existing = $self->get_current_config($started); - if (! defined($existing)) { - $self->error("No existing config found"); - return 1; - } - - - # server configuration - # $serverbase --+ - # +--manualconfig : boolean - # +--attlist ? nlist - # If manualconfig is false, remove any existing config parameter not part of the configuration. - my %definedsatt; - if ( $tree->{server} ) { - $self->info("Updating server attributes..."); - if ( $tree->{server}->{attlist} ) { - my $server_attlist = $tree->{server}->{attlist}; - foreach my $serveratt (sort keys %{$server_attlist}) { - $definedsatt{$serveratt} = 1; - $self->qmgr("set server $serveratt = ".$server_attlist->{$serveratt}); - } - } - - # Removing server attributes not defined in configuration if manualconfig is set to false. - # Take care of not removing a few attributes generated/maintained by the server. - # 'acl_hosts' is defined to the server host name at startup if not explicitly defined. - if ( $self->allowed($tree->{server}) ) { - $self->debug(1,"Removing server attributes not part of the configuration (manualconfig=false)"); - foreach (sort keys %{$existing->{satt}}) { - unless ( defined($definedsatt{$_}) || - ($_ eq "pbs_version") || - ($_ eq "acl_hosts") || - ($_ eq "next_job_number") ) { - $self->qmgr("unset server $_"); - } - } - } - } - - - if ( $tree->{server}->{attlist}->{server_name} ) { - my $fh = CAF::FileWriter->new("$pbsroot/server_name", log => $self); - print $fh "$tree->{server}->{attlist}->{server_name}\n"; - if ($fh->close()) { - $self->info("server_name file changed, restarting pbs_server"); - if (! $srv->restart()) { - $self->error('pbs_server restart failed: '. $?); - }; - # Wait till server responds again - my $new_existing = $self->get_current_config(1); - return 1 if (! defined($existing)); - } - } - - # queue configuration - # $queuebase --+ - # +--manualconfig : boolean - # +--queuelist--+ ? nlist - # +--manualconfig : boolean - # +--attlist ? nlist - # If manualconfig is false, remove any existing config parameter not part of the configuration. - - my %definedqueues; - if ( $tree->{queue} ) { - $self->info("Updating queue list and queue attributes..."); - if ( $tree->{queue}->{queuelist} ) { - my $queuelist = $tree->{queue}->{queuelist}; - foreach my $queue (sort keys(%{$queuelist})) { - $definedqueues{$queue} = 1; - if (!$existing->{queues}->{$queue}) { - $self->qmgr("create queue $queue"); - } - - my %definedqatt; - if ( $queuelist->{$queue}->{attlist} ) { - my $queue_attlist = $queuelist->{$queue}->{attlist}; - foreach my $queueatt (sort keys(%{$queue_attlist})) { - $definedqatt{$queueatt} = 1; - # Ensure queue is enabled and started after the configuration has been done - if (($queueatt ne "enabled") && ($queueatt ne "started")) { - $self->qmgr("set queue $queue $queueatt = ".$queue_attlist->{$queueatt}); - } - } - foreach my $queueatt ('enabled', 'started') { - if ( $definedqatt{$queueatt} ) { - $self->qmgr("set queue $queue $queueatt = ".$queue_attlist->{$queueatt}); - } - } - } - - # Removing non-defined queue attributes if manualconfig is set to false - if ( $self->allowed($queuelist->{$queue}) ) { - $self->debug(1,"Removing queue $queue attributes not part of the configuration (manualconfig=false)"); - foreach (sort keys %{$existing->{queues}->{$queue}}) { - $self->qmgr("unset queue $queue $_") unless (defined($definedqatt{$_})); - } - } - } - } - - # Delete existing queues not part of the configuration if manualconfig is set to false - if ( $self->allowed($tree->{queue}) ) { - foreach (sort keys %{$existing->{queues}}) { - unless (defined($definedqueues{$_})) { - $self->qmgr("delete queue $_", "Removing queue $_..."); - } - } - } - } - - - # This slurps the pbsnodes output into a hash of hashes. This - # avoids having to rerun the command. - my %existingnodes; - my $lastnode = ''; - - my $nodesfn = "$pbsroot/server_priv/nodes"; - if ($self->file_exists($nodesfn)) { - my $output = CAF::Process->new([$pbsnodes, '-a'], log => $self, keeps_state => 1)->output(); - if ($?) { - $self->error("error running $pbsnodes"); - return 1; - } - - my $filterpattern = '^(' . join('|', @FILTER_PBSNODES_PATTERNS) . ')$'; - my $filterregexp = qr{$filterpattern}; - $self->verbose("pbsnodes attributes filter regexp $filterregexp"); - - foreach my $line (split(/\n/, $output)) { - chomp($line); - if ($line =~ m/(^[\w\d\.-]+)\s*$/) { - # Start of a section with node name. - $lastnode = $1; - $existingnodes{$lastnode} = {}; - } elsif ($line =~ m/^\s*(\w+)\s*=\s*(.*)/) { - # This is an attribute. Attach it to last node. - my $name = $1; - my $value = $2; - if ($lastnode && $name !~ $filterregexp) { - my $href = $existingnodes{$lastnode}; - $href->{$name} = $value; - } - } - } - } else { - $self->verbose("nodes file $nodesfn not found, not checking any exiting nodes"); - } - - - # node configuration - # $nodebase--+ - # +--manualconfig : boolean - # +--nodelist--+ ? nlist - # +--manualconfig : boolean - # +--attlist ? nlist - - my %definednodes; - if ( $tree->{node} ) { - $self->info("Updating WN list and WN attributes..."); - if ( $tree->{node}->{nodelist} ) { - my $nodelist = $tree->{node}->{nodelist}; - foreach my $node (sort keys %{$nodelist}) { - $definednodes{$node} = 1; - $self->qmgr("create node $node") unless (defined($existingnodes{$node})); - - # Retrieve node attributes and properties. - # properties is a comma separated list. - my %definednatt; - my %existingnatt; - my %defprops; - if (defined($existingnodes{$node})) { - my $href = $existingnodes{$node}; - %existingnatt = %$href; - } - if (defined($existingnatt{properties})) { - my @props = split /,/, $existingnatt{properties}; - foreach my $p (@props) { - $defprops{$p} = 1; - } - } - - if ( $nodelist->{$node}->{attlist} ) { - my $node_attlist = $nodelist->{$node}->{attlist}; - foreach my $nodeatt (sort keys %{$node_attlist}) { - if ($nodeatt eq "properties") { - my @newprops = split /,/, $node_attlist->{$nodeatt}; - foreach my $p (@newprops) { - if (defined($defprops{$p})) { - delete $defprops{$p}; - } else { - $self->qmgr("set node $node $nodeatt += $p"); - } - } - } else { - $definednatt{$nodeatt} = 1; - $self->qmgr("set node $node $nodeatt = ".$node_attlist->{$nodeatt}); - } - } - } - - # Removing non-defined node attributes if manualconfig is set to false - if ( $self->allowed($nodelist->{$node}) ) { - $self->debug(1,"Removing node $node attributes not part of the configuration (manualconfig=false)"); - # First delete properties not part of the configuration - foreach my $p (sort keys %defprops) { - $self->qmgr("set node $node properties -= '$p'"); - } - # Delete attributes not part of the configuration - # Special and/or readonly attributes should be filtered from processing - # via FILTER_PBSNODES_PATTERNS or handled separately (like properties) - foreach (sort keys %existingnatt) { - if (!defined($definednatt{$_}) && - ($_ ne 'properties')) { - $self->qmgr("unset node $node $_"); - } - } - } - } - } - - # Delete existing nodes not part of the configuration if manualconfig is set to false - if ( $self->allowed($tree->{node}) ) { - foreach (sort keys %existingnodes) { - unless (defined($definednodes{$_})) { - $self->qmgr("delete node $_", "Removing node $_..."); - } - } - } - } - - return 1; -} - - -# Set qmgr module variable to qmgr_bin (if defined) -# Returns value of qmgr -sub set_qmgr -{ - my ($self, $qmgr_bin) = @_; - - $qmgr = $qmgr_bin if defined($qmgr_bin); - - return $qmgr; -} - - -# For hashref cfg, return if component is allowed to make changes -# (it checks if the manualconfig attribute is set and false) -sub allowed -{ - my ($self, $cfg) = @_; - - return defined($cfg->{manualconfig}) && (!$cfg->{manualconfig}); -} - - -# force (re)create the serverdb -sub force_create -{ - my ($self, $binpath, $pbsroot) = @_; - - my $sleep = 10; - - my $pbs_server_bin = "$binpath"; - # it's in sbin - $pbs_server_bin =~ s/bin/sbin/; - $pbs_server_bin .= "/pbs_server"; - $self->info("Trying with pbs_server $pbs_server_bin"); - my $output = CAF::Process->new([$pbs_server_bin, '-d', $pbsroot, '-t', 'create', '-f'], log => $self)->output(); - if ($?) { - $self->error("Failed to create the server (ec $?): $output"); - return; - }; - sleep $sleep; - - my $qterm = "$binpath/qterm"; - $output = CAF::Process->new([$qterm], log => $self)->output(); - if ($?) { - $self->error("Failed to stop the server (ec $?), trying again: $output"); - sleep 2*$sleep; - $output = CAF::Process->new([$qterm], log => $self)->output(); - if ($?) { - $self->error("Failed to stop the server (ec $?) 2nd time, giving up: $output"); - return; - }; - }; - - return 1; -} - -# execute qmgr with command cmd -# if optional msg is passed, report the message with info level -# if optional keeps_state is passed, run command with it -sub qmgr -{ - my ($self, $cmd, $msg, $keeps_state) = @_; - $self->info($msg) if $msg; - - my $out = CAF::Process->new([$qmgr, "-c", $cmd], log => $self, keeps_state => $keeps_state ? 1 : 0)->output(); - if ($?) { - $self->error("Failed to run $qmgr $cmd: $out (", $? >> 8, ")"); - } else { - $self->debug(2, "qmgr $cmd successful"); - } - return $out; -} - -# Wait a bit for the server to become active in case it has been restarted. -# Check every 30s after the first try until it comes up; try for up to -# 5 minutes. -# Args: -# started : start with 5 second sleep (in case recently (re)started) -# Return a hashref with server attributes and queue -# data from the current config on success; undef on failure. -sub get_current_config -{ - my ($self, $started) = @_; - - $self->info("Retrieving current configuration..."); - my $remaining = 10; - sleep 5 if $started; - my $current_config = $self->qmgr("print server", undef, 1); - while ( $? && ($remaining > 0) ) { - $self->info("waiting 30s for qmgr to respond; $remaining tries remaining"); - $remaining--; - sleep 30; - $current_config = $self->qmgr("print server", undef, 1); - } - if ( $? ) { - $self->error("qmgr is not responding; aborting configuration"); - return; - } - - my $existing; - foreach my $line (split('\n', $current_config)) { - chomp $line; - if ($line =~ m/set server ([\w\.]+)/) { - # Mark the server attribute as set. - $existing->{satt}->{$1} = 1; - - } elsif ($line =~ m/create queue ([\w\.\-]+)/) { - # Create a hash for the queue. - $existing->{queues}->{$1} = {}; - - } elsif ($line =~ m/set queue ([\w\.\-]+)\s+([\w\.]+)/) { - # Mark the attribute as set for the given queue. - my $queue = $1; - my $name = $2; - $existing->{queues}->{$queue}->{$name} = 1; - } - } - return $existing; -} - - -1; # Required for PERL modules diff --git a/ncm-pbsserver/src/main/perl/pbsserver.pod b/ncm-pbsserver/src/main/perl/pbsserver.pod deleted file mode 100755 index bbd3870c..00000000 --- a/ncm-pbsserver/src/main/perl/pbsserver.pod +++ /dev/null @@ -1,84 +0,0 @@ -# ${license-info} -# ${developer-info} -# ${author-info} -# ${build-info} -# - -=head1 NAME - -pbsserver: NCM component to configure partially the pbs (torque) server. - -=head1 DESCRIPTION - -The I component configures the pbs (torque) server. -Unsetting attributes of nodes doesn't work (yet). - -=head1 RESOURCES - -=head2 pbsroot (/var/spool/pbs) - -The absolute path to the pbs root directory. - -=head2 binpath (/usr/bin) - -The absolute path to the pbs binaries qmgr and pbsnodes. - -=head2 submitfilter - -The content of the submit filter. This file will be written to the -file $pbsroot/submit_filter and a reference to this put into the -$pbsroot/torque.cfg file. If this is not specified, the reference to -the script will be removed. - -=head2 env - -A named list with the environment to use for the pbs server. As a -security feature, pbs removes the current environment when it starts -and substitutes the environment defined in this file. Typical things -to set are the PATH and LANG. Optionally for torque, the variable -TORQUEKEEPCOMPLETED can be set to keep jobs in a "completed" state for -5 minutes after they complete. This is very useful for debugging -problems. - -=head2 "/software/components/pbsserver/server" ? pbs_server - -Sets the configuration of the server. Structure as follows: - -I<"/software/components/pbsserver/server/manualconfig" : boolean> - -Set to false gives complete control to ncm-pbsserver, meaning that it -will configure defined attributes and will remove existing non-defined -ones. Set to true will configure defined ones, but not remove existing -non-defined ones, thus allowing local configuration of other -attributes. - -I<"/software/components/pbsserver/server/attlist" ? pbs_server_attlist> - -A named list with attributes to be set for the server through qmgr. - -=head2 "/software/components/pbsserver/queue" ? pbs_queuelist - -Sets the configuration of the queue. Structure as follows: - -I<"/software/components/pbsserver/queue/manualconfig" : boolean> - -Same as /software/components/pbsserver/server/manualconfig, but will -remove queues completely if set to false. - -I<"/software/components/pbsserver/queue/queuelist" ? pbs_queue> - -A named list where the key is the name of the queue and the value of -the type pbs_queue. This type has also a manualconfig to allow manual -configuration of the attributes of the queue. It also can have an -entry attlist of type pbs_queue_attlist, which is a named list with -the attributes of that queue. - -=head2 "/software/components/pbsserver/node" ? pbs_node_list - -Analog to /software/components/pbsserver/queue, with entries -manaulconfig and nodelist. Nodelist is a named list with the FQHN of -the workernode as key and as value the type pbs_node, consisting of a -manualconfig and an attlist of type pbs_node_attlist. - - -=cut diff --git a/ncm-pbsserver/src/test/perl/00-load.t b/ncm-pbsserver/src/test/perl/00-load.t deleted file mode 100644 index 9a228dba..00000000 --- a/ncm-pbsserver/src/test/perl/00-load.t +++ /dev/null @@ -1,18 +0,0 @@ -# ${license-info} -# ${author-info} -# ${build-info} - -=pod - -=head1 Smoke test - -Basic test that ensures that our module will load correctly. - -=cut - -use strict; -use warnings; -use Test::More tests => 1; -use Test::Quattor; - -use_ok("NCM::Component::pbsserver"); diff --git a/ncm-pbsserver/src/test/perl/pod-syntax.t b/ncm-pbsserver/src/test/perl/pod-syntax.t deleted file mode 100644 index a7864338..00000000 --- a/ncm-pbsserver/src/test/perl/pod-syntax.t +++ /dev/null @@ -1,6 +0,0 @@ - -use Test::More; -use Test::Pod; - -my @dirs = qw(target/lib/perl); -all_pod_files_ok(all_pod_files(@dirs)); diff --git a/ncm-pbsserver/src/test/perl/simple.t b/ncm-pbsserver/src/test/perl/simple.t deleted file mode 100644 index 5eaf1dfd..00000000 --- a/ncm-pbsserver/src/test/perl/simple.t +++ /dev/null @@ -1,170 +0,0 @@ -use strict; -use warnings; - -BEGIN { - *CORE::GLOBAL::sleep = sub {}; -} - -use Test::More; -use CAF::Object; -use Test::Quattor qw(simple); -use NCM::Component::pbsserver; - - -use Readonly; - -# Very minimal server config -Readonly my $PRINT_SERVER => <<'EOF'; - -create queue q24h -set queue q24h queue_type = Execution -set queue q24h Priority = 60 - -create queue default -set queue default queue_type = Route -set queue default route_destinations = short -set queue default route_destinations += long -set queue default enabled = True -set queue default started = True - - -set server scheduling = True -set server acl_host_enable = False -set server acl_hosts = localhost -set server acl_hosts += some.server -set server to = remove - -EOF - -Readonly my $PBSNODES => <<'EOF'; -node0.example.com - state = job-exclusive - power_state = Running - np = 20 - properties = prop1,prop2 - ntype = cluster - jobs = 10-19/123.master.example.comf,0-9/456.master.example.com - status = rectime=some,garbage - mom_service_port = 15002 - mom_manager_port = 15003 - total_sockets = 2 - total_numa_nodes = 4 - total_cores = 20 - total_threads = 20 - dedicated_sockets = 0 - dedicated_numa_nodes = 0 - dedicated_cores = 0 - dedicated_threads = 20 - -node1.example.com - state = job-exclusive - power_state = Running - np = 20 - properties = prop1,prop2 - ntype = cluster - jobs = 10-19/123.master.example.comf,0-9/456.master.example.com - status = rectime=some,garbage - mom_service_port = 15002 - mom_manager_port = 15003 - total_sockets = 2 - total_numa_nodes = 4 - total_cores = 20 - total_threads = 20 - dedicated_sockets = 0 - dedicated_numa_nodes = 0 - dedicated_cores = 0 - dedicated_threads = 20 -EOF - -my $cfg = get_config_for_profile('simple'); -my $cmp = NCM::Component::pbsserver->new('simple'); - -set_file_contents("/var/spool/maui/maui.cfg", "something"); - -# Set expected binaries -set_file_contents("/usr/bin/qmgr", "qmgr"); -set_file_contents("/usr/bin/pbsnodes", "pbsnodes"); - -# Only has to exist, content is not actually used -set_file_contents("/var/spool/pbs/server_priv/nodes", "all nodes"); - -set_desired_output('/usr/bin/qmgr -c print server', $PRINT_SERVER); -set_desired_output('/usr/bin/pbsnodes -a', $PBSNODES); - -command_history_reset(); -$cmp->set_qmgr('/usr/bin/qmgr'); -diag explain $cmp->get_current_config(); -is_deeply($cmp->get_current_config(), { - satt => { - scheduling => 1, - acl_host_enable => 1, - acl_hosts => 1, - to => 1, - }, - queues => { - default => { - enabled => 1, - queue_type => 1, - route_destinations => 1, - started => 1, - }, - q24h => { - Priority => 1, - queue_type => 1, - }, - }, -}, "Current config from PRINT_SERVER"); -ok(command_history_ok(['qmgr -c print server']), "expected commands for get_current_config"); - -command_history_reset(); -is($cmp->Configure($cfg), 1, "Component runs correctly with a test profile"); - -my $fh = get_file("/var/spool/pbs/server_name"); -is("$fh", "master.example.com\n", "server_name file created"); - -ok(command_history_ok([ - # missing serverdb - 'service pbs_server stop', - '/usr/sbin/pbs_server -d /var/spool/pbs -t create -f', - 'service pbs_server start', - # current config - 'qmgr -c print server', - # set/unset server attributes - 'qmgr -c set server down_on_error = 1', - 'qmgr -c set server scheduling = 1', - 'qmgr -c set server server_name = master.example.com', - 'qmgr -c unset server acl_host_enable', - 'qmgr -c unset server to', - # restart due to changed server_name - 'service pbs_server restart', - # queues - 'qmgr -c print server', - 'qmgr -c set queue default queue_type = Route', - 'qmgr -c set queue default route_destinations = "short,long"', - 'qmgr -c set queue default enabled = 1', - 'qmgr -c set queue default started = 1', - 'qmgr -c create queue q72h', - 'qmgr -c set queue q72h Priority = 60', - 'qmgr -c set queue q72h acl_group_enable = 1', - 'qmgr -c set queue q72h acl_group_sloppy = 1', - 'qmgr -c set queue q72h acl_groups = "gpilot,wheel"', - 'qmgr -c set queue q72h queue_type = Execution', - 'qmgr -c set queue q72h enabled = 1', - 'qmgr -c delete queue q24h', - # node state - 'pbsnodes -a', - 'qmgr -c set node node1.example.com np = 20', - 'qmgr -c set node node1.example.com properties \+= prop3', - "qmgr -c set node node1.example.com properties -= 'prop1'", - 'qmgr -c create node node2.example.com', - 'qmgr -c set node node2.example.com np = 22', - 'qmgr -c set node node2.example.com properties \+= prop3', - 'qmgr -c set node node2.example.com properties \+= prop4', - 'qmgr -c delete node node0.example.com', -], [ - # protected attributes - 'qmgr -c .*? node1.example.com.*(status|(total|dedicated)_(sockets|numa_nodes|cores|threads))', -]), "expected configure commands"); - - -done_testing; diff --git a/ncm-pbsserver/src/test/resources/ccm.cfg b/ncm-pbsserver/src/test/resources/ccm.cfg deleted file mode 100644 index d0aebda3..00000000 --- a/ncm-pbsserver/src/test/resources/ccm.cfg +++ /dev/null @@ -1,6 +0,0 @@ -debug 0 -get_timeout 1 -profile https://www.google.com -cache_root target/test/cache -retrieve_wait 0 -retrieve_retries 1 diff --git a/ncm-pbsserver/src/test/resources/simple.pan b/ncm-pbsserver/src/test/resources/simple.pan deleted file mode 100644 index 6f3a3ce5..00000000 --- a/ncm-pbsserver/src/test/resources/simple.pan +++ /dev/null @@ -1,44 +0,0 @@ -object template simple; - -# mock pkg_repl -function pkg_repl = { null; }; - -include 'components/pbsserver/config'; - -# remove the dependencies -'/software/components/pbsserver/dependencies' = null; - -"/software/components/pbsserver/pbsroot" = '/var/spool/pbs'; - -"/software/components/pbsserver/server/manualconfig" = false; -prefix "/software/components/pbsserver/server/attlist"; -"server_name" = "master.example.com"; -"down_on_error" = true; -"scheduling" = true; - -"/software/components/pbsserver/queue/manualconfig" = false; -prefix "/software/components/pbsserver/queue/queuelist/default"; -"attlist/enabled" = true; -"attlist/queue_type" = "Route"; -"attlist/route_destinations" = '"short,long"'; -"attlist/started" = true; -"manualconfig" = false; - -prefix "/software/components/pbsserver/queue/queuelist/q72h"; -"attlist/Priority" = 60; -"attlist/acl_group_enable" = true; -"attlist/acl_group_sloppy" = true; -"attlist/acl_groups" = '"gpilot,wheel"'; -"attlist/enabled" = true; -"attlist/queue_type" = "Execution"; -"manualconfig" = false; - -"/software/components/pbsserver/node/manualconfig" = false; -prefix "/software/components/pbsserver/node/nodelist/node1.example.com"; -"attlist/np" = 20; -"attlist/properties" = 'prop2,prop3'; -"manualconfig" = false; -prefix "/software/components/pbsserver/node/nodelist/node2.example.com"; -"attlist/np" = 22; -"attlist/properties" = 'prop3,prop4'; -"manualconfig" = false; diff --git a/pom.xml b/pom.xml index 95e511cc..8160d649 100644 --- a/pom.xml +++ b/pom.xml @@ -43,7 +43,6 @@ ncm-myproxy ncm-pbsclient ncm-pbsknownhosts - ncm-pbsserver ncm-vomsclient ncm-wlconfig ncm-wmsclient