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

make creating initial vbox disks work with nixops 35ac0208 #28

Merged
merged 3 commits into from
Aug 10, 2023

Conversation

Uthar
Copy link
Contributor

@Uthar Uthar commented Aug 22, 2021

_eval_flags and nix_exprs are undefined in nixops 35ac0208, which causes an error when deploying with targetEnv="virtualbox" - one can use nixops.evaluation.eval instead to make it work.

full trace:

git............> creating VirtualBox VM...
git............> Virtual machine 'nixops-c9e5f533-02c9-11ec-8d2a-f01faf415644-git' is created and registered.
git............> UUID: 657a996c-25fd-4d9b-8403-c6b9b9e8559f
git............> Settings file: '/home/kpg/VirtualBox VMs/nixops-c9e5f533-02c9-11ec-8d2a-f01faf415644-git/nixops-c9e5f533-02c9-11ec-8d2a-f01faf415644-git.vbox'
git............> creating disk ‘disk1’...
Traceback (most recent call last):
  File "/nix/store/xj0midzl1ynx6s8w82x136xc96bg8qwl-python3.8-nixops-20210821/bin/.nixops-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/hd7zizr2v0fvi8sh733lkdvlb1b9gvsy-python3-3.8.9-env/lib/python3.8/site-packages/nixops/__main__.py", line 56, in main
    args.op(args)
  File "/nix/store/hd7zizr2v0fvi8sh733lkdvlb1b9gvsy-python3-3.8.9-env/lib/python3.8/site-packages/nixops/script_defs.py", line 688, in op_deploy
    depl.deploy(
  File "/nix/store/hd7zizr2v0fvi8sh733lkdvlb1b9gvsy-python3-3.8.9-env/lib/python3.8/site-packages/nixops/deployment.py", line 1352, in deploy
    self.run_with_notify("deploy", lambda: self._deploy(**kwargs))
  File "/nix/store/hd7zizr2v0fvi8sh733lkdvlb1b9gvsy-python3-3.8.9-env/lib/python3.8/site-packages/nixops/deployment.py", line 1341, in run_with_notify
    f()
  File "/nix/store/hd7zizr2v0fvi8sh733lkdvlb1b9gvsy-python3-3.8.9-env/lib/python3.8/site-packages/nixops/deployment.py", line 1352, in <lambda>
    self.run_with_notify("deploy", lambda: self._deploy(**kwargs))
  File "/nix/store/hd7zizr2v0fvi8sh733lkdvlb1b9gvsy-python3-3.8.9-env/lib/python3.8/site-packages/nixops/deployment.py", line 1255, in _deploy
    nixops.parallel.run_tasks(
  File "/nix/store/hd7zizr2v0fvi8sh733lkdvlb1b9gvsy-python3-3.8.9-env/lib/python3.8/site-packages/nixops/parallel.py", line 106, in run_tasks
    raise list(exceptions.values())[0]
  File "/nix/store/hd7zizr2v0fvi8sh733lkdvlb1b9gvsy-python3-3.8.9-env/lib/python3.8/site-packages/nixops/parallel.py", line 70, in thread_fun
    work_result = (worker_fun(t), None, t.name)
  File "/nix/store/hd7zizr2v0fvi8sh733lkdvlb1b9gvsy-python3-3.8.9-env/lib/python3.8/site-packages/nixops/deployment.py", line 1207, in worker
    r.create(
  File "/nix/store/hd7zizr2v0fvi8sh733lkdvlb1b9gvsy-python3-3.8.9-env/lib/python3.8/site-packages/nixopsvbox/backends/virtualbox.py", line 397, in create
    + self.depl._eval_flags(self.depl.nix_exprs)
AttributeError: 'Deployment' object has no attribute '_eval_flags'

_eval_flags and nix_exprs are undefined in nixops 35ac0208
@onny
Copy link

onny commented Sep 29, 2021

I'm facing the same issue while using libvirt as deployment backend :(

$ nixops deploy -d pi-nix-testing
database> Connecting to qemu:///system...
database> preparing disk image...
Traceback (most recent call last):
  File "/nix/store/m3g2f9fj7l0n8v3p42yyfpplyf0jibp1-python3.9-nixops-2.0.0/bin/.nixops-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/3il5njybb5whz9lh9wk9k3c70kb5xcn9-python3-3.9.6-env/lib/python3.9/site-packages/nixops/__main__.py", line 56, in main
    args.op(args)
  File "/nix/store/3il5njybb5whz9lh9wk9k3c70kb5xcn9-python3-3.9.6-env/lib/python3.9/site-packages/nixops/script_defs.py", line 688, in op_deploy
    depl.deploy(
  File "/nix/store/3il5njybb5whz9lh9wk9k3c70kb5xcn9-python3-3.9.6-env/lib/python3.9/site-packages/nixops/deployment.py", line 1352, in deploy
    self.run_with_notify("deploy", lambda: self._deploy(**kwargs))
  File "/nix/store/3il5njybb5whz9lh9wk9k3c70kb5xcn9-python3-3.9.6-env/lib/python3.9/site-packages/nixops/deployment.py", line 1341, in run_with_notify
    f()
  File "/nix/store/3il5njybb5whz9lh9wk9k3c70kb5xcn9-python3-3.9.6-env/lib/python3.9/site-packages/nixops/deployment.py", line 1352, in <lambda>
    self.run_with_notify("deploy", lambda: self._deploy(**kwargs))
  File "/nix/store/3il5njybb5whz9lh9wk9k3c70kb5xcn9-python3-3.9.6-env/lib/python3.9/site-packages/nixops/deployment.py", line 1255, in _deploy
    nixops.parallel.run_tasks(
  File "/nix/store/3il5njybb5whz9lh9wk9k3c70kb5xcn9-python3-3.9.6-env/lib/python3.9/site-packages/nixops/parallel.py", line 106, in run_tasks
    raise list(exceptions.values())[0]
  File "/nix/store/3il5njybb5whz9lh9wk9k3c70kb5xcn9-python3-3.9.6-env/lib/python3.9/site-packages/nixops/parallel.py", line 70, in thread_fun
    work_result = (worker_fun(t), None, t.name)
  File "/nix/store/3il5njybb5whz9lh9wk9k3c70kb5xcn9-python3-3.9.6-env/lib/python3.9/site-packages/nixops/deployment.py", line 1207, in worker
    r.create(
  File "/nix/store/3il5njybb5whz9lh9wk9k3c70kb5xcn9-python3-3.9.6-env/lib/python3.9/site-packages/nixops_virtd/backends/libvirtd.py", line 211, in create
    self._prepare_storage_volume()
  File "/nix/store/3il5njybb5whz9lh9wk9k3c70kb5xcn9-python3-3.9.6-env/lib/python3.9/site-packages/nixops_virtd/backends/libvirtd.py", line 239, in _prepare_storage_volume
    + self.depl._eval_flags(self.depl.nix_exprs)
AttributeError: 'Deployment' object has no attribute '_eval_flags'

@jbuchermn
Copy link

Why is this not merged? Still an issue.

@CodeLongAndProsper90
Copy link

Just ran into this issue today, it would be great if this could be merged

yajo added a commit to moduon/nixops-plugged that referenced this pull request Jul 7, 2022
Pre-merge nix-community/nixops-vbox#27 and update the plugin.

Since we now have 2 PRs merged (includes nix-community/nixops-vbox#28 as before), I switched the strategy: pull package from origin master and add PRs as patches.

@moduon MT-904
@yajo
Copy link
Contributor

yajo commented Jul 7, 2022

The patch is incomplete. By not calling nix-build, it's not making sure the disk is created on the nix store. After merging this patch, nixops deploy still fails with:

machine-1.> VBoxManage: error: Could not find file for the medium '/nix/store/7xgrcfcmcbhwb1bjcs4nq4dr2lh3mi3n-virtualbox-nixops-22.05.vmdk' (VERR_FILE_NOT_FOUND)
machine-1.> VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium, callee nsISupports
machine-1.> VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 187 of file VBoxManageDisk.cpp
Traceback (most recent call last):
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/parallel.py", line 70, in thread_fun
    work_result = (worker_fun(t), None, t.name)
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/deployment.py", line 1207, in worker
    r.create(
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixopsvbox/backends/virtualbox.py", line 409, in create
    self._logged_exec(
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/backends/__init__.py", line 582, in _logged_exec
    return nixops.util.logged_exec(command, self.logger, **kwargs)
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/util.py", line 372, in logged_exec
    raise CommandFailed(err, res)
nixops.util.CommandFailed: command ‘['VBoxManage', 'clonehd', '/nix/store/7xgrcfcmcbhwb1bjcs4nq4dr2lh3mi3n-virtualbox-nixops-22.05.vmdk', '/var/home/yajo/VirtualBox VMs/nixops-94a4598f-fdde-11ec-968b-b025aa45f949-k3s-agent-1/disk1.vdi', '--format', 'VDI']’ failed on machine ‘k3s-agent-1’ (exit code 1)

Which basically means that /nix/store/7xgrcfcmcbhwb1bjcs4nq4dr2lh3mi3n-virtualbox-nixops-22.05.vmdk doesn't exist.

yajo added a commit to moduon/nixops-vbox that referenced this pull request Jul 7, 2022
Without this fix, the virtualbox disk may not exist when creating the machine.

The error is:

```
machine-1.> VBoxManage: error: Could not find file for the medium '/nix/store/7xgrcfcmcbhwb1bjcs4nq4dr2lh3mi3n-virtualbox-nixops-22.05.vmdk' (VERR_FILE_NOT_FOUND)
machine-1.> VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium, callee nsISupports
machine-1.> VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 187 of file VBoxManageDisk.cpp
Traceback (most recent call last):
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/parallel.py", line 70, in thread_fun
    work_result = (worker_fun(t), None, t.name)
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/deployment.py", line 1207, in worker
    r.create(
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixopsvbox/backends/virtualbox.py", line 409, in create
    self._logged_exec(
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/backends/__init__.py", line 582, in _logged_exec
    return nixops.util.logged_exec(command, self.logger, **kwargs)
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/util.py", line 372, in logged_exec
    raise CommandFailed(err, res)
nixops.util.CommandFailed: command ‘['VBoxManage', 'clonehd', '/nix/store/7xgrcfcmcbhwb1bjcs4nq4dr2lh3mi3n-virtualbox-nixops-22.05.vmdk', '/var/home/yajo/VirtualBox VMs/nixops-94a4598f-fdde-11ec-968b-b025aa45f949-k3s-agent-1/disk1.vdi', '--format', 'VDI']’ failed on machine ‘k3s-agent-1’ (exit code 1)
```

See nix-community#28 (comment).

@moduon MT-904
yajo added a commit to moduon/nixops that referenced this pull request Jul 7, 2022
Plugins might need to call this function to actually build something in the nix store.

See nix-community/nixops-vbox#28 (comment) for example.

We need a way to tell eval to do a build. Here it is.

@moduon MT-904
yajo added a commit to moduon/nixops-vbox that referenced this pull request Jul 7, 2022
Without this fix, the virtualbox disk may not exist when creating the machine.

The error is:

```
machine-1.> VBoxManage: error: Could not find file for the medium '/nix/store/7xgrcfcmcbhwb1bjcs4nq4dr2lh3mi3n-virtualbox-nixops-22.05.vmdk' (VERR_FILE_NOT_FOUND)
machine-1.> VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium, callee nsISupports
machine-1.> VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 187 of file VBoxManageDisk.cpp
Traceback (most recent call last):
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/parallel.py", line 70, in thread_fun
    work_result = (worker_fun(t), None, t.name)
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/deployment.py", line 1207, in worker
    r.create(
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixopsvbox/backends/virtualbox.py", line 409, in create
    self._logged_exec(
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/backends/__init__.py", line 582, in _logged_exec
    return nixops.util.logged_exec(command, self.logger, **kwargs)
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/util.py", line 372, in logged_exec
    raise CommandFailed(err, res)
nixops.util.CommandFailed: command ‘['VBoxManage', 'clonehd', '/nix/store/7xgrcfcmcbhwb1bjcs4nq4dr2lh3mi3n-virtualbox-nixops-22.05.vmdk', '/var/home/yajo/VirtualBox VMs/nixops-94a4598f-fdde-11ec-968b-b025aa45f949-k3s-agent-1/disk1.vdi', '--format', 'VDI']’ failed on machine ‘k3s-agent-1’ (exit code 1)
```

See nix-community#28 (comment).

For this to work, we need a patch TODO LINK.

@moduon MT-904
yajo added a commit to moduon/nixops that referenced this pull request Jul 7, 2022
Plugins might need to call this function to actually build something in the nix store.

See nix-community/nixops-vbox#28 (comment) for example.

We need a way to tell eval to do a build. Here it is.

@moduon MT-904
yajo added a commit to moduon/nixops that referenced this pull request Jul 8, 2022
Plugins might need to call this function to actually build something in the nix store.

See nix-community/nixops-vbox#28 (comment) for example.

We need a way to tell eval to do a build. Here it is.

@moduon MT-904
yajo added a commit to moduon/nixops that referenced this pull request Jul 8, 2022
Plugins might need to call this function to actually build something in the nix store.

See nix-community/nixops-vbox#28 (comment) for example.

We need a way to tell eval to do a build. Here it is.

@moduon MT-904
Without this fix, the virtualbox disk may not exist when creating the machine.

The error is:

```
machine-1.> VBoxManage: error: Could not find file for the medium '/nix/store/7xgrcfcmcbhwb1bjcs4nq4dr2lh3mi3n-virtualbox-nixops-22.05.vmdk' (VERR_FILE_NOT_FOUND)
machine-1.> VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium, callee nsISupports
machine-1.> VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 187 of file VBoxManageDisk.cpp
Traceback (most recent call last):
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/parallel.py", line 70, in thread_fun
    work_result = (worker_fun(t), None, t.name)
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/deployment.py", line 1207, in worker
    r.create(
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixopsvbox/backends/virtualbox.py", line 409, in create
    self._logged_exec(
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/backends/__init__.py", line 582, in _logged_exec
    return nixops.util.logged_exec(command, self.logger, **kwargs)
  File "/nix/store/ywh9crwf21xbhgw31fy5zpcc4z9p9gzb-python3-3.8.9-env/lib/python3.8/site-packages/nixops/util.py", line 372, in logged_exec
    raise CommandFailed(err, res)
nixops.util.CommandFailed: command ‘['VBoxManage', 'clonehd', '/nix/store/7xgrcfcmcbhwb1bjcs4nq4dr2lh3mi3n-virtualbox-nixops-22.05.vmdk', '/var/home/yajo/VirtualBox VMs/nixops-94a4598f-fdde-11ec-968b-b025aa45f949-k3s-agent-1/disk1.vdi', '--format', 'VDI']’ failed on machine ‘k3s-agent-1’ (exit code 1)
```

See #28 (comment).

For this to work, we need NixOS/nixops#1529.

@moduon MT-904
@yajo
Copy link
Contributor

yajo commented Jul 8, 2022

Please @Uthar merge https://github.com/Uthar/nixops-vbox/pull/1 so this PR is complete. It depends on NixOS/nixops#1529 being merged and fixes the problem from #28 (comment).

yajo added a commit to moduon/nixops-plugged that referenced this pull request Jul 8, 2022
For nixops master and nixops-vbox to work, as of today, we need:
- NixOS/nixops#1529
- nix-community/nixops-vbox#27
- nix-community/nixops-vbox#28 (as before)
- https://github.com/Uthar/nixops-vbox/pull/1

Since we now have more PRs merged, I switched the strategy: pull package from origin master and add PRs as patches.

@moduon MT-904
pasqui23 pushed a commit to pasqui23/nixops that referenced this pull request Jul 16, 2022
Plugins might need to call this function to actually build something in the nix store.

See nix-community/nixops-vbox#28 (comment) for example.

We need a way to tell eval to do a build. Here it is.

@moduon MT-904
@Uthar
Copy link
Contributor Author

Uthar commented Aug 1, 2022

Thank you @yajo - I merged https://github.com/Uthar/nixops-vbox/pull/1

@lordcirth
Copy link

So, can this PR be merged now that dependencies are in place?

@GeorgesAlkhouri
Copy link

Is there anything left to do here? Is help needed? I would love to try out nixops with virtualbox?

@yajo
Copy link
Contributor

yajo commented Aug 22, 2022

AFAIK this just needs to be merged.

@ngasull
Copy link

ngasull commented Jan 9, 2023

Any chance we got this merged @AmineChikhaoui ? I'm still stumbling on this in 2023, this fix would be more than welcome.

@deepfire
Copy link

deepfire commented Aug 8, 2023

cc @Kranzes @adisbladis

@AmineChikhaoui
Copy link
Member

Sorry I didn't check nixops notifications that much since I haven't been using it for a while.

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

Successfully merging this pull request may close these issues.

10 participants