openshift-origin-node 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of openshift-origin-node might be problematic. Click here for more details.

Files changed (51) hide show
  1. data/COPYRIGHT +1 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +11 -0
  4. data/README.md +3 -0
  5. data/Rakefile +28 -0
  6. data/bin/oo-add-alias +93 -0
  7. data/bin/oo-app-create +110 -0
  8. data/bin/oo-app-destroy +100 -0
  9. data/bin/oo-app-state-show +74 -0
  10. data/bin/oo-authorized-ssh-key-add +83 -0
  11. data/bin/oo-authorized-ssh-key-remove +82 -0
  12. data/bin/oo-broker-auth-key-add +84 -0
  13. data/bin/oo-broker-auth-key-remove +72 -0
  14. data/bin/oo-cartridge-info +70 -0
  15. data/bin/oo-cartridge-list +70 -0
  16. data/bin/oo-connector-execute +94 -0
  17. data/bin/oo-env-var-add +81 -0
  18. data/bin/oo-env-var-remove +78 -0
  19. data/bin/oo-get-quota +64 -0
  20. data/bin/oo-remove-alias +93 -0
  21. data/bin/oo-set-quota +59 -0
  22. data/conf/node.conf +30 -0
  23. data/conf/resource_limits.template +67 -0
  24. data/lib/openshift-origin-node.rb +29 -0
  25. data/lib/openshift-origin-node/config.rb +21 -0
  26. data/lib/openshift-origin-node/environment.rb +26 -0
  27. data/lib/openshift-origin-node/model/application_container.rb +298 -0
  28. data/lib/openshift-origin-node/model/frontend_httpd.rb +346 -0
  29. data/lib/openshift-origin-node/model/node.rb +134 -0
  30. data/lib/openshift-origin-node/model/unix_user.rb +738 -0
  31. data/lib/openshift-origin-node/plugins/unix_user_observer.rb +86 -0
  32. data/lib/openshift-origin-node/utils/shell_exec.rb +115 -0
  33. data/lib/openshift-origin-node/version.rb +23 -0
  34. data/misc/bin/oo-admin-ctl-cgroups +482 -0
  35. data/misc/bin/oo-cgroup-read +25 -0
  36. data/misc/bin/oo-get-mcs-level +29 -0
  37. data/misc/bin/oo-trap-user +248 -0
  38. data/misc/bin/rhcsh +155 -0
  39. data/misc/bin/setup_pam_fs_limits.sh +146 -0
  40. data/misc/bin/teardown_pam_fs_limits.sh +73 -0
  41. data/misc/doc/cgconfig.conf +26 -0
  42. data/misc/etc/openshift-run.conf +1 -0
  43. data/misc/init/openshift-cgroups +56 -0
  44. data/misc/services/openshift-cgroups.service +14 -0
  45. data/openshift-origin-node.gemspec +31 -0
  46. data/rubygem-openshift-origin-node.spec +263 -0
  47. data/test/test_helper.rb +20 -0
  48. data/test/unit/frontend_httpd_test.rb +144 -0
  49. data/test/unit/unix_user_test.rb +95 -0
  50. data/test/unit/version_test.rb +45 -0
  51. metadata +230 -0
@@ -0,0 +1,81 @@
1
+ #!/usr/bin/env oo-ruby
2
+ #--
3
+ # Copyright 2010 Red Hat, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ def usage
19
+ puts <<USAGE
20
+ == Synopsis
21
+
22
+ #{$0}: Adds an environment var to the app.
23
+ This command must be run as root.
24
+
25
+ == Usage
26
+
27
+ #{$0} --with-app-uuid APP_UUID \\
28
+ --with-container-uuid UUID \\
29
+ --with-key KEY \\
30
+ --with-value VALUE
31
+
32
+ Options:
33
+ -h|--help:
34
+ Prints this message
35
+
36
+ UUID: Unique identifier for the application
37
+ KEY: The env var key
38
+ VALUE: The env var value
39
+
40
+ USAGE
41
+ end
42
+
43
+ require 'rubygems'
44
+ require 'openshift-origin-node'
45
+ require 'openshift-origin-node/utils/shell_exec'
46
+ opts = GetoptLong.new(
47
+ ["--with-app-uuid", "-a", GetoptLong::REQUIRED_ARGUMENT],
48
+ ["--with-container-uuid", "-c", GetoptLong::REQUIRED_ARGUMENT],
49
+ ["--with-key", "-k", GetoptLong::REQUIRED_ARGUMENT],
50
+ ["--with-value", "-v", GetoptLong::REQUIRED_ARGUMENT]
51
+ )
52
+
53
+ args = {}
54
+ begin
55
+ opts.each{ |k,v| args[k]=v }
56
+ rescue GetoptLong::Error => e
57
+ usage
58
+ end
59
+
60
+ container_uuid = args['--with-container-uuid']
61
+ app_uuid = args['--with-app-uuid']
62
+ key = args['--with-key']
63
+ value = args['--with-value']
64
+
65
+ if args["--help"]
66
+ usage
67
+ end
68
+
69
+ unless container_uuid and app_uuid and key and value
70
+ usage
71
+ end
72
+
73
+ begin
74
+ container = OpenShift::ApplicationContainer.new(app_uuid, container_uuid)
75
+ container.user.add_env_var(key, value)
76
+ rescue Exception => e
77
+ $stderr.puts(e.message)
78
+ exit -1
79
+ else
80
+ exit 0
81
+ end
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env oo-ruby
2
+ #--
3
+ # Copyright 2010 Red Hat, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ require 'rubygems'
19
+ require 'openshift-origin-node'
20
+ require 'openshift-origin-node/utils/shell_exec'
21
+
22
+ def usage
23
+ puts <<USAGE
24
+ == Synopsis
25
+
26
+ #{$0}: Removes an env var from the app.
27
+ This command must be run as root.
28
+
29
+ == Usage
30
+
31
+ #{$0} --with-app-uuid APP_UUID \\
32
+ --with-container-uuid UUID \\
33
+ --with-key KEY
34
+
35
+ Options:
36
+ -h|--help:
37
+ Prints this message
38
+
39
+ UUID: Unique identifier for the application
40
+ NAME: The name of the application to create
41
+
42
+ USAGE
43
+ exit 255
44
+ end
45
+
46
+ opts = GetoptLong.new(
47
+ ['--with-app-uuid', '-a', GetoptLong::REQUIRED_ARGUMENT],
48
+ ['--with-container-uuid', '-c', GetoptLong::REQUIRED_ARGUMENT],
49
+ ['--with-key', '-k', GetoptLong::REQUIRED_ARGUMENT]
50
+ )
51
+
52
+ args = {}
53
+ begin
54
+ opts.each{ | k, v | args[k]=v }
55
+ rescue GetoptLong::Error => e
56
+ usage
57
+ end
58
+
59
+ uuid = args['--with-container-uuid']
60
+ key = args['--with-key']
61
+
62
+ if args['--help']
63
+ usage
64
+ end
65
+
66
+ unless uuid and key
67
+ usage
68
+ end
69
+
70
+ begin
71
+ container = OpenShift::ApplicationContainer.new(uuid, uuid)
72
+ container.user.remove_env_var(key)
73
+ rescue Exception => e
74
+ $stderr.puts(e.message)
75
+ exit -1
76
+ else
77
+ exit 0
78
+ end
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env oo-ruby
2
+
3
+ require 'rubygems'
4
+ require 'openshift-origin-node'
5
+ require 'optparse'
6
+
7
+ def usage
8
+ puts <<USAGE
9
+ == Synopsis
10
+
11
+ #{$0}: Gets the quota for a gear.
12
+
13
+ == Usage
14
+
15
+ #{$0} -c <UUID>
16
+
17
+ Options:
18
+ -h|--help:
19
+ Prints this message
20
+
21
+ USAGE
22
+ exit 255
23
+ end
24
+
25
+ opts = GetoptLong.new(
26
+ ['--uuid', '-c', GetoptLong::REQUIRED_ARGUMENT],
27
+ ['--help', '-?', GetoptLong::NO_ARGUMENT]
28
+ )
29
+
30
+ args = {}
31
+ begin
32
+ opts.each{ |k,v| args[k]=v }
33
+ rescue GetoptLong::Error => e
34
+ usage
35
+ end
36
+
37
+ if args["--help"]
38
+ usage
39
+ end
40
+
41
+ uuid = args['--uuid']
42
+
43
+ unless uuid
44
+ usage
45
+ end
46
+
47
+
48
+ begin
49
+ quota_info = OpenShift::Node.get_quota(uuid)
50
+ filesystem, quota, quota_soft, quota_hard, inodes, inodes_soft, inodes_hard = quota_info
51
+ puts "Quota information for uuid: #{uuid}"
52
+ puts "Filesystem: #{filesystem}"
53
+ puts "Blocks used: #{quota}"
54
+ puts "Soft limit for blocks: #{quota_soft}"
55
+ puts "Hard limit for blocks: #{quota_hard}"
56
+ puts "Inodes used: #{inodes}"
57
+ puts "Soft limit for inodes: #{inodes_soft}"
58
+ puts "Hard limit for inodes: #{inodes_hard}"
59
+ rescue Exception => e
60
+ $stderr.puts(e.message)
61
+ exit -1
62
+ else
63
+ exit 0
64
+ end
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env oo-ruby
2
+ #--
3
+ # Copyright 2010 Red Hat, Inc.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #++
17
+
18
+ def usage
19
+ puts <<USAGE
20
+ == Synopsis
21
+
22
+ #{$0}: Add a frontend httpd alias to a gear.
23
+ This command must be run as root.
24
+
25
+ == Usage
26
+
27
+ #{$0} --with-container-uuid UUID \\
28
+ --with-container-name NAME \\
29
+ --with-namespace NAMESPACE \\
30
+ --with-alias-name ALIAS
31
+
32
+ == List of arguments
33
+ -a|--with-alias-name alias Alias to add to the gear
34
+ -c|--with-container-uuid gear_uuid Unique identifier for the gear(required)
35
+ |--with-namespace namespace Namespace of the application (required)
36
+ |--with-container-name gear_name Name of the gear
37
+ -n|--dry-run Don't make changes, just do a dry run.
38
+ -q|--porcelain TODO: what does this do?
39
+ -d|--debug Enable debug mode
40
+ -h|--help Print this message
41
+
42
+ USAGE
43
+ exit 255
44
+ end
45
+
46
+ require 'rubygems'
47
+ require 'openshift-origin-node'
48
+ opts = GetoptLong.new(
49
+ ["--with-alias-name", "-a", GetoptLong::REQUIRED_ARGUMENT],
50
+ ["--with-container-uuid", "-c", GetoptLong::REQUIRED_ARGUMENT],
51
+ ["--with-namespace", GetoptLong::REQUIRED_ARGUMENT],
52
+ ["--with-container-name", GetoptLong::REQUIRED_ARGUMENT],
53
+ ["--dry-run", "-n", GetoptLong::NO_ARGUMENT],
54
+ ["--porcelain", "-q", GetoptLong::NO_ARGUMENT],
55
+ ["--debug", "-d", GetoptLong::NO_ARGUMENT],
56
+ ["--help", "-?", GetoptLong::NO_ARGUMENT]
57
+ )
58
+
59
+ args = {}
60
+ begin
61
+ opts.each{ |k,v| args[k]=v }
62
+ rescue GetoptLong::Error => e
63
+ usage
64
+ end
65
+
66
+ if args["--help"]
67
+ usage
68
+ end
69
+
70
+ alias_name = args['--with-alias-name']
71
+ container_uuid = args['--with-container-uuid']
72
+ container_name = args['--with-container-name']
73
+ namespace = args['--with-namespace']
74
+
75
+ $dry_run = true if args['--dry-run']
76
+ $oo_debug = true if args['--debug']
77
+ $porcelain = args['--porcelain'] ? true : false
78
+
79
+ unless container_uuid
80
+ usage
81
+ end
82
+
83
+ begin
84
+ frontend = OpenShift::FrontendHttpServer.new(container_uuid, container_name, namespace)
85
+ out, err, rc = frontend.remove_alias(alias_name)
86
+ rescue Exception => e
87
+ $stderr.puts(e.message)
88
+ exit -1
89
+ else
90
+ $stdout.puts(out) if out != ""
91
+ $stderr.puts(err) if err != ""
92
+ exit rc
93
+ end
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env oo-ruby
2
+
3
+ require 'rubygems'
4
+ require 'openshift-origin-node'
5
+ require 'optparse'
6
+
7
+ def usage
8
+ puts <<USAGE
9
+ == Synopsis
10
+
11
+ #{$0}: Sets the quota for a gear.
12
+
13
+ == Usage
14
+
15
+ #{$0} -c <UUID> -b <BLOCKS> -i <INODES>
16
+
17
+ Options:
18
+ -h|--help:
19
+ Prints this message
20
+
21
+ USAGE
22
+ exit 255
23
+ end
24
+
25
+ opts = GetoptLong.new(
26
+ ['--uuid' , '-c', GetoptLong::REQUIRED_ARGUMENT],
27
+ ['--blocks', '-b', GetoptLong::REQUIRED_ARGUMENT],
28
+ ['--inodes', '-i', GetoptLong::REQUIRED_ARGUMENT],
29
+ ['--help' , '-?', GetoptLong::NO_ARGUMENT]
30
+ )
31
+
32
+ args = {}
33
+ begin
34
+ opts.each{ |k,v| args[k]=v }
35
+ rescue GetoptLong::Error => e
36
+ usage
37
+ end
38
+
39
+ if args["--help"]
40
+ usage
41
+ end
42
+
43
+ uuid = args['--uuid']
44
+ blocks = args['--blocks']
45
+ inodes = args['--inodes']
46
+
47
+ # modification to at least one parameter (blocks or inodes) must be requested
48
+ if !uuid or (!blocks and !inodes)
49
+ usage
50
+ end
51
+
52
+ begin
53
+ OpenShift::Node.set_quota(uuid, blocks, inodes)
54
+ rescue Exception => e
55
+ $stderr.puts(e.message)
56
+ exit -1
57
+ else
58
+ exit 0
59
+ end
@@ -0,0 +1,30 @@
1
+ # These should not be left at default values, even for a demo.
2
+ # "PUBLIC" networking values are ones that end-users should be able to reach.
3
+ PUBLIC_HOSTNAME="please.set.node.public-hostname.fqdn" # The node host's public hostname
4
+ PUBLIC_IP="127.0.0.1" # The node host's public IP address
5
+ BROKER_HOST="localhost" # IP or DNS name of broker server for REST API
6
+
7
+ # Usually (unless in a demo) this should be changed to the domain for your installation:
8
+ CLOUD_DOMAIN="example.com" # Domain suffix to use for applications (Must match broker config)
9
+
10
+ # You may want these, depending on the complexity of your networking:
11
+ # EXTERNAL_ETH_DEV='eth0' # Specify the internet facing public ethernet device
12
+ # INTERNAL_ETH_DEV='eth1' # Specify the internal cluster facing ethernet device
13
+ INSTANCE_ID="localhost" # Set by RH EC2 automation
14
+
15
+
16
+ # Generally the following should not be changed:
17
+ GEAR_BASE_DIR="/var/lib/openshift" # gear root directory
18
+ GEAR_SKEL_DIR="/etc/openshift/skel" # skel files to use when building a gear
19
+ GEAR_SHELL="/usr/bin/oo-trap-user" # shell to use for the gear
20
+ GEAR_GECOS="OpenShift guest" # Gecos information to populate for the gear user
21
+ GEAR_MIN_UID=500 # Lower bound of UID used to create gears
22
+ GEAR_MAX_UID=6500 # Upper bound of UID used to create gears
23
+ OPENSHIFT_NODE_PLUGINS="openshift-origin-node/plugins/unix_user_observer" # Extentions to load when customize/observe openshift-origin-node models
24
+ CARTRIDGE_BASE_PATH="/usr/libexec/openshift/cartridges" # Locations where cartridges are installed
25
+ LAST_ACCESS_DIR="/var/lib/openshift/.last_access" # Location to maintain last accessed time for gears
26
+ APACHE_ACCESS_LOG="/var/log/httpd/access_log" # Localion of httpd for node
27
+ PROXY_MIN_PORT_NUM=35531 # Lower bound of port numbers used to proxy ports externally
28
+ PROXY_PORTS_PER_GEAR=5 # Number of proxy ports available per gear
29
+ CREATE_APP_SYMLINKS=0 # If set to 1, creates gear-name symlinks to the UUID directories (debugging only)
30
+ OPENSHIFT_HTTP_CONF_DIR="/etc/httpd/conf.d/openshift"
@@ -0,0 +1,67 @@
1
+ #
2
+ # Limit resources for a new OpenShift guest user on a node
3
+ #
4
+ # Standard Profile
5
+ #
6
+ node_profile=small
7
+
8
+ #
9
+ # Quotas: File system limits
10
+ #
11
+ quota_files=40000
12
+ # 1GB. 1 block = 1024byte
13
+ quota_blocks=1048576
14
+
15
+ # For no over commitment, should be memory_limit_in_bytes / (Total System Memory - 1G)
16
+ max_apps=100
17
+ max_active_apps=100
18
+
19
+ # PAM - resource limits
20
+ # limits_core
21
+ #<item> can be one of the following:
22
+ # limits_core=unlimited # limits the core file size (KB)
23
+ # limits_data=unlimited # max data size (KB)
24
+ # limits_fsize=unlimited # maximum filesize (KB)
25
+ # limits_memlock=unlimited # max locked-in-memory address space (KB)
26
+ # limits_nofile=unlimited # max number of open files
27
+ # limits_rss=unlimited # max resident set size (KB)
28
+ # limits_stack=unlimited # max stack size (KB)
29
+ # limits_cpu=unlimited # max CPU time (MIN)
30
+ limits_nproc=250 # max number of processes
31
+ # limits_as=unlimited # address space limit (KB)
32
+ # limits_maxlogins=unlimited # max number of logins for this user
33
+ # limits_maxsyslogins=unlimited # max number of logins on the system
34
+ # limits_priority=unlimited # the priority to run user process with
35
+ # limits_locks=unlimited # max number of file locks the user can hold
36
+ # limits_sigpending=unlimited # max number of pending signals
37
+ # limits_msgqueue=unlimited # max memory used by POSIX message queues (bytes)
38
+ # limits_nice=19 # max nice priority allowed to raise to values: [-20, 19]
39
+ # limits_rtprio=19 # max realtime priority
40
+
41
+ #
42
+ # cgroups - more resource limits
43
+ #
44
+ #
45
+ # cpu
46
+ # cpu_rt_period_us=100000
47
+ # cpu_rt_runtime_us=950000
48
+ cpu_shares=128
49
+ cpu_cfs_quota_us=30000
50
+ #
51
+ # memory
52
+ # 1024 * 1024 * 512 = 536870912 = 512MB
53
+ memory_limit_in_bytes=536870912
54
+ memory_memsw_limit_in_bytes=641728512 # 512M + 100M (100M swap)
55
+ # memory_soft_limit_in_bytes=-1
56
+ # memory_swappiness=60
57
+
58
+ #
59
+ # Apache bandwidth limit
60
+ #
61
+ apache_bandwidth="all 500000"
62
+ apache_maxconnection="all 20"
63
+ apache_bandwidtherror="510"
64
+ #
65
+ # Apache rotatelogs tuning
66
+ rotatelogs_interval=86400
67
+ rotatelogs_format="-%Y%m%d-%H%M%S-%Z"