Skip to content

Commit

Permalink
Drop Container Component Statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
zakiva committed Sep 27, 2017
1 parent 0a9976a commit 87ec298
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 318 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module ManageIQ::Providers::Kubernetes::ContainerManager::EntitiesMapping
'persistent_volume' => 'PersistentVolume',
'pod' => 'ContainerGroup',
'service' => 'ContainerService',
'component_status' => 'ContainerComponentStatus',
'project' => 'ContainerProject',
'route' => 'ContainerRoute',
'build_config' => 'ContainerBuild',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,17 +242,6 @@ def initialize_inventory_collections
)
initialize_custom_attributes_collections(manager.container_routes, %w(labels))

@collections[:container_component_statuses] =
::ManagerRefresh::InventoryCollection.new(
shared_options.merge(
:model_class => ContainerComponentStatus,
:parent => manager,
:builder_params => {:ems_id => manager.id},
:association => :container_component_statuses,
:manager_ref => [:name],
)
)

@collections[:container_templates] =
::ManagerRefresh::InventoryCollection.new(
:model_class => ContainerTemplate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def ems_inv_to_hashes(inventory, _options = Config::Options.new)
get_pods(inventory)
get_endpoints(inventory)
get_services(inventory)
get_component_statuses(inventory)
EmsRefresh.log_inv_debug_trace(@data, "data:")

# Returning a hash triggers save_inventory_container code path.
Expand Down Expand Up @@ -71,7 +70,6 @@ def ems_inv_populate_collections(inventory, _options)
get_persistent_volumes_graph(inventory)
get_pods_graph(inventory)
get_endpoints_and_services_graph(inventory)
get_component_statuses_graph(inventory)
end

def get_nodes(inventory)
Expand Down Expand Up @@ -209,16 +207,6 @@ def get_limit_ranges(inventory)
end
end

def get_component_statuses(inventory)
key = path_for_entity("component_status")
process_collection(inventory["component_status"], key) do |cs|
parse_component_status(cs)
end
@data[key].each do |cs|
@data_index.store_path(key, :by_name, cs[:name], cs)
end
end

def get_additional_attributes(inventory)
inventory["additional_attributes"] ||= {}
process_collection(inventory["additional_attributes"], :additional_attributes) do |aa|
Expand Down Expand Up @@ -540,15 +528,6 @@ def get_container_service_port_configs_graph(container_service, hashes)
end
end

def get_component_statuses_graph(inv)
collection = @inv_collections[:container_component_statuses]

inv["component_status"].each do |cs|
h = parse_component_status(cs)
collection.build(h)
end
end

# TODO: images & registries still rely on @data_index
def get_container_image_registries_graph
collection = @inv_collections[:container_image_registries]
Expand Down Expand Up @@ -990,26 +969,6 @@ def parse_replication_controllers(container_replicator)
new_result
end

def parse_component_status(container_component_status)
new_result = {}

# At this point components statuses use only one condition.
# In the case of a future change, this will need to be modified accordingly.
component_condition = container_component_status.conditions.first

new_result.merge!(
:name => container_component_status.metadata.name,
:condition => component_condition.type,
:status => component_condition.status,
:message => component_condition.message,
# workaround for handling Kubernetes issue: "nil" string is returned in component status error
# https://github.com/kubernetes/kubernetes/issues/16721
:error => (component_condition.error unless component_condition.error == "nil")
)

new_result
end

def parse_labels(entity)
parse_identifying_attributes(entity.metadata.labels, 'labels')
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ module ContainerManager::RefresherMixin
KUBERNETES_ENTITIES = [
{:name => 'pods'}, {:name => 'services'}, {:name => 'replication_controllers'}, {:name => 'nodes'},
{:name => 'endpoints'}, {:name => 'namespaces'}, {:name => 'resource_quotas'}, {:name => 'limit_ranges'},
{:name => 'persistent_volumes'}, {:name => 'persistent_volume_claims'},
# workaround for: https://github.com/openshift/origin/issues/5865
{:name => 'component_statuses', :default => []}
{:name => 'persistent_volumes'}, {:name => 'persistent_volume_claims'}
]

def fetch_entities(client, entities)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,57 +413,6 @@
end
end

describe "parse_component_statuses" do
example_component_statuses = [
{
:component_status => array_recursive_ostruct(
:metadata => {:name => "example-component-status1"},
:conditions => [
{
:type => "Healthy",
:status => "True",
:message => "{'health': 'true'}"
},
]),
:name => "example-component-status1",
:condition => "Healthy",
:status => "True",
:message => "{'health': 'true'}",
:error => nil
},
{
:component_status => array_recursive_ostruct(
:metadata => {:name => "example-component-status2"},
:conditions => [
{
:type => "Healthy",
:status => "Unknown",
:error => "Get http://127.0.0.1:10251/healthz: dial tcp 127.0.0.1:10251: connection refused"
},
]),
:name => "example-component-status2",
:condition => "Healthy",
:status => "Unknown",
:message => nil,
:error => "Get http://127.0.0.1:10251/healthz: dial tcp 127.0.0.1:10251: connection refused"
}
]

example_component_statuses.each do |ex|
it "tests '#{ex[:name]}'" do
parsed_component_status = parser.send(:parse_component_status, ex[:component_status])

expect(parsed_component_status).to have_attributes(
:name => ex[:name],
:condition => ex[:condition],
:status => ex[:status],
:message => ex[:message],
:error => ex[:error]
)
end
end
end

describe "parse_iec_number" do
it "parse capacity hash correctly" do
hash = {:storage => "10Gi", :foo => "10"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def full_refresh_test
assert_specific_container_quota
assert_specific_container_limit
assert_specific_container_image_and_registry
assert_specific_container_component_status
# Volumes, PVs, and PVCs are tested in _before_deletions VCR.
end
end
Expand All @@ -74,7 +73,6 @@ def assert_table_counts
expect(ContainerLimit.count).to eq(3)
expect(ContainerImage.count).to eq(3)
expect(ContainerImageRegistry.count).to eq(1)
expect(ContainerComponentStatus.count).to eq(3)
expect(PersistentVolume.count).to eq(1)
end

Expand Down Expand Up @@ -371,14 +369,6 @@ def assert_specific_container_image_and_registry
expect(@image.container_nodes.count).to eq(1)
end

def assert_specific_container_component_status
@component_status = ContainerComponentStatus.find_by(:name => "etcd-0")
expect(@component_status).to have_attributes(
:condition => "Healthy",
:status => "True"
)
end

def label_with_name_value(name, value)
an_object_having_attributes(
:section => 'labels', :source => 'kubernetes',
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -403,47 +403,6 @@ http_interactions:
encoding: UTF-8
string: '{"kind":"PersistentVolumeClaimList","apiVersion":"v1","metadata":{"selfLink":"/api/v1/persistentvolumeclaims","resourceVersion":"123394"},"items":[]}

'
http_version:
recorded_at: Wed, 12 Jul 2017 10:27:14 GMT
- request:
method: get
uri: https://capture.context.com:8443/api/v1/componentstatuses
body:
encoding: US-ASCII
string: ''
headers:
Accept:
- "*/*"
Accept-Encoding:
- gzip, deflate
User-Agent:
- rest-client/2.0.2 (linux-gnu x86_64) ruby/2.4.1p111
Authorization:
- Bearer theToken
response:
status:
code: 200
message: OK
headers:
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Wed, 12 Jul 2017 10:27:14 GMT
Content-Length:
- '919'
body:
encoding: UTF-8
string: '{"kind":"ComponentStatusList","apiVersion":"v1","metadata":{"selfLink":"/api/v1/componentstatuses"},"items":[{"metadata":{"name":"controller-manager","selfLink":"/api/v1/componentstatusescontroller-manager","creationTimestamp":null},"conditions":[{"type":"Healthy","status":"False","message":"Get
http://127.0.0.1:10252/healthz: dial tcp 127.0.0.1:10252: getsockopt: connection
refused"}]},{"metadata":{"name":"scheduler","selfLink":"/api/v1/componentstatusesscheduler","creationTimestamp":null},"conditions":[{"type":"Healthy","status":"False","message":"Get
http://127.0.0.1:10251/healthz: dial tcp 127.0.0.1:10251: getsockopt: connection
refused"}]},{"metadata":{"name":"etcd-0","selfLink":"/api/v1/componentstatusesetcd-0","creationTimestamp":null},"conditions":[{"type":"Healthy","status":"False","message":"Get
https://capture.context.com:4001/health: remote error:
tls: bad certificate"}]}]}

'
http_version:
recorded_at: Wed, 12 Jul 2017 10:27:14 GMT
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -401,48 +401,7 @@ http_interactions:
string: '{"kind":"PersistentVolumeClaimList","apiVersion":"v1","metadata":{"selfLink":"/api/v1/persistentvolumeclaims","resourceVersion":"2124022"},"items":[{"metadata":{"name":"my-persistentvolumeclaim-2","namespace":"my-project-2","selfLink":"/api/v1/namespaces/my-project-2/persistentvolumeclaims/my-persistentvolumeclaim-2","uid":"f05028a5-50ed-11e7-9a6c-001a4a162683","resourceVersion":"2123427","creationTimestamp":"2017-06-14T10:40:52Z"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"8Gi"}}},"status":{"phase":"Pending"}},{"metadata":{"name":"metrics-cassandra-1","namespace":"openshift-infra","selfLink":"/api/v1/namespaces/openshift-infra/persistentvolumeclaims/metrics-cassandra-1","uid":"e21379dd-e6f9-11e6-a348-001a4a162683","resourceVersion":"973","creationTimestamp":"2017-01-30T14:39:19Z","labels":{"metrics-infra":"hawkular-cassandra"},"annotations":{"pv.kubernetes.io/bind-completed":"yes","pv.kubernetes.io/bound-by-controller":"yes"}},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"10Gi"}},"volumeName":"metrics-volume"},"status":{"phase":"Bound","accessModes":["ReadWriteOnce"],"capacity":{"storage":"10Gi"}}}]}

'
http_version:
recorded_at: Wed, 14 Jun 2017 10:54:31 GMT
- request:
method: get
uri: https://host.example.com:8443/api/v1/componentstatuses
body:
encoding: US-ASCII
string: ''
headers:
Accept:
- "*/*"
Accept-Encoding:
- gzip, deflate
User-Agent:
- rest-client/2.0.2 (linux-gnu x86_64) ruby/2.3.3p222
Authorization:
- Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJtYW5hZ2VtZW50LWluZnJhIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZWNyZXQubmFtZSI6Im1hbmFnZW1lbnQtYWRtaW4tdG9rZW4tOHhlb2siLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC5uYW1lIjoibWFuYWdlbWVudC1hZG1pbiIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjI3Zjc0NTNlLWU2ZjgtMTFlNi1hMzQ4LTAwMWE0YTE2MjY4MyIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDptYW5hZ2VtZW50LWluZnJhOm1hbmFnZW1lbnQtYWRtaW4ifQ.bPi4TnBvEHQ5URSYZ9pfhebq5KLSJBAgJCeQ3I4UATpxwvy-WkF1uy_E_k2nc_GKRIOTzHjxjxBwvwL4KFyyM-By-RQHSb1Uux4qU077n9c67drbaeeYZ3MJVdoxDANqDu96g00YnVxxODx7DSep36dr9mLzWlP_k2NwAyxBV5NukYULdGunCjvWuv7wEyPHmUMRN4xntbhd5EhZThpN93PD6AhzcYy-OV9ZUB41L7bslnZEPU0kpG9oQbvj9hRoKJR7FyRPnHaUqJD7riOXwYjB57vk7lTCaxzsQs1i21dlQvdetu83drMTdV-02V_XuB5zucYPvaCUx7v-PUUy3A
response:
status:
code: 200
message: OK
headers:
Cache-Control:
- no-store
Content-Type:
- application/json
Date:
- Wed, 14 Jun 2017 10:52:57 GMT
Content-Length:
- '915'
body:
encoding: UTF-8
string: '{"kind":"ComponentStatusList","apiVersion":"v1","metadata":{"selfLink":"/api/v1/componentstatuses"},"items":[{"metadata":{"name":"scheduler","selfLink":"/api/v1/componentstatuses/scheduler","creationTimestamp":null},"conditions":[{"type":"Healthy","status":"False","message":"Get
http://127.0.0.1:10251/healthz: dial tcp 127.0.0.1:10251: getsockopt: connection
refused"}]},{"metadata":{"name":"controller-manager","selfLink":"/api/v1/componentstatuses/controller-manager","creationTimestamp":null},"conditions":[{"type":"Healthy","status":"False","message":"Get
http://127.0.0.1:10252/healthz: dial tcp 127.0.0.1:10252: getsockopt: connection
refused"}]},{"metadata":{"name":"etcd-0","selfLink":"/api/v1/componentstatuses/etcd-0","creationTimestamp":null},"conditions":[{"type":"Healthy","status":"False","message":"Get
https://host.example.com:4001/health: remote error: tls: bad
certificate"}]}]}

'
http_version:
http_version:
recorded_at: Wed, 14 Jun 2017 10:54:31 GMT
- request:
method: get
Expand Down
Loading

0 comments on commit 87ec298

Please sign in to comment.