Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1643191

Summary: statefulset cannot create pods: failed error: Pod "ip-172-31-47-15.us-west-2.compute.internal-0" is invalid: spec.hostname
Product: OpenShift Container Platform Reporter: Hongkai Liu <hongkliu>
Component: kube-controller-managerAssignee: Tomáš Nožička <tnozicka>
Status: CLOSED INSUFFICIENT_DATA QA Contact: Xingxing Xia <xxia>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 3.11.0CC: aos-bugs, hongkliu, jokerman, jstrunk, maszulik, mfojtik, mifiedle, mmccomas
Target Milestone: ---   
Target Release: 3.11.z   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-04 15:01:59 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Hongkai Liu 2018-10-25 17:26:36 UTC
Description of problem:
Not sure if this is the desired hehavior.
Modify the sts name with `ip-172-31-47-15.us-west-2.compute.internal` in the example https://raw.githubusercontent.com/kubernetes/website/master/content/en/examples/application/web/web.yaml
Then pods of sts cannot be created.

Version-Release number of selected component (if applicable):
# yum list installed | grep openshift
atomic-openshift.x86_64         3.11.22-1.git.0.fc93a54.el7

How reproducible:


Steps to Reproduce:
1. oc create -f ccc.yaml
2.
3.

Actual results:
# oc describe sts ip-172-31-47-15.us-west-2.compute.internal
Name:               ip-172-31-47-15.us-west-2.compute.internal
Namespace:          ttt
CreationTimestamp:  Thu, 25 Oct 2018 17:10:28 +0000
Selector:           app=nginx
Labels:             <none>
Annotations:        <none>
Replicas:           2 desired | 0 total
Update Strategy:    RollingUpdate
Pods Status:        0 Running / 0 Waiting / 0 Succeeded / 0 Failed
Pod Template:
  Labels:  app=nginx
  Containers:
   nginx:
    Image:        k8s.gcr.io/nginx-slim:0.8
    Port:         80/TCP
    Host Port:    0/TCP
    Environment:  <none>
    Mounts:
      /usr/share/nginx/html from www (rw)
  Volumes:  <none>
Volume Claims:
  Name:          www
  StorageClass:  
  Labels:        <none>
  Annotations:   <none>
  Capacity:      1Gi
  Access Modes:  [ReadWriteOnce]
Events:
  Type     Reason            Age                From                    Message
  ----     ------            ----               ----                    -------
  Normal   SuccessfulCreate  13m                statefulset-controller  create Claim www-ip-172-31-47-15.us-west-2.compute.internal-0 Pod ip-172-31-47-15.us-west-2.compute.internal-0 in StatefulSet ip-172-31-47-15.us-west-2.compute.internal success
  Warning  FailedCreate      3m (x36 over 13m)  statefulset-controller  create Pod ip-172-31-47-15.us-west-2.compute.internal-0 in StatefulSet ip-172-31-47-15.us-west-2.compute.internal failed error: Pod "ip-172-31-47-15.us-west-2.compute.internal-0" is invalid: spec.hostname: Invalid value: "ip-172-31-47-15.us-west-2.compute.internal-0": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')



Expected results:


Additional info:

=================================================
# cat ccc.yaml 
apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  ports:
  - port: 80
    name: web
  clusterIP: None
  selector:
    app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: ip-172-31-47-15.us-west-2.compute.internal
spec:
  serviceName: "nginx"
  replicas: 2
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: k8s.gcr.io/nginx-slim:0.8
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html
  volumeClaimTemplates:
  - metadata:
      name: www
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 1Gi

Comment 1 Hongkai Liu 2018-10-25 17:37:44 UTC
I also tried with a pod with the same name and it is a valid pod name:
Is there something special for sts name?

# oc get pod
NAME                                           READY     STATUS    RESTARTS   AGE
ip-172-31-47-15.us-west-2.compute.internal-0   1/1       Running   0          35s

# oc get pod ip-172-31-47-15.us-west-2.compute.internal-0 -o yaml
apiVersion: v1
kind: Pod
metadata:
  annotations:
    openshift.io/scc: anyuid
  creationTimestamp: 2018-10-25T17:34:21Z
  labels:
    app: web
  name: ip-172-31-47-15.us-west-2.compute.internal-0
  namespace: ttt
  resourceVersion: "44900"
  selfLink: /api/v1/namespaces/ttt/pods/ip-172-31-47-15.us-west-2.compute.internal-0
  uid: 354295d7-d87c-11e8-844b-026633a2e2b6
spec:
  containers:
  - image: docker.io/nginx
    imagePullPolicy: Always
    name: front-end
    ports:
    - containerPort: 80
      protocol: TCP
    resources: {}
    securityContext:
      capabilities:
        drop:
        - MKNOD
    terminationMessagePath: /dev/termination-log
    terminationMessagePolicy: File
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-4fgww
      readOnly: true
  dnsPolicy: ClusterFirst
  imagePullSecrets:
  - name: default-dockercfg-rrrqt
  nodeName: ip-172-31-59-125.us-west-2.compute.internal
  nodeSelector:
    node-role.kubernetes.io/compute: "true"
  priority: 0
  restartPolicy: Always
  schedulerName: default-scheduler
  securityContext:
    seLinuxOptions:
      level: s0:c21,c5
  serviceAccount: default
  serviceAccountName: default
  terminationGracePeriodSeconds: 30
  volumes:
  - name: default-token-4fgww
    secret:
      defaultMode: 420
      secretName: default-token-4fgww
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: 2018-10-25T17:34:21Z
    status: "True"
    type: Initialized
  - lastProbeTime: null
    lastTransitionTime: 2018-10-25T17:34:30Z
    status: "True"
    type: Ready
  - lastProbeTime: null
    lastTransitionTime: null
    status: "True"
    type: ContainersReady
  - lastProbeTime: null
    lastTransitionTime: 2018-10-25T17:34:21Z
    status: "True"
    type: PodScheduled
  containerStatuses:
  - containerID: docker://c72a553c3a1bf14135ade8c160653663d36fb3f768ae5630e1ae195fb425da6a
    image: docker.io/nginx:latest
    imageID: docker-pullable://docker.io/nginx@sha256:b73f527d86e3461fd652f62cf47e7b375196063bbbd503e853af5be16597cb2e
    lastState: {}
    name: front-end
    ready: true
    restartCount: 0
    state:
      running:
        startedAt: 2018-10-25T17:34:30Z
  hostIP: 172.31.59.125
  phase: Running
  podIP: 172.21.0.10
  qosClass: BestEffort
  startTime: 2018-10-25T17:34:21Z

Comment 2 Xingxing Xia 2018-10-26 06:10:36 UTC
FYI, STS pod uses the name in spec.hostname.
It you name the sts with "abc" and create it, it can create pod abc-0. `oc get pod abc-0 -o yaml`, it shows:
spec
...
  hostname: abc-0

Comment 4 Maciej Szulik 2020-05-04 15:01:59 UTC
This bug hasn't had any activity in quite some time. Maybe the problem got
resolved, was a duplicate of something else, or became less pressing for some
reason - or maybe it's still relevant but just hasn't been looked at yet. As
such, we're closing this bug.

If you have further information on the current state of the bug, please add it
and reopen this bug. The information can be, for example, that the problem
still occurs, that you still want the feature, that more information is needed,
or that the bug is (for whatever reason) no longer relevant.