1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-27 14:03:40 +03:00

B #4406: preserve gid and uig when scaling (#4424)

This commit is contained in:
Alejandro Huertas Herrero 2020-03-25 16:21:37 +01:00 committed by GitHub
parent 682aa68fdc
commit f182365c80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 5 deletions

View File

@ -161,7 +161,7 @@ class OneFlowTemplateHelper < OpenNebulaHelper::OneHelper
# @return [Hash] Custom attributes values
def custom_attrs(custom_attrs)
# rubocop:disable Layout/LineLength
return unless custom_attrs
return if custom_attrs.nil? || custom_attrs.empty?
ret = {}
ret['custom_attrs_values'] = OpenNebulaHelper.parse_user_inputs(custom_attrs)

View File

@ -326,6 +326,11 @@ class ServiceLCM
set_cardinality(role, cardinality, force)
if cardinality_diff > 0
# change client to have right ownership
client = @cloud_auth.client("#{service.uname}:#{service.gid}")
service.replace_client(client)
role.scale_way('UP')
rc = deploy_roles(client,
@ -378,7 +383,13 @@ class ServiceLCM
elsif service.can_recover_undeploy?
recover_undeploy(client, service)
elsif service.can_recover_scale?
# change client to have right ownership
client = @cloud_auth.client("#{service.uname}:#{service.gid}")
service.replace_client(client)
recover_scale(client, service)
elsif Service::STATE['COOLDOWN'] == service.state
service.set_state(Service::STATE['RUNNING'])
else
break OpenNebula::Error.new(
'Service cannot be recovered in state: ' \
@ -679,7 +690,7 @@ class ServiceLCM
def catch_up(client)
Log.error LOG_COMP, 'Catching up...'
@srv_pool.info
@srv_pool.info_all
@srv_pool.each do |service|
recover_action(client, service.id) if service.transient_state?

View File

@ -55,6 +55,7 @@ module OpenNebula
DEPLOYING
UNDEPLOYING
SCALING
COOLDOWN
]
FAILED_STATES = %w[
@ -140,6 +141,20 @@ module OpenNebula
@body['ready_status_gate']
end
def uname
self['UNAME']
end
def gid
self['GID'].to_i
end
# Replaces this object's client with a new one
# @param [OpenNebula::Client] owner_client the new client
def replace_client(owner_client)
@client = owner_client
end
# Sets a new state
# @param [Integer] the new state
# @return [true, false] true if the value was changed

View File

@ -72,6 +72,15 @@ module OpenNebula
rc
end
def info_all
osp = OpenNebulaServicePool.new(client)
rc = osp.info_all
@one_pool = osp
rc
end
# rubocop:disable Lint/ToJSON
def to_json
# rubocop:enable Lint/ToJSON

View File

@ -491,14 +491,15 @@ post '/service_template/:id/action' do
VALIDATION_EC)
end
if custom_attrs && !custom_attrs_values
if custom_attrs && !custom_attrs.empty? && !custom_attrs_values
return internal_error('No custom_attrs_values found',
VALIDATION_EC)
end
if custom_attrs &&
custom_attrs_values &&
!(custom_attrs.keys - custom_attrs_values.keys).empty?
!custom_attrs.empty?
custom_attrs_values &&
!(custom_attrs.keys - custom_attrs_values.keys).empty?
return internal_error('Every custom_attrs key must have its ' \
'value defined at custom_attrs_value',
VALIDATION_EC)