ood_core 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ec6f497f2c284f0ff82e4523a4deb37eee2cb9e7
4
- data.tar.gz: 3d8c7a43d9b35fcc5b6e6f29ae58d7f1b5192f71
3
+ metadata.gz: 459b58d5f136ce29268fe40b8eaf470de62e2784
4
+ data.tar.gz: d63226217007a7b7a269561b45a3bbc655e83c57
5
5
  SHA512:
6
- metadata.gz: a0d8048e7402f17dfd4d9f7504adbe23c142f4a0c6e3100b4ae4ce5feadbd24e9c7430ac19dee00b7e3127f328c3227e5051c4d41abb64025c02a662dcd09c20
7
- data.tar.gz: 53c70e68d490a1a196d0caab502f0040b7765582e52b39cbd8ca036112c39f6d933fd48f7957d8fd3e63ffdd19a3b492ebc00147396ca5306f4baf8ba411b84b
6
+ metadata.gz: 3d15a23ba546a7c1ca4fd6dd6ef2f652e11f9eadfd3ae81c92b71649c04a380c5c282c5628a7b6aa571aaa42180b54e68cabce7bf0d6ebaf164588f26c7abebc
7
+ data.tar.gz: 4736fcd7049e7c99f3587f936b98afd45cc1fc3f7ec110a28f788e1cc1421ad9e24e2ee034df78e836cb0e7902b0a6041dff6611fce9e362fa1dbb406d4445e2
data/CHANGELOG.md CHANGED
@@ -7,25 +7,39 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ## [0.1.1] - 2017-09-08
10
+ ## [0.2.0] - 2017-10-11
11
+ ### Added
12
+ - Added Batch Connect helper function to wait for port to be used.
13
+ [#57](https://github.com/OSC/ood_core/issues/57)
14
+ - Can include Batch Connect helper functions when writing to files or running
15
+ remote code. [#58](https://github.com/OSC/ood_core/issues/58)
16
+ - The Batch Connect helper functions are now available to use in the forked
17
+ Batch Connect main script. [#59](https://github.com/OSC/ood_core/issues/59)
18
+ - The `host` and `port` environment variables are now available to use in the
19
+ forked Batch Connect main script.
20
+ [#60](https://github.com/OSC/ood_core/issues/60)
11
21
 
12
22
  ### Fixed
23
+ - Fixed a bug with the `nc` command used in the Batch Connect helper functions
24
+ for CentOS 7. [#55](https://github.com/OSC/ood_core/issues/55)
25
+ - Fixed not correctly detecting open ports for specific ip address in Batch
26
+ Connect helper functions. [#56](https://github.com/OSC/ood_core/issues/56)
27
+ - Fixed a bug when parsing nodes in the Slurm adapter.
28
+ [#54](https://github.com/OSC/ood_core/issues/54)
13
29
 
30
+ ## [0.1.1] - 2017-09-08
31
+ ### Fixed
14
32
  - fix crash when calling `Adapters::Lsf#info(id:)` with "invalid" id
15
33
  - optimize `Adapters::Lsf#info_where_owner` by using `bjobs -u $USER` when a single user is specified
16
34
 
17
35
  ## [0.1.0] - 2017-07-17
18
-
19
36
  ### Changed
20
-
21
37
  - Setting the host in a batch_connect batch script can now be directly
22
38
  manipulated through the `set_host` initialization parameter.
23
39
  [#42](https://github.com/OSC/ood_core/issues/42)
24
40
 
25
41
  ## [0.0.5] - 2017-07-05
26
-
27
42
  ### Added
28
-
29
43
  - Add wallclock time limit to `OodCore::Job::Info` object.
30
44
  - Add further support for the LSF adapter.
31
45
  - Add a new Batch Connect template feature that builds batch scripts to launch
@@ -34,57 +48,45 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
34
48
  - Add method to filter list of batch jobs for a given owner or owners.
35
49
 
36
50
  ### Changed
37
-
38
51
  - Torque adapter provides nodes/procs info if available for non-running jobs.
39
52
  - Slurm adapter provides node info if available for non-running jobs.
40
53
  - Changed the `CHANGELOG.md` formatting.
41
54
 
42
55
  ### Removed
43
-
44
56
  - Remove deprecated tests for the Slurm adapter.
45
57
 
46
58
  ### Fixed
47
-
48
59
  - Fix parsing bjobs output for LSF 9.1, which has extra SLOTS column.
49
60
 
50
61
  ## [0.0.4] - 2017-05-17
51
-
52
62
  ### Changed
53
-
54
63
  - By default all PBS jobs output stdout & stderr to output path unless an error
55
64
  path is specified (mimics behavior of Slurm and LSF)
56
65
 
57
66
  ### Removed
58
-
59
67
  - Remove `OodCore::Job::Script#min_phys_memory` due to lack of commonality
60
68
  across resource managers.
61
69
  - Remove `OodCore::Job::Script#join_files` due to lack of support in resource
62
70
  managers.
63
71
 
64
72
  ## [0.0.3] - 2017-04-28
65
-
66
73
  ### Added
67
-
68
74
  - Provide support for Slurm conf file.
69
75
 
70
76
  ### Fixed
71
-
72
77
  - Correct code documentation for `Script#min_phys_memory`.
73
78
  - Add fix for login feature being allowed on all clusters even if not defined.
74
79
 
75
80
  ## [0.0.2] - 2017-04-27
76
-
77
81
  ### Removed
78
-
79
82
  - Remove the `OodCore::Job::NodeRequest` object.
80
83
 
81
84
  ## 0.0.1 - 2017-04-17
82
-
83
85
  ### Added
84
-
85
86
  - Initial release!
86
87
 
87
- [Unreleased]: https://github.com/OSC/ood_core/compare/v0.1.1...HEAD
88
+ [Unreleased]: https://github.com/OSC/ood_core/compare/v0.2.0...HEAD
89
+ [0.2.0]: https://github.com/OSC/ood_core/compare/v0.1.1...v0.2.0
88
90
  [0.1.1]: https://github.com/OSC/ood_core/compare/v0.1.0...v0.1.1
89
91
  [0.1.0]: https://github.com/OSC/ood_core/compare/v0.0.5...v0.1.0
90
92
  [0.0.5]: https://github.com/OSC/ood_core/compare/v0.0.4...v0.0.5
@@ -94,31 +94,56 @@ module OodCore
94
94
  passwd_size = context.fetch(:passwd_size, 32).to_i
95
95
 
96
96
  <<-EOT.gsub(/^ {14}/, '')
97
- # Generate random integer in range [$1..$2]
98
- function random () {
99
- shuf -i ${1}-${2} -n 1
100
- }
101
-
102
- # Check if port $1 is in use
103
- function used_port () {
104
- local PORT=${1}
105
- nc -z localhost ${PORT} &>/dev/null
106
- }
107
-
108
- # Find available port in range [$1..$2]
109
- # Default: [#{min_port}..#{max_port}]
110
- function find_port () {
111
- local PORT=$(random ${1:-#{min_port}} ${2:-#{max_port}})
112
- while $(used_port ${PORT}); do
113
- PORT=$(random ${1:-#{min_port}} ${2:-#{max_port}})
114
- done
115
- echo ${PORT}
116
- }
117
-
118
- # Generate random alphanumeric password with $1 (default: #{passwd_size}) characters
119
- function create_passwd () {
120
- tr -cd '[:alnum:]' < /dev/urandom 2>/dev/null | head -c${1:-#{passwd_size}}
97
+ # Source in all the helper functions
98
+ source_helpers () {
99
+ # Generate random integer in range [$1..$2]
100
+ random_number () {
101
+ shuf -i ${1}-${2} -n 1
102
+ }
103
+ export -f random_number
104
+
105
+ # Check if port $1 is in use
106
+ port_used () {
107
+ local port="${1#*:}"
108
+ local host=$(expr "${1}" : '\\(.*\\):' || echo "localhost")
109
+ nc -w 2 "${host}" "${port}" < /dev/null &> /dev/null
110
+ }
111
+ export -f port_used
112
+
113
+ # Find available port in range [$2..$3] for host $1
114
+ # Default: [#{min_port}..#{max_port}]
115
+ find_port () {
116
+ local host="${1:-localhost}"
117
+ local port=$(random_number "${2:-#{min_port}}" "${3:-#{max_port}}")
118
+ while port_used "${host}:${port}"; do
119
+ port=$(random_number "${2:-#{min_port}}" "${3:-#{max_port}}")
120
+ done
121
+ echo "${port}"
122
+ }
123
+ export -f find_port
124
+
125
+ # Wait $2 seconds until port $1 is in use
126
+ # Default: wait 30 seconds
127
+ wait_until_port_used () {
128
+ local port="${1}"
129
+ local time="${2:-30}"
130
+ for ((i=1; i<=time*2; i++)); do
131
+ if port_used "${port}"; then
132
+ return 0
133
+ fi
134
+ sleep 0.5
135
+ done
136
+ return 1
137
+ }
138
+ export -f wait_until_port_used
139
+
140
+ # Generate random alphanumeric password with $1 (default: #{passwd_size}) characters
141
+ create_passwd () {
142
+ tr -cd '[:alnum:]' < /dev/urandom 2> /dev/null | head -c${1:-#{passwd_size}}
143
+ }
144
+ export -f create_passwd
121
145
  }
146
+ export -f source_helpers
122
147
  EOT
123
148
  end.to_s
124
149
  end
@@ -173,8 +198,12 @@ module OodCore
173
198
  <<-EOT.gsub(/^ {12}/, '')
174
199
  cd #{work_dir}
175
200
 
201
+ # Export useful connection variables
202
+ export host
203
+ export port
204
+
176
205
  # Generate a connection yaml file with given parameters
177
- function create_yml () {
206
+ create_yml () {
178
207
  echo "Generating connection YAML file..."
179
208
  (
180
209
  umask 077
@@ -183,7 +212,7 @@ module OodCore
183
212
  }
184
213
 
185
214
  # Cleanliness is next to Godliness
186
- function clean_up () {
215
+ clean_up () {
187
216
  echo "Cleaning up..."
188
217
  #{clean_script.gsub(/\n(?=[^\s])/, "\n ")}
189
218
  pkill -P $$
@@ -191,6 +220,7 @@ module OodCore
191
220
  }
192
221
 
193
222
  #{bash_helpers}
223
+ source_helpers
194
224
 
195
225
  # Set host of current machine
196
226
  #{set_host}
@@ -430,21 +430,23 @@ module OodCore
430
430
  # Convert host list string to individual nodes
431
431
  # "em082"
432
432
  # "em[014,055-056,161]"
433
- # "n0163/2,7,10-11+n0205/0-11+n0156/0-11"
433
+ # "c457-[011-012]"
434
+ # "c438-[062,104]"
435
+ # "c427-032,c429-002"
434
436
  def parse_nodes(node_list)
435
- /^(?<prefix>[^\[]+)(\[(?<range>[^\]]+)\])?$/ =~ node_list
436
-
437
- if range
438
- range.split(",").map do |x|
439
- x =~ /^(\d+)-(\d+)$/ ? ($1..$2).to_a : x
440
- end.flatten.map do |n|
441
- { name: prefix + n, procs: nil }
437
+ node_list.to_s.scan(/([^,\[]+)(?:\[([^\]]+)\])?/).map do |prefix, range|
438
+ if range
439
+ range.split(",").map do |x|
440
+ x =~ /^(\d+)-(\d+)$/ ? ($1..$2).to_a : x
441
+ end.flatten.map do |n|
442
+ { name: prefix + n, procs: nil }
443
+ end
444
+ elsif prefix
445
+ [ { name: prefix, procs: nil } ]
446
+ else
447
+ []
442
448
  end
443
- elsif prefix
444
- [ { name: prefix, procs: nil } ]
445
- else
446
- []
447
- end
449
+ end.flatten
448
450
  end
449
451
 
450
452
  # Determine state from Slurm state code
@@ -1,4 +1,4 @@
1
1
  module OodCore
2
2
  # The current version of {OodCore}
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ood_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Nicklas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-09-08 00:00:00.000000000 Z
11
+ date: 2017-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ood_support