change ownership of the image provided by a filesystem PVC to qemu
@@ -75,6 +75,11 @@ func ReplacePVCByHostDisk(vmi *v1.VirtualMachineInstance, clientset kubecli.Kube
}
// PersistenVolumeClaim is replaced by HostDisk
volumeSource.PersistentVolumeClaim = nil
+ // Set ownership of the disk.img to qemu
+ if err := ephemeraldiskutils.DefaultOwnershipManager.SetFileOwnership(file); err != nil && !os.IsNotExist(err) {
+ log.Log.Reason(err).Errorf("Couldn't set Ownership on %s: %v", file, err)
+ return err
+ }
}
}
return nil
@@ -176,6 +181,7 @@ func (hdc DiskImgCreator) Create(vmi *v1.VirtualMachineInstance) error {
} else if err != nil {
return err
}
+ // Change file ownership to the qemu user.
if err := ephemeraldiskutils.DefaultOwnershipManager.SetFileOwnership(diskPath); err != nil {
log.Log.Reason(err).Errorf("Couldn't set Ownership on %s: %v", diskPath, err)
return err
