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 chargeback for container Images with rate assigning by docker label #12851

Merged
merged 10 commits into from
Dec 6, 2016

Conversation

zeari
Copy link

@zeari zeari commented Nov 24, 2016

This includes work on persisting openshift container images as well as fixes to ContainerImageChargeback reports

screenshot from 2016-11-24 23-53-58

Fix for image names under filter:
screencapture-localhost-3000-report-explorer-1481051637304

@simon3z @enoodle
@miq-bot add_label providers/containers, chargeback, wip

@miq-bot
Copy link
Member

miq-bot commented Nov 27, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

:docker_labels => parse_identifying_attributes(docker_metadata[:Config][:Labels],
'docker_labels', "openshift"),
:docker_labels => docker_labels,
:tags => map_labels('ContainerImage', labels + docker_labels)
Copy link
Author

Choose a reason for hiding this comment

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

Allow mapping of both kubernetes labels and docker labels to tags
@simon3z

Copy link
Contributor

Choose a reason for hiding this comment

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

@zeari you can't merge labels and docker_labels... what if they have the same key but different values? Which one should win? You should keep them separate.

Copy link
Author

Choose a reason for hiding this comment

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

@simon3z Im only merging them when sending them to be mapped into tags. This would allow users to turn docker labels into tags for ContainerImages. I think its unlikely that someone would set a rule on something that would be common for both docker-labels and kubernetes labels.
@cben What would happen in the above case which they have the same key but different values?

Copy link
Contributor

Choose a reason for hiding this comment

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

@simon3z Im only merging them when sending them to be mapped into tags.

@zeari it's not about how many times or where. If you do it even once you still have to answer the questions above (what if they have the same key but different values? Which one should win? why?).

Is this used by the Chargeback for Images? (IIRC we were basing it on labels)

Let's remove everything that could cause issues and that it's not vital for the use-cases we identified.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ooh, docker labels, shiny :)

[First, are these concatenable? Is docker_labels array of {:name, :value} hashes?]
I think the mapping code would map both. With same name and 2 values, you might get 2 tags.
Is that what we want? The Right Thing is probably a new mapping column, letting user define independent mappings for k8s labels vs docker labels (and maybe open it to other kinds of custom attrs). Though I'm not excited about making auto-tagging more complicated :-\

Are you also adding docker labels as new virtual custom-attr columns in reports?
There, would you merge a k8s label & docker label of same name into one "column"?
We probably should be consistent between direct label querying / mapped tag querying.

Are you covering docker labels only on images?
https://docs.docker.com/engine/userguide/labels-custom-metadata/ lists several entities.
P.S. This PR does way too much, but you knew that :)

Copy link
Author

Choose a reason for hiding this comment

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

[First, are these concatenable? Is docker_labels array of {:name, :value} hashes?]
I think the mapping code would map both. With same name and 2 values, you might get 2 tags.

We could filter the list...

Is that what we want? The Right Thing is probably a new mapping column, letting user define independent mappings for k8s labels vs docker labels (and maybe open it to other kinds of custom attrs). Though I'm not excited about making auto-tagging more complicated :-\

I feel doing this is a whole lot easier than adding label rate assignment code which is turning out as a lot but I may be wrong. Besides, tags are much more integrated into various miq features so this will solve multiple use case scenarios

Are you covering docker labels only on images?

yes

Copy link
Contributor

Choose a reason for hiding this comment

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

Mitigating note: docker labels recommend com.domain.reversed.label format — if followed, collisions with k8s labels should be rare.

I think the mapping code would map both.

Correction: UI creates categories with single_value=true, so this either won't work, or will be "inconsistent" in DB. Can fix, but let's understand behavior first.

I feel doing this is a whole lot easier than adding label rate assignment code which is turning out as a lot but I may be wrong. Besides, tags are much more integrated into various miq features so this will solve multiple use case scenarios

Fair enough. 👍 to smaller euwe changes and 👍 to less chargeback-special code.
Do we have a longer-term plan?

  • UX: will we show k8s labels / docker labels together as just "labels", or will we separate them?
  • Will we want independent k8s labels / docker labels mappings?
    I'm concerned that if we allow ambiguous "either one" mappings now, and want to separate later, a later migration won't be able to know which was meant.
    In any case, we can't do schema changes in euwe.
  • Will we eventually have direct MiqExpression (virtual column) support for docker labels? Will they show merged with k8s labels or separate?
  • Will chargeback rate assignment eventually support [any kind of] labels?
    Is there any hope rate assigment will become MiqExpression based to stop playing catch-up?

[aside: Chargeback is not just technical & feature debt, it's a continuous attractor of new debt :-(. IMHO we must allocate more time to gradually make it more based on the core infrastructure...]

@enoodle
Copy link

enoodle commented Nov 28, 2016

@zeari, @simon3z If this PR replaces #12711 then we should add blocker, bug and euwe/yes labels here too.

@miq-bot
Copy link
Member

miq-bot commented Nov 29, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@simon3z
Copy link
Contributor

simon3z commented Dec 1, 2016

Will we want independent k8s labels / docker labels mappings?

@cben @zeari yes

@zeari zeari force-pushed the combined_cb_images branch 6 times, most recently from a68f505 to a2aac99 Compare December 5, 2016 13:32
@zeari
Copy link
Author

zeari commented Dec 5, 2016

@gtanzillo @lpichler Adding tests, please review.
cc @simon3z

@zeari zeari changed the title [WIP] Fix chargeback for container Images with rate assigning by docker label Fix chargeback for container Images with rate assigning by docker label Dec 5, 2016
@zeari
Copy link
Author

zeari commented Dec 5, 2016

@miq-bot remove_label wip

@miq-bot miq-bot removed the wip label Dec 5, 2016
@zeari zeari force-pushed the combined_cb_images branch 2 times, most recently from dac3f66 to ac28c4c Compare December 5, 2016 14:06
@lpichler
Copy link
Contributor

lpichler commented Dec 6, 2016

screen shot 2016-12-06 at 18 06 50
@zeari
What is archived ? Is this expected output ?

@zeari
Copy link
Author

zeari commented Dec 6, 2016

What is archived ? Is this expected output ?

Yes or No depending on if this project was deleted or not - We save old entities\metrics for chargeback.

@zeari
Copy link
Author

zeari commented Dec 6, 2016

What is archived ? Is this expected output ?

Fixed

@zeari
Copy link
Author

zeari commented Dec 6, 2016

@miq-bot add_label euwe/yes

@simon3z
Copy link
Contributor

simon3z commented Dec 6, 2016

@enoodle please review this as well (it contains some of your PRs and we want to make sure they're integrated properly)

@miq-bot
Copy link
Member

miq-bot commented Dec 6, 2016

Checked commits zeari/manageiq@43d581e~...f42f061 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
25 files checked, 20 offenses detected

app/controllers/chargeback_controller.rb

app/helpers/container_image_helper/textual_summary.rb

app/helpers/ui_constants.rb

app/models/chargeback.rb

app/models/chargeback/rates_cache.rb

app/models/container_image.rb

app/models/manageiq/providers/openshift/container_manager/refresh_parser.rb

  • ❕ - Line 174, Col 7 - Metrics/AbcSize - Assignment Branch Condition size for parse_openshift_image is too high. [29.63/20]

app/models/metric/chargeback_helper.rb

app/models/mixins/assignment_mixin.rb

app/services/container_dashboard_service.rb

app/views/report/_form_filter_chargeback.html.haml

  • ⚠️ - Line 96 - Line is too long. [182/160]

spec/models/chargeback_container_image_spec.rb

spec/models/manageiq/providers/openshift/container_manager/refresher_spec.rb

  • ❕ - Line 203, Col 3 - Metrics/AbcSize - Assignment Branch Condition size for assert_specific_container_image is too high. [20.02/20]

@h-kataria
Copy link
Contributor

UI changes look good.

@zeari
Copy link
Author

zeari commented Dec 8, 2016

@gtanzillo @lpichler I cant chery pick this into euwe without conflicts and Im having a hard time mapping out the PR's this depends on. is it ok to have euwe specific commits?( #13030)

@gtanzillo
Copy link
Member

@zeari Yes, that's the way to go what it becomes too difficult to cherry-pick.

@chessbyte
Copy link
Member

Backported to Euwe via #13030

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.

None yet

10 participants