@@ -82,6 +82,7 @@ def all_role_names
82
82
ENV [ "DISABLE_MIQ_WORKER_HEARTBEAT" ] ||= options [ :heartbeat ] ? nil : '1'
83
83
84
84
options [ :ems_id ] ||= ENV . fetch ( "EMS_ID" , nil )
85
+ options [ :guid ] ||= SecureRandom . uuid
85
86
86
87
if options [ :roles ] . present?
87
88
MiqServer . my_server . server_role_names += options [ :roles ]
@@ -96,45 +97,21 @@ def all_role_names
96
97
97
98
worker_class . preload_for_worker_role if worker_class . respond_to? ( :preload_for_worker_role )
98
99
unless options [ :dry_run ]
99
- create_options = { :pid => Process . pid }
100
- runner_options = { }
101
-
102
- create_options [ :system_uid ] = options [ :system_uid ] if options [ :system_uid ]
103
-
104
- if options [ :ems_id ]
105
- create_options [ :queue_name ] = "ems_#{ options [ :ems_id ] } "
106
- runner_options [ :ems_id ] = options [ :ems_id ]
107
- end
108
-
109
- update_options = create_options . dup
110
- # If a guid is provided, raise if it's not found, update otherwise
111
- # Because podified needs to create on the first run_single_worker and update after:
112
- # If system_uid is provided, update if found, create if not found.
113
- # TODO: This is really inconsistent and confusing. Why can't GUID follow the same rules?
114
- worker = if options [ :guid ]
115
- worker_class . find_by! ( :guid => options [ :guid ] ) . tap do |wrkr |
116
- wrkr . update ( update_options )
117
- end
118
- elsif options [ :system_uid ] && worker = worker_class . find_by ( :system_uid => options [ :system_uid ] )
119
- worker . update ( update_options )
120
- worker
121
- else
122
- worker_class . create_worker_record ( create_options )
123
- end
100
+ runner_options = { :guid => options [ :guid ] }
101
+ runner_options [ :ems_id ] = options [ :ems_id ] if options [ :ems_id ]
124
102
125
103
begin
126
- runner_options [ :guid ] = worker . guid
127
- $log. info ( "Starting #{ worker . class . name } with runner options #{ runner_options } " )
128
- worker . class ::Runner . new ( runner_options ) . tap ( &:setup_sigterm_trap ) . start
104
+ $log. info ( "Starting #{ worker_class . name } with runner options #{ runner_options } " )
105
+ worker_class ::Runner . new ( runner_options ) . tap ( &:setup_sigterm_trap ) . start
129
106
rescue SystemExit
130
107
raise
131
108
rescue Exception => err
132
- MiqWorker ::Runner . safe_log ( worker , "An unhandled error has occurred: #{ err } \n #{ err . backtrace . join ( "\n " ) } " , :error )
109
+ # MiqWorker::Runner.safe_log(worker, "An unhandled error has occurred: #{err}\n#{err.backtrace.join("\n")}", :error)
133
110
STDERR . puts ( "ERROR: An unhandled error has occurred: #{ err } . See log for details." ) rescue nil
134
111
exit 1
135
112
ensure
136
- FileUtils . rm_f ( worker . heartbeat_file )
137
- $log. info ( "Deleting worker record for #{ worker . class . name } , id #{ worker . id } " )
138
- worker . delete
113
+ # FileUtils.rm_f(worker.heartbeat_file)
114
+ $log. info ( "Deleting worker record for #{ worker_class . name } , GUID #{ options [ :guid ] } " )
115
+ # worker.delete
139
116
end
140
117
end
0 commit comments