Labbs opened a new issue #10292:
URL: https://github.com/apache/airflow/issues/10292
<!--
Welcome to Apache Airflow! For a smooth issue process, try to answer the
following questions.
Don't worry if they're not all applicable; just try to include what you can
:-)
If you need to include code snippets or logs, please put them in fenced code
blocks. If they're super-long, please use the details tag like
<details><summary>super-long log</summary> lots of stuff </details>
Please delete these comment blocks before submitting the issue.
-->
<!--
IMPORTANT!!!
PLEASE CHECK "SIMILAR TO X EXISTING ISSUES" OPTION IF VISIBLE
NEXT TO "SUBMIT NEW ISSUE" BUTTON!!!
PLEASE CHECK IF THIS ISSUE HAS BEEN REPORTED PREVIOUSLY USING SEARCH!!!
Please complete the next sections or the issue will be closed.
This questions are the first thing we need to know to understand the context.
-->
**Apache Airflow version**: 1.10.11
**Kubernetes version (if you are using kubernetes)** (use `kubectl version`):
```
Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.1",
GitCommit:"7879fc12a63337efff607952a323df90cdc7a335", GitTreeState:"clean",
BuildDate:"2020-04-10T21:53:51Z", GoVersion:"go1.14.2", Compiler:"gc",
Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"17+",
GitVersion:"v1.17.6-eks-4e7f64",
GitCommit:"4e7f642f9f4cbb3c39a4fc6ee84fe341a8ade94c", GitTreeState:"clean",
BuildDate:"2020-06-11T13:55:35Z", GoVersion:"go1.13.9", Compiler:"gc",
Platform:"linux/amd64"}
```
**Environment**:
- **Cloud provider or hardware configuration**: AWS
**What happened**:
When I want to retrieve the logs from the GUI, Airflow indicates that it has
not found the pod
```
HTTP response body:
b'{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"pods
\\"examplekubernetesexecutorstarttask-7409bf0f1ed644cfba6c423be769\\" not
found","reason":"NotFound","details":{"name":"examplekubernetesexecutorstarttask-7409bf0f1ed644cfba6c423be769","kind":"pods"},"code":404}\n'
```
After checking in the kubernetes and the database, the hostname is in the
database is not complete.
```
kubectl get po -n airflow-testing | grep
examplekubernetesexecutorstarttask-7409bf0f1ed644cfba6c423be769
examplekubernetesexecutorstarttask-7409bf0f1ed644cfba6c423be769a8c4
0/1 Completed 0 107m
```

It's missing 4 characters in the hostname.
If I update the database with the complete hostname, airflow retrieve the
log without issue
<!-- (please include exact error messages if you can) -->
**What you expected to happen**:
The hostname must be complete in the database so that airflow can retrieve
the logs in kubernetes with the correct pod name.
<!-- What do you think went wrong? -->
**How to reproduce it**:
1- configure airflow for use KubernetesExecutor
```
AIRFLOW__KUBERNETES__DELETE_WORKER_PODS=False
AIRFLOW__CORE__EXECUTOR=KubernetesExecutor
```
2- add dag
```
from airflow import DAG
from airflow.operators.python_operator import PythonOperator
from airflow.utils.dates import days_ago
args = {
"owner": "airflow",
}
def print_stuff():
print("ok")
dag = DAG(
dag_id="example_kubernetes_executor",
default_args=args,
schedule_interval=None,
start_date=days_ago(2),
tags=["example"],
)
start_task = PythonOperator(
dag=dag,
task_id="start_task",
python_callable=print_stuff)
one_task = PythonOperator(
dag=dag,
task_id="one_task",
python_callable=print_stuff,
executor_config={"KubernetesExecutor": {"image":
"apache/airflow:latest"}},
)
start_task >> one_task
```
3- trigger execution
4- get logs from UI
Result:
```
*** Trying to get logs (last 100 lines) from worker pod
examplekubernetesexecutorstarttask-7409bf0f1ed644cfba6c423be769 ***
*** Unable to fetch logs from worker pod
examplekubernetesexecutorstarttask-7409bf0f1ed644cfba6c423be769 ***
(404)
Reason: Not Found
HTTP response headers: HTTPHeaderDict({'Audit-Id':
'28495ca5-86f3-4935-9cef-f825b79cdff6', 'Cache-Control': 'no-cache, private',
'Content-Type': 'application/json', 'Date': 'Tue, 11 Aug 2020 16:27:43 GMT',
'Content-Length': '294'})
HTTP response body:
b'{"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"pods
\\"examplekubernetesexecutorstarttask-7409bf0f1ed644cfba6c423be769\\" not
found","reason":"NotFound","details":{"name":"examplekubernetesexecutorstarttask-7409bf0f1ed644cfba6c423be769","kind":"pods"},"code":404}\n'
```
<!---
As minimally and precisely as possible. Keep in mind we do not have access
to your cluster or dags.
If you are using kubernetes, please attempt to recreate the issue using
minikube or kind.
## Install minikube/kind
- Minikube https://minikube.sigs.k8s.io/docs/start/
- Kind https://kind.sigs.k8s.io/docs/user/quick-start/
If this is a UI bug, please provide a screenshot of the bug or a link to a
youtube video of the bug in action
You can include images using the .md style of

To record a screencast, mac users can use QuickTime and then create an
unlisted youtube video with the resulting .mov file.
--->
**Anything else we need to know**:
The problem is permanent regardless of the dag used.
<!--
How often does this problem occur? Once? Every time etc?
Any relevant logs to include? Put them here in side a detail tag:
<details><summary>x.log</summary> lots of stuff </details>
-->
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]