Коммит 8f1114ea создал по автору rpereira2's avatar rpereira2
Просмотр файлов

Include container name in kube pod_logs API call

- When a pod contains more than one container, the container name has
to be included in the pod_logs API call otherwise the Kubernetes API
returns 400.
- Also allow our logs API to take a container_name param which can be
used to choose which container's logs should be returned.
владелец 7f5eea27
......@@ -11,6 +11,10 @@ def kube_pods_response
kube_response(kube_pods_body)
end
def kube_pod_response
kube_response(kube_pod)
end
def kube_logs_response
kube_response(kube_logs_body)
end
......@@ -63,11 +67,30 @@ def stub_kubeclient_pods(namespace, status: nil)
WebMock.stub_request(:get, pods_url).to_return(response || kube_pods_response)
end
def stub_kubeclient_logs(pod_name, namespace, status: nil)
def stub_kubeclient_pod_details(pod, namespace, status: nil)
stub_kubeclient_discover(service.api_url)
logs_url = service.api_url + "/api/v1/namespaces/#{namespace}/pods/#{pod_name}/log?tailLines=#{Clusters::Platforms::Kubernetes::LOGS_LIMIT}"
pod_url = service.api_url + "/api/v1/namespaces/#{namespace}/pods/#{pod}"
response = { status: status } if status
WebMock.stub_request(:get, pod_url).to_return(response || kube_pod_response)
end
def stub_kubeclient_logs(pod_name, namespace, container: nil, status: nil, message: nil)
stub_kubeclient_discover(service.api_url)
if container
container_query_param = "container=#{container}&"
end
logs_url = service.api_url + "/api/v1/namespaces/#{namespace}/pods/#{pod_name}" \
"/log?#{container_query_param}tailLines=#{Clusters::Platforms::Kubernetes::LOGS_LIMIT}"
if status
response = { status: status }
response[:body] = { message: message }.to_json if message
end
WebMock.stub_request(:get, logs_url).to_return(response || kube_logs_response)
end
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать