Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync with stable/3.0 part of the rails app for apply_role improvements #18

Open
wants to merge 16 commits into
base: stable/sap/3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crowbar_framework/app/controllers/barclamp_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,8 @@ def proposal_update
"crowbar-deep-merge-template"
)
)
# See FIXME in ServiceObject.apply_role
message = "" if code == 202

respond_to do |format|
case code
Expand Down Expand Up @@ -623,7 +625,10 @@ def proposal_update
@proposal["attributes"][params[:barclamp]] = JSON.parse(params[:proposal_attributes])
@proposal["deployment"][params[:barclamp]] = JSON.parse(params[:proposal_deployment])
@service_object.save_proposal!(@proposal)
answer = @service_object.proposal_commit(params[:name])
# validation already happened on save
answer = @service_object.proposal_commit(params[:name],
validate: false,
validate_after_save: false)
flash[:alert] = answer[1] if answer[0] >= 400
flash[:notice] = answer[1] if answer[0] >= 300 and answer[0] < 400
flash[:notice] = t("barclamp.proposal_show.commit_proposal_success") if answer[0] == 200
Expand Down
13 changes: 9 additions & 4 deletions crowbar_framework/app/models/crowbar_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ def role_constraints
# Unfortunatelly we need to explicitely look at crowbar-status of the proposal
# because apply_role from this model ignores errors from superclass's apply_role.
def commit_and_check_proposal
answer = proposal_commit("default", false, false)
answer = proposal_commit(
"default",
in_queue: false,
validate: false,
validate_after_save: false
)
# check if error message is saved in one of the nodes
if answer.first != 200
found_errors = []
Expand Down Expand Up @@ -390,7 +395,7 @@ def prepare_nodes_for_crowbar_upgrade
proposal.raw_data["deployment"]["crowbar"]["elements"]["crowbar-upgrade"] = nodes_to_upgrade
proposal.save
# commit the proposal so chef recipe get executed
proposal_commit("default", false, false)
proposal_commit("default", in_queue: false, validate_after_save: false)
end

def disable_non_core_proposals
Expand Down Expand Up @@ -492,7 +497,7 @@ def revert_nodes_from_crowbar_upgrade

# commit current proposal (with the crowbar-upgrade role still assigned to nodes),
# so the recipe is executed when nodes have 'ready' state
proposal_commit("default", false, false)
proposal_commit("default", in_queue: false, validate: false, validate_after_save: false)
# now remove the nodes from upgrade role
proposal["deployment"]["crowbar"]["elements"]["crowbar-upgrade"] = []
proposal.save
Expand Down Expand Up @@ -569,7 +574,7 @@ def apply_role (role, inst, in_queue)
else
unless answer[1].include?(id)
@logger.debug("Crowbar apply_role: #{k}.#{id} wasn't active: Activating")
answer = service.proposal_commit(id, false, false)
answer = service.proposal_commit(id, in_queue: false, validate_after_save: false)
if answer[0] != 200
answer[1] = "Failed to commit proposal '#{id}' for '#{k}' " +
"(The error message was: #{answer[1].strip})"
Expand Down
6 changes: 4 additions & 2 deletions crowbar_framework/app/models/network_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ def allocate_ip_by_type(bc_instance, network, range, object, type, suggestion =

if type == :node
# Save the information.
node.crowbar["crowbar"]["network"][network] = net_info
node.save
if node.crowbar["crowbar"]["network"][network] != net_info
node.crowbar["crowbar"]["network"][network] = net_info
node.save
end
end

@logger.info("Network allocate ip for #{type}: Assigned: #{name} #{network} #{range} #{net_info["address"]}")
Expand Down
Loading