openstack-resource-controller icon indicating copy to clipboard operation
openstack-resource-controller copied to clipboard

Images with same name are being adopted even though their specs are different

Open mandre opened this issue 10 months ago • 2 comments

Create these two ORC image objects:

---
apiVersion: openstack.k-orc.cloud/v1alpha1
kind: Image
metadata:
  name: import-error-external-1
spec:
  cloudCredentialsRef:
    cloudName: openstack
    secretName: openstack-clouds
  managementPolicy: managed
  resource:
    name: cirros
    content:
      diskFormat: qcow2
      download:
        url: https://download.cirros-cloud.net/0.6.3/cirros-0.6.3-x86_64-disk.img
---
apiVersion: openstack.k-orc.cloud/v1alpha1
kind: Image
metadata:
  name: import-error-external-2
spec:
  cloudCredentialsRef:
    cloudName: openstack
    secretName: openstack-clouds
  managementPolicy: managed
  resource:
    name: cirros
    content:
      diskFormat: qcow2
      download:
        url: https://download.cirros-cloud.net/0.6.2/cirros-0.6.2-x86_64-disk.img

I expect this to create two separate images in OpenStack, with the same name.

However, there's only one resulting image, with the other resource being imported:

apiVersion: openstack.k-orc.cloud/v1alpha1                                                                                                                                                                                                                                                                                                           
kind: Image                                                                                                                                                                                                                                                                                                                                          
metadata:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
  name: import-error-external-1                                                                                                                                                                                                                                                                                                                      
  uid: cbbe6d18-0c2a-44b3-9b14-1b76d76fe8e6
  [snip]
spec:
  cloudCredentialsRef:
    cloudName: openstack
    secretName: openstack-clouds
  managementPolicy: managed
  resource:
    content:
      containerFormat: bare
      diskFormat: qcow2
      download:
        url: https://download.cirros-cloud.net/0.6.3/cirros-0.6.3-x86_64-disk.img
    name: cirros
status:
  [snip]
  id: e974251f-c838-4778-ad5f-355e94ed7746
  resource:
    hash:
      algorithm: sha512
      value: 9a9bce0083a00939ec17c11febbfc767aa211aaa54f51e75c5a8b271a9b5637c77205a518b7a2007cb391d23cceb01e0e4e8d64832317151bc85b734b92a7be0
    name: cirros
    protected: false
    sizeB: 21692416
    status: active
    virtualSizeB: 117440512
    visibility: shared
---
apiVersion: openstack.k-orc.cloud/v1alpha1
kind: Image
metadata:
  name: import-error-external-2
  uid: acecebfd-feb2-42fc-a24b-ef300e0a8d60
  [snip]
spec:
  cloudCredentialsRef:
    cloudName: openstack
    secretName: openstack-clouds
  managementPolicy: managed
  resource:
    content:
      containerFormat: bare
      diskFormat: qcow2
      download:
        url: https://download.cirros-cloud.net/0.6.2/cirros-0.6.2-x86_64-disk.img
    name: cirros
status:
  [snip]
  id: e974251f-c838-4778-ad5f-355e94ed7746
  resource:
    hash:
      algorithm: sha512
      value: 9a9bce0083a00939ec17c11febbfc767aa211aaa54f51e75c5a8b271a9b5637c77205a518b7a2007cb391d23cceb01e0e4e8d64832317151bc85b734b92a7be0
    name: cirros
    protected: false
    sizeB: 21692416
    status: active
    virtualSizeB: 117440512
    visibility: shared

Logs from the controller:

2025-02-24T08:48:41+01:00       LEVEL(-5)       Observed create {"controller": "server", "watchKind": "*v1alpha1.Image", "name": "import-error-external-1", "namespace": "kuttl-test-solid-anchovy"}                                                                                                                                                 
2025-02-24T08:48:41+01:00       LEVEL(-5)       Reconciling     {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-1","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-1", "reconcileID": "ff836b
ca-fd52-4f7d-b33c-86aec2633bc5"}                                                                                                                                                                                                                                                                                                                     
2025-02-24T08:48:41+01:00       LEVEL(-3)       Reconciling image       {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-1","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-1", "reconcileID":
 "ff836bca-fd52-4f7d-b33c-86aec2633bc5"}                                                                                                                                                                                                                                                                                                             
2025-02-24T08:48:41+01:00       LEVEL(-4)       Adding finalizer        {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-1","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-1", "reconcileID":
 "ff836bca-fd52-4f7d-b33c-86aec2633bc5", "objectName": "openstack-clouds", "objectKind": "Secret"}                                                                                                                                                                                                                                                   
2025-02-24T08:48:41+01:00       LEVEL(-5)       Observed create {"controller": "server", "watchKind": "*v1alpha1.Image", "name": "import-error-external-2", "namespace": "kuttl-test-solid-anchovy"}                                                                                                                                                 
2025-02-24T08:48:41+01:00       LEVEL(-5)       Observed update {"controller": "server", "watchKind": "*v1alpha1.Image", "name": "import-error-external-1", "namespace": "kuttl-test-solid-anchovy"}                                                                                                                                                 
2025-02-24T08:48:42+01:00       LEVEL(-3)       Creating resource       {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-1","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-1", "reconcileID":
 "ff836bca-fd52-4f7d-b33c-86aec2633bc5"}                                                                                                                                                                                                                                                                                                             
2025-02-24T08:48:42+01:00       LEVEL(-4)       Got resource    {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-1","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-1", "reconcileID": "ff836b
ca-fd52-4f7d-b33c-86aec2633bc5", "ID": "e974251f-c838-4778-ad5f-355e94ed7746"}                                                                                                                                                                                                                                                                       
2025-02-24T08:48:42+01:00       LEVEL(-5)       Observed update {"controller": "server", "watchKind": "*v1alpha1.Image", "name": "import-error-external-1", "namespace": "kuttl-test-solid-anchovy"}                                                                                                                                                 
2025-02-24T08:48:42+01:00       LEVEL(-3)       Importing with web-download     {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-1","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-1", "recon
cileID": "ff836bca-fd52-4f7d-b33c-86aec2633bc5", "ID": "e974251f-c838-4778-ad5f-355e94ed7746"}                                                                                                                                                                                                                                                       
2025-02-24T08:48:43+01:00       LEVEL(-4)       Setting image status    {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-1","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-1", "reconcileID":
 "ff836bca-fd52-4f7d-b33c-86aec2633bc5", "ID": "e974251f-c838-4778-ad5f-355e94ed7746", "Available.status": "False", "Available.reason": "Progressing", "Available.message": "Reconciliation is progressing", "Progressing.status": "True", "Progressing.reason": "Progressing", "Progressing.message": "Reconciliation is progressing"}              
2025-02-24T08:48:43+01:00       LEVEL(-5)       Reconcile successful    {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-1","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-1", "reconcileID":
 "ff836bca-fd52-4f7d-b33c-86aec2633bc5"}                                                                                                                                                                                                                                                                                                             
2025-02-24T08:48:43+01:00       LEVEL(-5)       Reconciling     {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-2","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-2", "reconcileID": "45cdc7
ee-3311-406c-8a43-c98bcdedf119"}                                                                                                                                                                                                                                                                                                                     
2025-02-24T08:48:43+01:00       LEVEL(-3)       Reconciling image       {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-2","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-2", "reconcileID":
 "45cdc7ee-3311-406c-8a43-c98bcdedf119"}                                                                                                                                                                                                                                                                                                             
2025-02-24T08:48:43+01:00       LEVEL(-5)       Observed update {"controller": "server", "watchKind": "*v1alpha1.Image", "name": "import-error-external-1", "namespace": "kuttl-test-solid-anchovy"}                                                                                                                                                 
2025-02-24T08:48:43+01:00       LEVEL(-5)       Observed update {"controller": "server", "watchKind": "*v1alpha1.Image", "name": "import-error-external-2", "namespace": "kuttl-test-solid-anchovy"}                                                                                                                                                 
2025-02-24T08:48:43+01:00       LEVEL(-4)       Adopted previously created resource     {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-2","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-2"
, "reconcileID": "45cdc7ee-3311-406c-8a43-c98bcdedf119"}                                                                                                                                                                                                                                                                                             
2025-02-24T08:48:43+01:00       LEVEL(-4)       Got resource    {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-2","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-2", "reconcileID": "45cdc7
ee-3311-406c-8a43-c98bcdedf119", "ID": "e974251f-c838-4778-ad5f-355e94ed7746"}                                                                                                                                                                                                                                                                       
2025-02-24T08:48:43+01:00       LEVEL(-5)       Observed update {"controller": "server", "watchKind": "*v1alpha1.Image", "name": "import-error-external-2", "namespace": "kuttl-test-solid-anchovy"}                                                                                                                                                 
2025-02-24T08:48:43+01:00       LEVEL(-3)       Importing with web-download     {"controller": "image", "controllerGroup": "openstack.k-orc.cloud", "controllerKind": "Image", "Image": {"name":"import-error-external-2","namespace":"kuttl-test-solid-anchovy"}, "namespace": "kuttl-test-solid-anchovy", "name": "import-error-external-2", "recon
cileID": "45cdc7ee-3311-406c-8a43-c98bcdedf119", "ID": "e974251f-c838-4778-ad5f-355e94ed7746"}

mandre avatar Feb 24 '25 08:02 mandre

This is because the image controller only considers the image name in its filter:

https://github.com/k-orc/openstack-resource-controller/blob/a19bd9a/internal/controllers/image/actuator.go#L92-L95

mandre avatar Feb 24 '25 08:02 mandre

The problem, when creating two identical image objects except for the download URL, as shown in the above example, is that we can't filter on this field as the source URL is not saved in the OpenStack image resource.

We could (and should) add additional fields to the import filter, but download URL is not one of them.

mandre avatar Apr 10 '25 10:04 mandre