Skip to content

Commit

Permalink
Add job_timeout parameter for upgrade_cluster
Browse files Browse the repository at this point in the history
The motivation here is that we need the job to have one timeout, and the
Ansible role to have another - the job will end if the timeout from the
time it was created will pass, while Ansible playbook will only timeout if it is
stack for too long on one phase. So we will want to set the job timeout
to something huge - 1 year, and set a real timeout through the playbook
extra_vars.

This is part of implementing: https://bugzilla.redhat.com/show_bug.cgi?id=1644605
  • Loading branch information
Boris Odnopozov committed Nov 22, 2018
1 parent 0598dc1 commit e1965d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/models/ems_cluster/cluster_upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ module EmsCluster::ClusterUpgrade
end
end

def upgrade_cluster(options = {})
def upgrade_cluster(ansible_extra_vars = {}, job_timeout = 1.year)
role_options = {:role_name => "oVirt.cluster-upgrade"}
job = ManageIQ::Providers::Redhat::AnsibleRoleWorkflow.create_job({}, extra_vars_for_upgrade(options), role_options)
job = ManageIQ::Providers::Redhat::AnsibleRoleWorkflow.create_job({}, extra_vars_for_upgrade(ansible_extra_vars), role_options, :timeout => job_timeout)
job.signal(:start)
job.miq_task
end
Expand Down
5 changes: 3 additions & 2 deletions spec/models/ems_cluster_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,9 @@
:cluster_name => @cluster.name,
:hostname => "localhost",
:ca_string => @ems.default_endpoint.certificate_authority}
role_arg = {:role_name=>"oVirt.cluster-upgrade"}
expect(ManageIQ::Providers::AnsibleRoleWorkflow).to receive(:create_job).with(env_vars, extra_args, role_arg).and_call_original
role_arg = { :role_name => "oVirt.cluster-upgrade" }
timeout = { :timeout => 1.year }
expect(ManageIQ::Providers::AnsibleRoleWorkflow).to receive(:create_job).with(env_vars, extra_args, role_arg, timeout).and_call_original
@cluster.upgrade_cluster
end

Expand Down

0 comments on commit e1965d6

Please sign in to comment.