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

Volumes not mounted for Pre-hook container #4711

Closed
ewolinetz opened this issue Sep 17, 2015 · 13 comments
Closed

Volumes not mounted for Pre-hook container #4711

ewolinetz opened this issue Sep 17, 2015 · 13 comments

Comments

@ewolinetz
Copy link
Contributor

I'm trying to leverage a Recreate Pre-hook and a PV to seed configuration for a container. I see that my seeding script fails because the mounted path for my container, as specified by my template, cannot be found. But the application pod succeeds using the same script (and is able to write to the mounted path). The PVC and PV have status 'bound' when I do a oc get pvc; oc get pv

apiVersion: "v1"
  kind: "DeploymentConfig"
  metadata:
    name: "elasticsearch"
  spec:
    strategy:
      type: Recreate
      recreateParams:
        pre:
          failurePolicy: Abort
          execNewPod:
            command: [ "./run.sh" ]
            containerName: "elasticsearch"
    replicas: 1
    selector:
      provider: "openshift"
      component: "elasticsearch"
    template:
      metadata:
        labels:
          provider: "openshift"
          component: "elasticsearch"
      spec:
        containers:
          -
            env:
            -
              name: "KUBERNETES_TRUST_CERT"
              value: "true"
            -
              name: "SERVICE_DNS"
              value: "es-logging-cluster"
            -
              name: "CLUSTER_NAME"
              value: "elasticsearch"
            image: "openshift/elasticsearch:v1"
            name: "elasticsearch"
            ports:
            -
              containerPort: 9200
              name: "http"
            -
              containerPort: 9300
              name: "transport"
            volumeMounts:
              - name: certs
                mountPath: /etc/elasticsearch/keys
                readOnly: true
              - name: pvc
                mountPath: /elasticsearch
                readOnly: false
        volumes:
          - name: certs
            secret:
              secretName: elasticsearch
          - name: pvc
            persistentVolumeClaim:
              claimName: pvc-001
@sosiouxme
Copy link
Member

https://docs.openshift.org/latest/rest_api/openshift_v1.html#v1-execnewpodhook doesn't indicate any way to specify volumes for the lifecycle pod. If volume definitions are not getting automatically copied from the deploymentconfig pod template, then there should be a way to specify what volumes you do want on the lifecycle pod. Without being able to share the volumes, lifecycle pods seem pretty limited.

@deads2k
Copy link
Contributor

deads2k commented Sep 17, 2015

See #3739.

@ironcladlou
Copy link
Contributor

This is fixed by #4783

@gravis
Copy link

gravis commented Nov 19, 2015

I'm having the same issue with an EmptyDir volume.
The volume doesn't seem to be mounted when the command executes, resulting in a real "EmptyDir" for the pod.
I tried to add the volumes field to the execNewPod with no success.

@ironcladlou
Copy link
Contributor

@gravis which version of origin are you using? There was a bug (fixed in #5664) where the volumes were copied to the hook pods, but not the volumeMounts. Can you dump the YAML for your broken hook pod and your deploymentConfig so we can reconcile differences?

@gravis
Copy link

gravis commented Nov 19, 2015

I'm using openshift 1.0.8, maybe it was fixed in 1.1 only?

Thanks

@ironcladlou
Copy link
Contributor

@gravis I believe #5664 is part of 1.0.8. Can you provide your full deploymentConfig YAML as well as the YAML for the broken hook pod?

@gravis
Copy link

gravis commented Nov 19, 2015

I dont' want to publicly share this, can I leave a private message somewhere to you?

@ironcladlou
Copy link
Contributor

@gravis absolutely; feel free to email me directly using dmace@redhat.com

@gravis
Copy link

gravis commented Nov 19, 2015 via email

@ironcladlou
Copy link
Contributor

@gravis yeah, that's it. EmptyDir isn't reusable across pods. You need to use something backed by shared storage, a persistent volume, etc.

@gravis
Copy link

gravis commented Nov 19, 2015

That's too bad. the EmptyDir fits exactly this need (store and share generated assets). If we replace that with a persistent volume, we will corrupt the files as soon as the replica will have more than 2 pods :(

@gravis
Copy link

gravis commented Nov 19, 2015

I think I understand, os can't exec a pre command, BEFORE the actual pod command.
If the container is created, it's not running, hence we can't exec the pre hook inside.
Makes sense. Probably worth a bit of explanation in the doc :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants