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

odo config volumes do not have owner references #2693

Closed
maysunfaisal opened this issue Mar 9, 2020 · 8 comments
Closed

odo config volumes do not have owner references #2693

maysunfaisal opened this issue Mar 9, 2020 · 8 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@maysunfaisal
Copy link
Contributor

maysunfaisal commented Mar 9, 2020

/kind bug

What versions of software are you using?

Operating System: MacOS

Output of odo version:

maysuns-mbp:spring-devfile maysun$ ./odo version
odo v1.1.0 (c64e84bde)

Server: <cluster ip>
OpenShift: v3.11.0+e5dbec2-186
Kubernetes: v1.11.0+d4cacc0

How did you run odo exactly?

odo create, add storage to .odo/config.yaml and odo push

Actual behavior

Noticed this when working on #2472

When i delete the deployment config, the volumes/pvc defined in config.yaml are not deleted

Expected behavior

When you delete the deployment config, the volumes/pvc defined in config.yaml should be deleted

Any logs, error output, etc?

printed pvc after owner refs were added in https://github.com/openshift/odo/blob/master/pkg/occlient/volumes.go#L187

I0306 00:41:00.456342    5682 volumes.go:205] mjf after latestPVC &PersistentVolumeClaim{ObjectMeta:k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta{Name:maysunvol-app-pvc,GenerateName:,Namespace:myproject,SelfLink:/api/v1/namespaces/myproject/persistentvolumeclaims/maysunvol-app-pvc,UID:93191f6b-5f5a-11ea-9264-664b76d93af3,ResourceVersion:39735,Generation:0,CreationTimestamp:2020-03-05 22:28:40 -0500 EST,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{app: app,app.kubernetes.io/instance: nodejs-nodejs-ex-xwcu,app.kubernetes.io/managed-by: odo,app.kubernetes.io/managed-by-version: v1.1.0,app.kubernetes.io/part-of: app,app.kubernetes.io/storage-name: maysunvol,},Annotations:map[string]string{pv.kubernetes.io/bind-completed: yes,pv.kubernetes.io/bound-by-controller: yes,},OwnerReferences:[],Finalizers:[kubernetes.io/pvc-protection],ClusterName:,Initializers:nil,},Spec:PersistentVolumeClaimSpec{AccessModes:[ReadWriteOnce],Resources:ResourceRequirements{Limits:ResourceList{},Requests:ResourceList{storage: {{1073741824 0} {<nil>} 1Gi BinarySI},},},VolumeName:pv0042,Selector:nil,StorageClassName:nil,VolumeMode:nil,DataSource:nil,},Status:PersistentVolumeClaimStatus{Phase:Bound,AccessModes:[ReadWriteOnce ReadWriteMany ReadOnlyMany],Capacity:ResourceList{storage: {{107374182400 0} {<nil>} 100Gi BinarySI},},Conditions:[],},}
I0306 00:41:00.456587    5682 volumes.go:206] mjf after &latestPVC 0xc0000cd0e8
 ✓  Creating component [487ms]

oc get po,dc,pvc

NAME                                    READY   STATUS    RESTARTS   AGE
pod/nodejs-nodejs-ex-xwcu-app-1-6l9m4   1/1     Running   0          5m

NAME                                                           REVISION   DESIRED   CURRENT   TRIGGERED BY
deploymentconfig.apps.openshift.io/nodejs-nodejs-ex-xwcu-app   1          1         1         config,image(nodejs:latest)

NAME                                                      STATUS   VOLUME   CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/maysunvol-app-pvc                   Bound    pv0042   100Gi      RWO,ROX,RWX                   5m
persistentvolumeclaim/nodejs-nodejs-ex-xwcu-app-s2idata   Bound    pv0012   100Gi      RWO,ROX,RWX                   5m

oc get pvc maysunvol-app-pvc -o yaml

maysuns-mbp:~ maysun$ oc get pvc maysunvol-app-pvc -o yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  annotations:
    pv.kubernetes.io/bind-completed: "yes"
    pv.kubernetes.io/bound-by-controller: "yes"
  creationTimestamp: "2020-03-06T03:28:40Z"
  finalizers:
  - kubernetes.io/pvc-protection
  labels:
    app: app
    app.kubernetes.io/instance: nodejs-nodejs-ex-xwcu
    app.kubernetes.io/managed-by: odo
    app.kubernetes.io/managed-by-version: v1.1.0
    app.kubernetes.io/part-of: app
    app.kubernetes.io/storage-name: maysunvol
  name: maysunvol-app-pvc
  namespace: myproject
  resourceVersion: "39735"
  selfLink: /api/v1/namespaces/myproject/persistentvolumeclaims/maysunvol-app-pvc
  uid: 93191f6b-5f5a-11ea-9264-664b76d93af3
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  volumeName: pv0042
status:
  accessModes:
  - ReadWriteOnce
  - ReadWriteMany
  - ReadOnlyMany
  capacity:
    storage: 100Gi
  phase: Bound
maysuns-mbp:~ maysun$ 

config.yaml

Maysuns-MacBook-Pro:nodejs-ex maysun$ cat .odo/config.yaml 
kind: LocalConfig
apiversion: odo.openshift.io/v1alpha1
ComponentSettings:
  Type: nodejs
  SourceLocation: ./
  SourceType: local
  Ports:
  - 8080/TCP
  Application: app
  Project: myproject
  Name: nodejs-nodejs-ex-xwcu
  Storage:
  - Name: maysunvol
    Size: 1Gi
    Path: /root/maysunpath
@openshift-ci-robot openshift-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 9, 2020
@maysunfaisal
Copy link
Contributor Author

maysunfaisal commented Mar 9, 2020

The issue is in function https://github.com/openshift/odo/blob/master/pkg/occlient/volumes.go#L187

pvc and latestPVC are pointers to different objects of the same PVC. In the above function, the pvc object is being updated but it is not reflected in latestPVC and when we update PVC with the API on latestPVC, the changes are not reflected.

the pvc object in the above function:

I0306 00:41:00.456329    5682 volumes.go:203] mjf &pvc 0xc0000cd0e0

I0306 00:41:00.456204    5682 volumes.go:202] mjf pvc &PersistentVolumeClaim{ObjectMeta:k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta{Name:maysunvol-app-pvc,GenerateName:,Namespace:myproject,SelfLink:/api/v1/namespaces/myproject/persistentvolumeclaims/maysunvol-app-pvc,UID:93191f6b-5f5a-11ea-9264-664b76d93af3,ResourceVersion:39730,Generation:0,CreationTimestamp:2020-03-05 22:28:40 -0500 EST,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{app: app,app.kubernetes.io/instance: nodejs-nodejs-ex-xwcu,app.kubernetes.io/managed-by: odo,app.kubernetes.io/managed-by-version: v1.1.0,app.kubernetes.io/part-of: app,app.kubernetes.io/storage-name: maysunvol,},Annotations:map[string]string{},OwnerReferences:[{apps.openshift.io/v1 DeploymentConfig nodejs-nodejs-ex-xwcu-app 9336e925-5f5a-11ea-ac41-664b76d93af3 <nil> <nil>}],Finalizers:[kubernetes.io/pvc-protection],ClusterName:,Initializers:nil,},Spec:PersistentVolumeClaimSpec{AccessModes:[ReadWriteOnce],Resources:ResourceRequirements{Limits:ResourceList{},Requests:ResourceList{storage: {{1073741824 0} {<nil>} 1Gi BinarySI},},},VolumeName:,Selector:nil,StorageClassName:nil,VolumeMode:nil,DataSource:nil,},Status:PersistentVolumeClaimStatus{Phase:Pending,AccessModes:[],Capacity:ResourceList{},Conditions:[],},}

the latestPVC object in the above function:

I0306 00:41:00.456189    5682 volumes.go:198] mjf before &latestPVC 0xc0000cd0e8

I0306 00:41:00.456342    5682 volumes.go:205] mjf after latestPVC &PersistentVolumeClaim{ObjectMeta:k8s_io_apimachinery_pkg_apis_meta_v1.ObjectMeta{Name:maysunvol-app-pvc,GenerateName:,Namespace:myproject,SelfLink:/api/v1/namespaces/myproject/persistentvolumeclaims/maysunvol-app-pvc,UID:93191f6b-5f5a-11ea-9264-664b76d93af3,ResourceVersion:39735,Generation:0,CreationTimestamp:2020-03-05 22:28:40 -0500 EST,DeletionTimestamp:<nil>,DeletionGracePeriodSeconds:nil,Labels:map[string]string{app: app,app.kubernetes.io/instance: nodejs-nodejs-ex-xwcu,app.kubernetes.io/managed-by: odo,app.kubernetes.io/managed-by-version: v1.1.0,app.kubernetes.io/part-of: app,app.kubernetes.io/storage-name: maysunvol,},Annotations:map[string]string{pv.kubernetes.io/bind-completed: yes,pv.kubernetes.io/bound-by-controller: yes,},OwnerReferences:[],Finalizers:[kubernetes.io/pvc-protection],ClusterName:,Initializers:nil,},Spec:PersistentVolumeClaimSpec{AccessModes:[ReadWriteOnce],Resources:ResourceRequirements{Limits:ResourceList{},Requests:ResourceList{storage: {{1073741824 0} {<nil>} 1Gi BinarySI},},},VolumeName:pv0042,Selector:nil,StorageClassName:nil,VolumeMode:nil,DataSource:nil,},Status:PersistentVolumeClaimStatus{Phase:Bound,AccessModes:[ReadWriteOnce ReadWriteMany ReadOnlyMany],Capacity:ResourceList{storage: {{107374182400 0} {<nil>} 100Gi BinarySI},},Conditions:[],},}

In #2472, we've had to change the flow a bit because of this. We tried to do the same way as non-experimental odo(storage push, generate dc, add volume and mounts to dc, create dc, update pvc with owner reference from dc). But right now, with non experimental mode for devfile, it is:

  • add volumes and mount paths to pod template spec
  • create deployment with pod template spec
  • create pvc spec with owner reference from deployment
  • create pvc

@girishramnani
Copy link
Contributor

This is currently expected behavior as we don't want to delete user defined pvcs when user deletes the component.

@girishramnani
Copy link
Contributor

so this is not a bug

@adisky
Copy link
Contributor

adisky commented Mar 13, 2020

It same as #2710 or the other way :)

@adisky
Copy link
Contributor

adisky commented Mar 13, 2020

if it is expected behavior than odo push after odo delete would fail and we need to handle this in some other way.

@kadel
Copy link
Member

kadel commented Mar 30, 2020

This is currently expected behavior as we don't want to delete user defined pvcs when user deletes the component.

I'm actually starting to incline towards deleting the pvcs. As a user I would expect that it gets deleted when I delete the component.

Originally we were thinking that we wouldn't delete the storage as we had a mechanism to unmount storage from one component and mount it to another one, but that functionality was dropped, so now it actually makes sense to delete pvcs, as they have no use after the component is deleted, and users don't have any mechanism to access that pvc using just odo.

@adisky
Copy link
Contributor

adisky commented Apr 2, 2020

Resolved with this PR #2750
/close

@adisky adisky closed this as completed Apr 2, 2020
@openshift-ci-robot
Copy link
Collaborator

@adisky: Closing this issue.

In response to this:

Resolved with this PR #2750
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

5 participants