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

Make sure Container has always the right STI type #177

Conversation

Ladas
Copy link
Contributor

@Ladas Ladas commented Nov 27, 2017

Make sure Container has always the right STI type. Before, the
missing image could cause the STI type is Container, which
made metrics capture fail.

Fixes BZ:
https://bugzilla.redhat.com/show_bug.cgi?id=1517676

Make sure Container has always the right STI type. Before, the
missing image could cause the STI type is Container, which
made metrics capture fail.

Fixes BZ:
https://bugzilla.redhat.com/show_bug.cgi?id=1517676
@Ladas Ladas added the bug label Nov 27, 2017
@miq-bot
Copy link
Member

miq-bot commented Nov 27, 2017

Checked commit Ladas@561dba9 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 🍪

@Ladas
Copy link
Contributor Author

Ladas commented Nov 27, 2017

cc @simon3z

@bazulay
Copy link

bazulay commented Nov 27, 2017

@moolitayer PTAL

Copy link
Contributor

@cben cben left a comment

Choose a reason for hiding this comment

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

great find 👍 🏅

@cben
Copy link
Contributor

cben commented Nov 29, 2017

gaprindashvili/?

@Ladas
Copy link
Contributor Author

Ladas commented Nov 29, 2017

@cben should be g-release, or even more?

@cben
Copy link
Contributor

cben commented Nov 29, 2017

On second thoughts, I think on fine and older, before ContainerDefinition merge into Container, there is no bug.
Yes, container_status is not always present, but then Container record is just not created at all, and no metrics is collected, so no error message. IIUC only very new, not yet running, containers have no status, so not collecting metrics is fine.
@zeari please double-check my thinking.

And on gaprindashvili and master, the BZ symptom is not very severe, if it only happens to very new containers (though inventory may be stale, we might already get some metrics by time we collect).
But in any case having wrong STI type can lead to many weird problems, important to fix!

@moolitayer
Copy link

@Ladas thanks for the fix.
Could you please add a spec that fails before this fix?
(parsing is enough, refresh_parser_spec.rb)

@zeari
Copy link

zeari commented Nov 30, 2017

On second thoughts, I think on fine and older, before ContainerDefinition merge into Container, there is no bug.
Yes, container_status is not always present, but then Container record is just not created at all, and no metrics is collected, so no error message. IIUC only very new, not yet running, containers have no status, so not collecting metrics is fine.
@zeari please double-check my thinking.

I agree, this is a new issue. either way if it does pop up we have @Ladas manual fix in https://bugzilla.redhat.com/show_bug.cgi?id=1517676

@Ladas
Copy link
Contributor Author

Ladas commented Dec 4, 2017

@moolitayer @cben hm, could you guys do that magic with manual editing VCRs? In our VCR data, we do not have Container without image.

@cben
Copy link
Contributor

cben commented Dec 4, 2017 via email

Copy link

@enoodle enoodle left a comment

Choose a reason for hiding this comment

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

Great Catch LGTM!

@moolitayer
Copy link

@Ladas refresh_parser_spec.rb does not use VCR and would be enough, thanks

@Ladas
Copy link
Contributor Author

Ladas commented Dec 8, 2017

@cben not sure if refresh_parser_spec.rb is good for this? I see you use it mainly for 'it will be parsed good'. While in other providers, this is more of refresher_spec makes sure the right STI type is always there. (also in other providers, we are not setting the type in parser, unless there are sub STI types)

@Ladas
Copy link
Contributor Author

Ladas commented Dec 11, 2017

@cben @moolitayer is it ok to just merge this to deal with the blocker BZ? Then @cben would cover this later with his VCR specs? Including this data combination example.

@cben
Copy link
Contributor

cben commented Dec 11, 2017 via email

@moolitayer moolitayer merged commit cc36180 into ManageIQ:master Dec 11, 2017
@moolitayer
Copy link

@Ladas why not add a refresh_parser_spec for the case that went wrong here? we use it as general unit tests related to all things parsing, STI and others. let's reiterate on that if needed

@moolitayer moolitayer added this to the Sprint 75 Ending Dec 11, 2017 milestone Dec 11, 2017
@Ladas
Copy link
Contributor Author

Ladas commented Dec 11, 2017

@moolitayer looking at the refresh_parser_spec, you use that mainly for making sure the data are parsed correctly. For this case it's better to have VCR spec, testing the scenarios with missing and present image of a pod, leading to correct data. At least that is what we do in other providers. :-) Since @cben will be adding those VCR specs, I think we can leave it on that?

@moolitayer
Copy link

@Ladas It would be good to test in VCR specs as an integration test for the complete refresh and in refresh_parser_spec as a unit test - we already check several type attributes in that class.
Since that test is simple enough + fails before the PR and succeeds with it I would feel more confident having the test.

We used to have a requirement at some point to have both types of specs for each new entity.

simaishi pushed a commit that referenced this pull request Dec 11, 2017
…_right_sti_type

Make sure Container has always the right STI type
(cherry picked from commit cc36180)

https://bugzilla.redhat.com/show_bug.cgi?id=1524630
@simaishi
Copy link

Gaprindashvili backport details:

$ git log -1
commit e319f3a7d92ab5f9f5ecc5355c442822a3a692ec
Author: Mooli Tayer <[email protected]>
Date:   Mon Dec 11 17:36:01 2017 +0200

    Merge pull request #177 from Ladas/make_sure_container_has_always_the_right_sti_type
    
    Make sure Container has always the right STI type
    (cherry picked from commit cc3618091bc5027b6ac0fee091555efe059cee86)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1524630

@cben
Copy link
Contributor

cben commented Jan 25, 2018

@Ladas, does this need a data migration?
I just simulated via Container.last.update(type: "Container") and then refresh — it does NOT fix the type column. Neither :batch strategy graph nor classic refresh.
(if I destroy the Container and refresh it re-creates correctly of course)

P.S. found stable way to reproduce missing containerStatuses — a Pending pod — https://bugzilla.redhat.com/show_bug.cgi?id=1524630#c9

@Ladas
Copy link
Contributor Author

Ladas commented Jan 25, 2018

@cben yeah. We do not update :type in refresh, for some reason. At this point, we should document a rails c fix, since it's too late for a migration.

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.

8 participants