-
Notifications
You must be signed in to change notification settings - Fork 63
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
unify container and container definition #42
Conversation
@moolitayer @cben can you review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comments, overall LGTM
@@ -333,18 +332,16 @@ def parse_pod(pod) | |||
# TODO, podIP | |||
containers_index = {} | |||
containers = pod.spec.containers | |||
containers.collect do |container_def| | |||
containers_index[container_def.name] = parse_container_definition(container_def, pod.metadata.uid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider renaming
s/parse_container_definition(/parse_container_spec(/
s/parse_container(/parse_container_status(/
👍 on keeping the 2 functions separate, but since they now go to same table, the distinction that makes sense is the names of the input parts.
@@ -333,18 +332,16 @@ def parse_pod(pod) | |||
# TODO, podIP | |||
containers_index = {} | |||
containers = pod.spec.containers | |||
containers.collect do |container_def| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.collect
builds an array (aka .map
), if you don't need it use .each
.
unless pod.status.nil? || pod.status.containerStatuses.nil? | ||
pod.status.containerStatuses.each do |cn| | ||
containers_index[cn.name] = parse_container(cn, pod.metadata.uid) | ||
containers_index[cn.name].merge!(parse_container(cn, pod.metadata.uid)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As dicussed, we can't think of a scenario containers_index[cn.name]
could be nil (status without spec) but let's handle it just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another question: can a container that previously had a status stop having it?
I suspect in such case we'd not clear the fields last parsed from a status, I think save_inventory_multi
only updates the fields you set in the hash (?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can set those as nil, but the question is if we would want to 'delete' the last known status
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question, hard to say without a scenario when this could happen (if at all)...
I think a good rule is that refresh should be "stateless", should converge to final state == what API gives, irrespective of what we saw before.
the exception to this rule is archiving. if you see a benefit to remembering last status seen, then archiving Container separately from ContainerDefinition would be a clean way to do this — a way that disappears after this change merging them.
IMO it's not worth the bother for a hypothetical situation, I'd set them to nil.
BTW, what do we do now? Would a ContainerDefinition's Container get deleted if [hypotetically] status disappears?
Graph saving would also need updating, I'll help with that if you'll want to do it in this PR, |
gladly, the less PRs the better. |
0e1fc3e
to
ae1a2bf
Compare
This pull request is not mergeable. Please rebase and repush. |
👍 for simplifying of the model :-) |
@zeari if you rebase this I think we're ready to move forward with all this series (schema, ui, core and kubernetes provider). |
1ce53ea
to
59c1ed4
Compare
@zeari do tests pass locally given the dependencies? |
59c1ed4
to
87e5405
Compare
This pull request is not mergeable. Please rebase and repush. |
87e5405
to
6046160
Compare
6046160
to
4206496
Compare
@@ -999,7 +991,7 @@ def parse_conditions(entity) | |||
end | |||
end | |||
|
|||
def parse_container_definition(container_def, pod_id) | |||
def parse_container_spec(container_def, pod_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, can you rename container_def -> container_spec arg
4206496
to
726ace3
Compare
Roger Roger |
This pull request is not mergeable. Please rebase and repush. |
726ace3
to
b1bacea
Compare
Checked commit zeari@b1bacea with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb
|
@moolitayer Migrations & core have landed, we need this. |
Still red but now less red. I'm looking into the VCR unused HTTP interactions, will try to send PR. |
The `.find_by` instead of `.first` will make the tested targets stable and matching the VCR even if refresh record order changes. It also happens to fix VCR errors following ManageIQ#42, but not because of order. Without .reload after refresh, ActiveRecord caches were stale, and pod.containers returned same container twice.
Rekicking this PR after merging #76 |
Green 🎉 |
Depends on ManageIQ/manageiq#15393
@enoodle @zakiva Please review
cc @simon3z @moolitayer @cben