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

API Chunking Support #312

Merged
merged 8 commits into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,18 @@ def parse_targeted_inventory(ems, target, inventory)

def fetch_entities(client, entities)
entities.each_with_object({}) do |entity, h|
continue = nil
h[entity[:name].singularize] ||= []

begin
h[entity[:name].singularize] = client.send("get_#{entity[:name]}")
loop do
entities = client.send("get_#{entity[:name]}", :limit => refresher_options.chunk_size, :continue => continue)

h[entity[:name].singularize].concat(entities)
break if entities.last?

continue = entities.continue
end
rescue KubeException => e
raise e if entity[:default].nil?
$log.warn("Unexpected Exception during refresh: #{e}")
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
:kubernetes:
:refresh_interval: 15.minutes
:streaming_refresh: false
:chunk_size: 1_000
cben marked this conversation as resolved.
Show resolved Hide resolved
:inventory_object_refresh: true
:inventory_collections:
:saver_strategy: batch
Expand Down
2 changes: 1 addition & 1 deletion manageiq-providers-kubernetes.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Gem::Specification.new do |s|

s.add_runtime_dependency("hawkular-client", "~> 4.1")
s.add_runtime_dependency("image-inspector-client", "~> 2.0")
s.add_runtime_dependency("kubeclient", "~> 4.0")
s.add_runtime_dependency("kubeclient", "~> 4.1.1")
cben marked this conversation as resolved.
Show resolved Hide resolved
s.add_runtime_dependency("prometheus-alert-buffer-client", "~> 0.2.0")
s.add_runtime_dependency("prometheus-api-client", "~> 0.6")
s.add_runtime_dependency("more_core_extensions", "~> 3.6")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

describe ManageIQ::Providers::Kubernetes::ContainerManager::RefresherMixin do
let(:client) { double("client") }
let(:dummy) { (Class.new { include ManageIQ::Providers::Kubernetes::ContainerManager::RefresherMixin }).new }
cben marked this conversation as resolved.
Show resolved Hide resolved
let(:ems) { FactoryBot.create(:ems_kubernetes) }
let(:dummy) { ManageIQ::Providers::Kubernetes::ContainerManager::Refresher.new([ems]) }

context 'when an exception is thrown' do
before { allow(client).to receive(:get_pods) { raise KubeException.new(0, 'oh-no', nil) } }
Expand Down