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

Fix started_at/finished_at always being nil #496

Merged

Conversation

agrare
Copy link
Member

@agrare agrare commented Jun 23, 2023

The state_info had symbol keys like :startedAt and :finishedAt and we were looking for string keys like "startedAt" and "finishedAt" causing these values to always be nil even if data existed in the API response.

@kbrock
Copy link
Member

kbrock commented Jun 23, 2023

@Fryguy Is it possible to raise the priority of this bugfix? Or are we thinking the deleted_on logic is not critical?

@@ -114,7 +114,7 @@ def assert_specific_container
@container.last_started_at,
@container.last_finished_at,
].each do |date_|
expect(date_.kind_of?(ActiveSupport::TimeWithZone) || date_.kind_of?(NilClass)).to be_truthy
expect(date_.kind_of?(ActiveSupport::TimeWithZone))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this change intentional? This expectation is no longer expecting anything?

Suggested change
expect(date_.kind_of?(ActiveSupport::TimeWithZone))
expect(date_.kind_of?(ActiveSupport::TimeWithZone)).to be

or

Suggested change
expect(date_.kind_of?(ActiveSupport::TimeWithZone))
expect(date_.kind_of?(ActiveSupport::TimeWithZone)).to be_truthy

Copy link
Member Author

@agrare agrare Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually just going to drop the whole loop since expect time or nil is what hid this bug in the first place

In this VCR @container has started_at, last_started_at and last_finished_at set wit finished_at being nil so we can just check those directly

@@ -853,10 +853,10 @@ 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
(state, state_info), = state_hash.to_h.deep_symbolize_keys.to_a
res[:state] = state
%w(reason started_at finished_at exit_code signal message).each do |attr|
Copy link
Member

@Fryguy Fryguy Jun 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe not for this PR, but we can pre-symbolize everything and not need to the .to_sym nor camelize calls calls - Something like:

Suggested change
%w(reason started_at finished_at exit_code signal message).each do |attr|
%i(reason reason started_at startedAt finished_at finishedAt exit_code exitCode signal signal message message).each_slice(2) do |attr, state_info_attr|

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, instead of each_slice, just using a hash is easier for me to read. But both work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Fryguy
Copy link
Member

Fryguy commented Jun 23, 2023

@kbrock we'll backport to petrosian as part of the set, yes. Even so, we'll need to deal with existing records anyway.

@agrare agrare force-pushed the fix_started_at_finished_at_timestamps branch from f1fcc7a to 0d96172 Compare June 23, 2023 21:37
@agrare agrare force-pushed the fix_started_at_finished_at_timestamps branch from 0d96172 to 731d077 Compare July 11, 2023 16:11
The `state_info` had symbol keys like `:startedAt` and `:finishedAt` and
we were looking for string keys like `"startedAt"` and `"finishedAt"`
causing these values to always be `nil` even if data existed in the API
response.
@agrare agrare force-pushed the fix_started_at_finished_at_timestamps branch from 731d077 to 634e763 Compare July 11, 2023 16:19
@miq-bot
Copy link
Member

miq-bot commented Jul 11, 2023

Checked commit agrare@634e763 with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint
2 files checked, 0 offenses detected
Everything looks fine. 🏆

@kbrock
Copy link
Member

kbrock commented Jul 14, 2023

Rebase please. I think kubernetes HEAD fixes this issue

@agrare agrare closed this Jul 14, 2023
@agrare agrare reopened this Jul 14, 2023
@kbrock kbrock assigned kbrock and unassigned Fryguy Jul 14, 2023
@kbrock kbrock merged commit 1c753fe into ManageIQ:master Jul 14, 2023
3 of 5 checks passed
@agrare agrare deleted the fix_started_at_finished_at_timestamps branch July 14, 2023 20:13
@Fryguy
Copy link
Member

Fryguy commented Jul 25, 2023

Backported to petrosian in commit 7793ce0.

commit 7793ce09194180ee171d172d73f9de22c95afdbb
Author: Keenan Brock <keenan@thebrocks.net>
Date:   Fri Jul 14 16:09:47 2023 -0400

    Merge pull request #496 from agrare/fix_started_at_finished_at_timestamps
    
    Fix started_at/finished_at always being nil
    
    (cherry picked from commit 1c753fe979d1ecec638b211d88f9ff7af8d8ed92)

Fryguy pushed a commit that referenced this pull request Jul 25, 2023
…amps

Fix started_at/finished_at always being nil

(cherry picked from commit 1c753fe)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants