Skip to content

Commit

Permalink
Merge pull request #496 from agrare/fix_started_at_finished_at_timest…
Browse files Browse the repository at this point in the history
…amps

Fix started_at/finished_at always being nil

(cherry picked from commit 1c753fe)
  • Loading branch information
kbrock authored and Fryguy committed Jul 25, 2023
1 parent 51d0504 commit 7793ce0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -851,13 +851,16 @@ def parse_container_status(container)

def parse_container_state(state_hash)
return {} if state_hash.to_h.empty?
res = {}

# state_hash key is the state and value are attributes e.g 'running': {...}
(state, state_info), = state_hash.to_h.to_a
res[:state] = state
%w(reason started_at finished_at exit_code signal message).each do |attr|
res[attr.to_sym] = state_info[attr.camelize(:lower)]
(state, state_info), = state_hash.to_h.deep_symbolize_keys.to_a

res = {:state => state}

%i[reason reason started_at startedAt finished_at finishedAt exit_code exitCode signal signal message message].each_slice(2) do |attr, state_info_attr|
res[attr] = state_info[state_info_attr]
end

res
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,10 @@ def assert_specific_container
# :backing_ref => "docker://87cd51044d7175c246fa1fa7699253fc2aecb769021837a966fa71e9dcb54d71"
)

[
@container.started_at,
@container.finished_at,
@container.last_started_at,
@container.last_finished_at,
].each do |date_|
expect(date_.kind_of?(ActiveSupport::TimeWithZone) || date_.kind_of?(NilClass)).to be_truthy
end
expect(@container.started_at).to be_kind_of(ActiveSupport::TimeWithZone)
expect(@container.finished_at).to be_nil
expect(@container.last_started_at).to be_kind_of(ActiveSupport::TimeWithZone)
expect(@container.last_finished_at).to be_kind_of(ActiveSupport::TimeWithZone)

expect(@container.container_image.name).to eq("kubernetes/heapster")
expect(@container.command).to eq("/heapster --source\\=kubernetes:https://kubernetes "\
Expand Down

0 comments on commit 7793ce0

Please sign in to comment.