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

unify container and container definition #42

Merged
merged 1 commit into from
Jul 26, 2017

Conversation

zeari
Copy link

@zeari zeari commented Jun 19, 2017

@simon3z
Copy link
Contributor

simon3z commented Jun 22, 2017

@moolitayer @cben can you review?
cc @agrare @Ladas

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.

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)
Copy link
Contributor

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|
Copy link
Contributor

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))
Copy link
Contributor

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.

Copy link
Contributor

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 (?)

Copy link
Author

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

Copy link
Contributor

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?

@cben
Copy link
Contributor

cben commented Jun 25, 2017

Graph saving would also need updating, I'll help with that if you'll want to do it in this PR, or I could do it in later PR. (graph refresh specs are currently broken anyway, marked pending)

@zeari
Copy link
Author

zeari commented Jul 2, 2017

Graph saving would also need updating, I'll help with that if you'll want to do it in this PR, or I could do it in later PR. (graph refresh specs are currently broken anyway, marked pending)

gladly, the less PRs the better.

@miq-bot
Copy link
Member

miq-bot commented Jul 3, 2017

This pull request is not mergeable. Please rebase and repush.

@Ladas
Copy link
Contributor

Ladas commented Jul 3, 2017

👍 for simplifying of the model :-)

@simon3z
Copy link
Contributor

simon3z commented Jul 8, 2017

@zeari if you rebase this I think we're ready to move forward with all this series (schema, ui, core and kubernetes provider).

@zeari zeari force-pushed the unify_container_definition branch 4 times, most recently from 1ce53ea to 59c1ed4 Compare July 10, 2017 13:59
@simon3z simon3z closed this Jul 11, 2017
@simon3z simon3z reopened this Jul 11, 2017
@cben
Copy link
Contributor

cben commented Jul 19, 2017

@zeari do tests pass locally given the dependencies?
I suppose the graph refresh test doesn't, you need to merge get_container_definitions_graph into get_containers_graph, I'm happy to help.

@zeari zeari force-pushed the unify_container_definition branch from 59c1ed4 to 87e5405 Compare July 20, 2017 12:49
@miq-bot
Copy link
Member

miq-bot commented Jul 20, 2017

This pull request is not mergeable. Please rebase and repush.

@zeari zeari force-pushed the unify_container_definition branch from 87e5405 to 6046160 Compare July 20, 2017 13:04
@zeari zeari force-pushed the unify_container_definition branch from 6046160 to 4206496 Compare July 20, 2017 13:20
@zeari
Copy link
Author

zeari commented Jul 20, 2017

@zeari do tests pass locally given the dependencies?
I suppose the graph refresh test doesn't, you need to merge get_container_definitions_graph into get_containers_graph, I'm happy to help.

@cben should be good now.

@@ -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)
Copy link
Contributor

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

@zeari zeari force-pushed the unify_container_definition branch from 4206496 to 726ace3 Compare July 20, 2017 14:11
@zeari
Copy link
Author

zeari commented Jul 20, 2017

oh, can you rename container_def -> container_spec arg

Roger Roger

@miq-bot
Copy link
Member

miq-bot commented Jul 21, 2017

This pull request is not mergeable. Please rebase and repush.

@zeari zeari force-pushed the unify_container_definition branch from 726ace3 to b1bacea Compare July 24, 2017 08:54
@miq-bot
Copy link
Member

miq-bot commented Jul 24, 2017

Checked commit zeari@b1bacea with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 1 offense detected

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

  • ⚠️ - Line 1042, Col 43 - Lint/UnusedMethodArgument - Unused method argument - pod_id. If it's necessary, use _ or _pod_id as an argument name to indicate that it won't be used.

@cben
Copy link
Contributor

cben commented Jul 26, 2017

@moolitayer Migrations & core have landed, we need this.
@zeari (or anyone) can you kick Travis?

@zeari zeari closed this Jul 26, 2017
@zeari zeari reopened this Jul 26, 2017
@cben
Copy link
Contributor

cben commented Jul 26, 2017

Still red but now less red.
@moolitayer I propose we merge this because PG::UndefinedTable: ERROR: relation \"container_definitions\" does not exist is really bad, while with this PR I'm able to run refresh...

I'm looking into the VCR unused HTTP interactions, will try to send PR.

cben added a commit to cben/manageiq-providers-kubernetes that referenced this pull request Jul 26, 2017
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.
@Fryguy Fryguy closed this Jul 26, 2017
@Fryguy Fryguy reopened this Jul 26, 2017
@Fryguy
Copy link
Member

Fryguy commented Jul 26, 2017

Rekicking this PR after merging #76

@cben
Copy link
Contributor

cben commented Jul 26, 2017

Green 🎉

@Fryguy Fryguy merged commit 00df730 into ManageIQ:master Jul 26, 2017
@Fryguy Fryguy added this to the Sprint 66 Ending Aug 7, 2017 milestone Jul 26, 2017
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.

6 participants