Compare commits

..

378 Commits

Author SHA1 Message Date
Julien Fontanet
33eb080484 chore(xen-api/_call): better handling 2022-04-20 10:18:47 +02:00
Julien Fontanet
6da0aa376f fix(xo-vmdk-to-vhd/createNicsSection): remove incorrect XML node
Introduced by 4b9db257f

See https://github.com/vatesfr/xen-orchestra/pull/6195#discussion_r853177122
2022-04-20 09:56:04 +02:00
Julien Fontanet
1ab5503558 chore(xo-vmdk-to-vhd): refresh README
Introduced by 4b9db257f
2022-04-19 17:47:43 +02:00
Nicolas Raynaud
4b9db257fd feat: initial support for OVA VM export (#6006)
Co-authored-by: Florent Beauchamp <flo850@free.fr>
2022-04-19 11:01:53 +02:00
Julien Fontanet
96f83d92fc chore: update dev deps 2022-04-19 10:32:16 +02:00
Pierre Donias
7c7ee7fb9b feat: release 5.69.2 (#6189) 2022-04-13 16:52:40 +02:00
Pierre Donias
2bd3d57f8a feat(xo-server/rpu): update hosts one by one on XCP-ng (#6188) 2022-04-13 16:38:23 +02:00
Pierre Donias
3f1c41a4f7 fix(xo-server/Rolling Pool Update/_xcpUpdate): handle undefined hosts (#6186)
Fixes #6170
Introduced by e7f9111ab5
2022-04-13 13:22:30 +02:00
Julien Fontanet
ef819f4d53 fix(xo-server/connectXenServer): typo
Introduced by 6b8a34524
2022-04-08 14:30:35 +02:00
Julien Fontanet
23189ed8f9 chore(scripts): add .js suffix for better Prettier/ESLint integration 2022-04-08 14:14:41 +02:00
Florent BEAUCHAMP
6b8a345241 feat(xen-api): implement fallback addresses (#6061) 2022-04-08 11:11:20 +02:00
Julien Fontanet
b3cc168571 docs(xapi/watchObject): explicit behavior and param 2022-04-08 10:57:44 +02:00
Julien Fontanet
00b740c549 chore(xo-server/docs/rest-api): improve readability 2022-04-08 10:57:44 +02:00
Pierre Donias
472bececb1 feat(xo-server/plugins): unload plugin on configuration purge (#6172) 2022-04-07 14:49:36 +02:00
Olivier Lambert
4fe9a4eb59 feat(docs): add REST API doc and minor fixes (#6178)
Co-authored-by: Jon Sands <fohdeesha@gmail.com>
2022-04-07 10:42:10 +02:00
Pierre Donias
d331cd934a fix(xo-server/backup): restore VM from proxied remote (#6179) 2022-04-06 16:32:43 +02:00
Olivier Lambert
f6e1b95711 feat(issue template/bug): explicit XOA and sources differences (#6175)
Co-authored-by: Jon Sands <fohdeesha@gmail.com>
2022-04-05 15:02:46 +02:00
Florent BEAUCHAMP
edec412bc7 fix(docs/backups): clarify file level restore for VG based on multiple PV (#6152)
Co-authored-by: Jon Sands <fohdeesha@gmail.com>
2022-04-05 10:24:41 +02:00
Florent BEAUCHAMP
e142bacb67 fix(xo-vmdk-to-vhd): ensure secondary grain table is present (#6167) 2022-04-05 10:24:00 +02:00
Florent BEAUCHAMP
915e4b66a3 fix(vmdk): ensure descriptor have enough free space (#6163) 2022-04-05 10:22:13 +02:00
Pierre Donias
ee47a361b1 fix(xo-server/config): configure plugins on config import (#6171)
See https://xcp-ng.org/forum/topic/5720/ztp-restore-xoa-from-backup
2022-04-04 15:44:05 +02:00
l-austenfeld
3ab2dad19b fix(docs/configuration): link to sources install (#6177)
Co-authored-by: Lennart Austenfeld <lennarta@mail.upb.de>
2022-04-04 08:28:12 +02:00
Julien Fontanet
635c6db83a fix(backups/ImportVmBackup): fix optional mapVdisSrs
Introduced by dfa5009a9
2022-04-03 16:34:05 +02:00
Julien Fontanet
d2a13f531a feat(xen-api): support pathname in URL
Fixes #6174
2022-04-02 20:07:43 +02:00
Julien Fontanet
e44857c023 fix(xen-api/transports/xml-rpc): fix agent support
Introduced by c99120bd2
2022-04-02 20:05:17 +02:00
Julien Fontanet
749cdd011b fix(proxy/reverse proxy): don't remove first char of local path
Introduced by b78a946458
2022-04-02 19:57:08 +02:00
Julien Fontanet
4fde005b7f fix(proxy/reverse proxy): fix options support
Introduced by b78a946458
2022-04-02 19:54:28 +02:00
Olivier Lambert
0a975fc0cc feat(docs/updates): add RPU documentation and improve the update section (#6173)
* feat(docs/updates): add RPU documentation and improve the update section

Signed-off-by: Olivier Lambert <olivier.lambert@vates.fr>
2022-04-02 11:23:22 +02:00
Pierre Donias
f5b7c59203 feat: release 5.69.1 (#6169) 2022-03-31 15:54:59 +02:00
Florent BEAUCHAMP
c775559912 fix(xo-server): typo in authorization level enterprise (#6168)
Introduced by 8ce1b4bf71
See zammad#6043
2022-03-31 15:39:05 +02:00
Pierre Donias
4b9116ed72 feat: release 5.69.0 (#6166) 2022-03-31 10:50:32 +02:00
Thierry Goettelmann
178501e252 fix(backups/_backupType): XVA sum files are not detected (#6160) 2022-03-30 23:20:05 +02:00
Pierre Donias
c9391abfd9 feat: technical release (#6165) 2022-03-30 16:06:06 +02:00
Pierre Donias
f7a7d9e52d feat: technical release (#6164) 2022-03-30 15:15:22 +02:00
Mathieu
5a65087aeb fix(xo-web/file restore): mention S3 is not compatible (#6158)
Introduced by 3842f5b16d
2022-03-30 12:10:08 +02:00
Pierre Donias
3cfeb8f492 docs(Netbox): update with Netbox v3 screenshots (#6162) 2022-03-30 09:00:18 +02:00
Julien Fontanet
0498e2d679 chore: update deps 2022-03-29 16:35:00 +02:00
Florent BEAUCHAMP
19563d0b3c fix(web): rework human readable number rounding (#6131) 2022-03-29 14:33:04 +02:00
Pierre Donias
4cc1d98a42 fix(xo-server,xo-web/new ISO SR): take NFS version & options into account (#6161)
See zammad#5995
2022-03-29 14:28:16 +02:00
Mathieu
cd408c1687 feat(xo-web/VM/import): ability to import XVA VM from URL (#6130)
Follow-up of 86e390f70f
2022-03-29 11:43:11 +02:00
Rajaa.BARHTAOUI
546859531b feat(xo-web/install patches): improve confirm message (#6159) 2022-03-29 11:17:13 +02:00
Pierre Donias
857e467672 Revert "fix(xo-web/job): properly handle array arguments (#5944)" (#6156)
This reverts commit e2e453985f.

See #5983
See #5973
See zammad#5844
2022-03-29 11:15:43 +02:00
Florent BEAUCHAMP
5de5a80eee feat(xo-web/VM/Advanced): add link to doc on secure boot (#6146) 2022-03-28 15:46:26 +02:00
Thierry Goettelmann
5f1333b2a0 chore(fs/s3): upgrade AWS SDK (#6144)
https://github.com/aws/aws-sdk-js-v3/blob/main/UPGRADING.md
2022-03-28 14:06:23 +02:00
Julien Fontanet
5e9548edbc feat(xo-server/rest-api): add VDI export 2022-03-28 11:12:26 +02:00
Julien Fontanet
e42edf2164 fix(xo-server/rest-api/VM export): 404 error if UUID is not a VM 2022-03-28 11:01:09 +02:00
Julien Fontanet
7e8c524a43 fix(xo-server/rest-api): restrict to admin users (missing change)
Introduced by 24ce40042
2022-03-28 11:00:26 +02:00
Julien Fontanet
8d6ba86118 fix(xo-server): xo-common/api-error.js import
Introduced by dc27317d0
2022-03-28 10:36:10 +02:00
Julien Fontanet
dc27317d0b feat(xo-server/rollingPoolUpdate): fail if some hosts are not running
Fixes zammad#795.
2022-03-28 08:46:00 +02:00
Julien Fontanet
0b8032c7a0 feat(xen-api/cli): expose lodash as L 2022-03-28 08:38:41 +02:00
Julien Fontanet
d3e18a81aa chore(xen-api): don't use babel-plugin-lodash
It prevents importing the whole package when necessary.
2022-03-28 08:37:54 +02:00
Julien Fontanet
4707573c57 feat(xo-server/rest-api): add VM export 2022-03-26 23:36:01 +01:00
Julien Fontanet
218e2deef4 chore(xo-server/docs/rest-api): add ToC 2022-03-26 23:14:00 +01:00
Julien Fontanet
47afff3bab chore(xo-server/docs/rest-api): explicit experimental status 2022-03-26 23:13:09 +01:00
Julien Fontanet
24ce400429 feat(xo-server/rest-api): restrict to admin users 2022-03-26 23:01:45 +01:00
Julien Fontanet
ceac341016 chore(xo-server): use @xen-orchestra/xapi/VM_export 2022-03-26 22:59:20 +01:00
Julien Fontanet
7830c89e66 fix(xo-server/Xapi#exportVm): correctly use getRecord
Introduced by 6aa5ec6eb
2022-03-26 12:41:44 +01:00
Julien Fontanet
fa6ca01de9 chore: remove unused Flow config
Introduced by 78c0f2c7e
2022-03-26 09:20:18 +01:00
Julien Fontanet
746bff55a8 fix(backups): import suspended VM without suspend VDI (#6149)
Fixes #6142
2022-03-25 23:06:32 +01:00
Julien Fontanet
ec81e90153 chore(proxy-cli): remove build step 2022-03-25 19:07:26 +01:00
Julien Fontanet
74c9d06d91 chore(cron): remove build step 2022-03-25 17:10:22 +01:00
Julien Fontanet
3cfbd8b70c fix(jest): don't run audit-core tests
Introduced by 046d9b80b
2022-03-25 17:10:22 +01:00
Julien Fontanet
046d9b80bb test(audit-core): use tap instead of Jest 2022-03-25 16:53:04 +01:00
Julien Fontanet
516fda2a3a chore(audit-core): move spec to docs/
To avoid it from being published.
2022-03-25 15:43:37 +01:00
Julien Fontanet
bc5c103cec chore(audit-core): remove build step 2022-03-25 15:40:52 +01:00
Julien Fontanet
98f0c068ad chore(backups): initial documentation 2022-03-25 11:21:17 +01:00
Julien Fontanet
28e0a5a3a3 fix(xo-server/utils/parseXml): ignore XML declaration
Restore previous behavior and fix tests.
2022-03-25 10:18:41 +01:00
Julien Fontanet
5f9d6db761 feat(xo-server/_pDebounceWithKey): proper support of inifinite delay
No more Node warning.
2022-03-25 10:17:33 +01:00
Julien Fontanet
9bec52074f test(xo-server): use tap instead of Jest
Fixes support of .mjs files
2022-03-25 10:16:49 +01:00
Rajaa.BARHTAOUI
dfa5009a9b feat(xo-web/backup/restore): ability to ignore certain VDIs (#6143)
Fixes #4605
2022-03-24 10:51:26 +01:00
Julien Fontanet
fbb5c47358 chore: update to eslint-plugin-n@15.1.0
It fixes the support for dynamic imports (`import()`).
2022-03-24 10:34:44 +01:00
Thierry Goettelmann
f2ca67a7f4 fix(fs/rmtree): unllink can throw EPERM for dirs on POSIX (#6155)
For instance on macOS.
2022-03-24 10:03:56 +01:00
Rajaa.BARHTAOUI
3a9af92571 feat(xo-web): disable patch installation when HA is enabled (#6145)
See kanban#770
2022-03-23 17:16:03 +01:00
Mathieu
b26148bf62 fix(xo-web/new/SR/NFS): disable "No selected value" path option (#6137)
Fixes #5991
2022-03-23 16:55:45 +01:00
Julien Fontanet
7e27e0bda8 linting: enable eslint-plugin-n recommended rules
And fixes a lot of related issues.
2022-03-23 11:18:37 +01:00
Julien Fontanet
94df05566a chore(xapi): remove xo-common from dev deps
Introduced by 5f1c1278e
2022-03-23 09:49:14 +01:00
Julien Fontanet
efa46414fd chore(xapi): remove build step 2022-03-23 09:48:07 +01:00
Julien Fontanet
311623d71a chore(xapi): don't use decorator syntax 2022-03-23 09:36:35 +01:00
Julien Fontanet
89894b0f08 chore: update yarn.lock 2022-03-23 09:35:57 +01:00
Julien Fontanet
ed590eeb41 fix(xen-api/_getHostBackupAddress): avoid using internal address for master
Fixes #6125
2022-03-22 15:44:21 +01:00
Julien Fontanet
8956902c52 chore: update dev deps 2022-03-22 09:34:46 +01:00
Julien Fontanet
720d9649eb fix(xapi): add missing xo-common dep
Introduced by 5f1c1278e
2022-03-22 09:34:46 +01:00
Olivier Lambert
ce95041821 feat(docs/community): add more details on support (#6151)
Co-authored-by: Jon Sands <fohdeesha@gmail.com>
2022-03-22 08:01:38 +01:00
Olivier Lambert
9cd84ac834 feat(docs/roadmap): update (#6150)
Co-authored-by: Jon Sands <fohdeesha@gmail.com>
2022-03-22 07:50:13 +01:00
Julien Fontanet
eddd6880f2 feat(xo-server/pool.installPatches): disable when HA enabled
Requested by @stormi https://team.vates.fr/vates/pl/r3y6fmxq9byqixehhm8wiyx9zw
2022-03-21 11:23:41 +01:00
Julien Fontanet
e7f9111ab5 feat(xo-server/pool.installPatches): restart toolstacks after install
Fixes https://kanban.vates.fr/b/jnfjuip4eBARBNuv9/xo-releases/t8QpqKnZ23iYnbRxR
2022-03-21 11:19:11 +01:00
Julien Fontanet
0eb2ee72a4 feat(xapi): host_restartAgent 2022-03-21 10:40:35 +01:00
Julien Fontanet
1aa4fac528 chore(xen-api): better status assertions 2022-03-21 10:38:27 +01:00
Pierre Donias
3f07f7ef41 fix(xo-server): invalid arguments passed to VM_destroy (#6119)
Fixes #6124
See https://xcp-ng.org/forum/topic/5569

Introduced by cb52a8b51
2022-03-17 14:37:45 +01:00
Julien Fontanet
886ff2cd70 fix(xo-server/_runJob): createUserConnection → createApiConnection
Introduced by 244b15038
2022-03-16 16:43:28 +01:00
Julien Fontanet
ed09608952 fix(xapi/VM_destroy): remove useless return 2022-03-16 15:54:36 +01:00
Julien Fontanet
6aa5ec6eb6 chore(xo-server): use @xen-orchestra/xapi/VM_{checkpoint,snapshot} 2022-03-16 14:48:59 +01:00
Julien Fontanet
eee4981d4c fix(xapi/VM_checkpoint): set is_a_template to false
The work-around was already implement for `VM_snapshot`.
2022-03-16 11:49:57 +01:00
Julien Fontanet
ab2c0f905a fix(xo-server): fix patching for XCP-ng>=8.2.1
Fixes zammad#5786

The behavior of the plugin has changed:
- it will throw in case of error
- `exit` is no longer defined in case of success

When defined, `exit` is still checked for compatibility with older versions.
2022-03-15 15:24:11 +01:00
Julien Fontanet
4eca3d169e feat(xo-server/api): add api.{getConnections,closeAllConnections} methods 2022-03-15 15:24:11 +01:00
Julien Fontanet
e69944eaaf chore(xo-server/api): uniformize session → connection 2022-03-15 15:24:11 +01:00
Julien Fontanet
bc987b2dda chore(xo-server): WebSocket connection events debugs 2022-03-15 15:23:52 +01:00
Julien Fontanet
244b150385 chore(xo-server): move Xo#createUserConnection() to Api#createApiConnection() 2022-03-15 15:23:01 +01:00
Julien Fontanet
3acbc08ec5 chore(xo-server): move some API logic to Xo#createUserConnection() 2022-03-15 14:38:16 +01:00
Julien Fontanet
1ce7e5d8a4 fix(proxy): fix incorrect order of decorators application
Introduced by e14c177f3
2022-03-14 18:34:01 +01:00
Julien Fontanet
7813fe232a chore(fs/S3): standardize paths handling 2022-03-14 13:41:01 +01:00
Julien Fontanet
1b273071b2 chore(fs/_path): utilities to handle virtual paths 2022-03-14 13:27:51 +01:00
Julien Fontanet
43236f25ad chore(fs/_normalizePath): comment more behaviors 2022-03-14 13:27:51 +01:00
Julien Fontanet
5f2b1acfea chore(xo-server/authorization): simplify check for source users 2022-03-12 16:06:07 +01:00
Florent BEAUCHAMP
b820dcd73f fix(xo-server/authorizations): add missing smart backups and S3 (#6141)
Introduced by 4e8dc2
2022-03-12 09:57:42 +01:00
Florent BEAUCHAMP
0a412c0ef7 feat(CI): use github action (#5987) 2022-03-11 17:18:21 +01:00
Florent BEAUCHAMP
db75f8046c feat(fs/S3#list): workaround Backblaze issue (#6139)
Workaround for #6138
2022-03-11 16:12:08 +01:00
Florent Beauchamp
7bdd1a4a3a fix(vhd-lib): fix tests 2022-03-11 14:55:55 +01:00
Julien Fontanet
b7d39105e8 feat(docs): delete old (unused) from_the_sources 2022-03-10 19:26:48 +01:00
Julien Fontanet
f8b5dbbba5 feat(docs/installation): integrate old from_the_sources changes 2022-03-10 19:26:13 +01:00
Florent BEAUCHAMP
c99120bd24 feat: support VM/hosts consoles behind HTTP proxy (#6133)
This is a major change in the way xo-server connect to a console, from connecting directly as a TCP socket to using a WebSocket in binary mode.

This was already the case prior c17620e but was changed due to XenServer issues with their WebSocket console implementation, it appears to be working fine now.
2022-03-10 13:54:32 +01:00
Julien Fontanet
b9ff3db9b0 feat(decorate-with): decorateClass() (#6136)
Generalization of `decorateMethodsWith` which also works for accessors.

The suffix `With` is not part of the name because it's not fluent (unlike for `@decorateWith(decorator)`).

`decorateMethodsWith` is now a deprecated alias for this new implementation.
2022-03-10 11:51:57 +01:00
Florent BEAUCHAMP
8ce1b4bf71 feat(xo-server): server side authorization (#6107) 2022-03-10 11:45:04 +01:00
Julien Fontanet
0b41a2b132 feat(fs): add basic CLI 2022-03-10 09:48:45 +01:00
Julien Fontanet
575ed92593 fix(xo-server): add missing dep @vates/async-each
Introduced by 6075a3307
2022-03-09 16:14:58 +01:00
Julien Fontanet
d3fe37b879 fix(fs): add missing dep @vates/async-each
Introduced by 96eb79329
2022-03-09 16:13:27 +01:00
Julien Fontanet
8318cb991b chore(xen-api): remove Babel plugin included in preset-env 2022-03-09 09:03:23 +01:00
Julien Fontanet
9779fb1d29 fix(gitignore): ignore all coverage/ 2022-03-09 08:19:59 +01:00
Julien Fontanet
43b4e8c924 fix(CHANGELOG.unreleased): add @xen-orchestra/xapi
Follow-up of c67b55043
2022-03-09 06:58:17 +01:00
Julien Fontanet
756a206a9e feat(xo-server/RestApi): add networks, VBDs, VDIs and VIFs 2022-03-09 06:56:25 +01:00
Julien Fontanet
324ff44886 chore(proxy): remove unused .eslintrc.js
Follow-up of a870813ac
2022-03-09 06:45:24 +01:00
AtaxyaNetwork
04913cabba fix(docs/from_the_sources): replace python-minimal with python3-minimal (#6134)
python-minimal doesn't exist anymore on latest Debian
2022-03-06 19:36:52 +01:00
Julien Fontanet
c67b550435 chore(xen-api): major version
When using major version zero, every increase of the minor version number is breaking.

Which means that each new version of `xen-api` required also a new release of `@xen-orchestra/xapi`, using a true major version will fix that.
2022-03-04 10:17:12 +01:00
Julien Fontanet
88bf60b8c2 feat(xen-api/objects): add index by type 2022-03-04 10:17:12 +01:00
Barney
08fd2beb52 fix(docs/sdn_controller.md): typo optionnal → optional 2022-03-04 09:26:39 +01:00
Julien Fontanet
a870813ac5 chore(proxy): remove build step 2022-03-03 15:38:55 +01:00
Julien Fontanet
c31f0100cb chore(proxy/backups): no license check bypass in dev mode 2022-03-03 15:23:02 +01:00
Julien Fontanet
bc7fc750f0 fix(xo-server/RestApi): don't fail on missing express
Which is the case when instanciated from `xo-server-recover-account`.
2022-03-03 14:26:26 +01:00
Julien Fontanet
9cd1784667 chore(xo-server): remove Babel plugin included in preset-env 2022-03-03 14:12:29 +01:00
Julien Fontanet
fbc7baa9a4 chore(proxy): remove unused Babel plugin 2022-03-03 14:12:29 +01:00
Julien Fontanet
a4e5cf3914 chore: remove babel plugins included in preset-env 2022-03-03 14:12:25 +01:00
Julien Fontanet
e14c177f39 chore(proxy): don't use decorator syntax 2022-03-03 13:45:26 +01:00
Julien Fontanet
b5b53c636c feat(vhd-cli info): human format UUIDs 2022-03-03 10:59:22 +01:00
Julien Fontanet
33b45d2eda feat(xo-server): better info when failing to start a VM
Fixes https://xcp-ng.org/forum/post/47329
2022-03-02 22:52:59 +01:00
Julien Fontanet
4c9bb71626 chore: missing use strict 2022-03-02 17:49:53 +01:00
Julien Fontanet
e9aa88e637 chore(scripts): fix lint errors 2022-03-02 17:48:26 +01:00
Julien Fontanet
e7c7c2ce3e fix(xo-server/pool.rollingUpdate): don't fail on missing load-balancer
Fixes zammad#5642
2022-03-02 17:35:31 +01:00
Manon Mercier
686e7e9527 feat(docs/backup_troubleshooting): Lock file is already being held (#6123)
Co-authored-by: Jon Sands <fohdeesha@gmail.com>
2022-03-01 16:33:11 +01:00
Julien Fontanet
86e390f70f feat(xo-server/vm.import): support from URL 2022-03-01 11:44:16 +01:00
Julien Fontanet
e04352a577 chore: update dev deps 2022-03-01 09:04:28 +01:00
Julien Fontanet
ee4e7620b5 feat(xo-server/sr.getAllUnhealthyVdiChainsLength): memoize 60 seconds
Introduced by 0975863d9
2022-02-28 23:15:02 +01:00
Julien Fontanet
975dc4f314 feat: release 5.68.0 2022-02-28 23:15:02 +01:00
Julien Fontanet
dfff96ace1 feat(xo-server-audit): 0.9.3 2022-02-28 17:37:20 +01:00
Julien Fontanet
f01171bb8b fix(xo-server-audit): ignore sr.getAllUnhealthyVdiChainsLength
Introduced by 0975863d9
2022-02-28 17:36:27 +01:00
Julien Fontanet
8f248f8d14 feat(CHANGELOG): integrate released changes 2022-02-28 17:24:11 +01:00
Julien Fontanet
ae815a80b1 feat(xo-web): 5.94.0 2022-02-28 17:23:43 +01:00
Julien Fontanet
925514b0a3 feat(xo-server): 5.89.0 2022-02-28 17:23:23 +01:00
Julien Fontanet
45639e5a5c feat(@xen-orchestra/proxy): 0.19.0 2022-02-28 17:22:59 +01:00
Julien Fontanet
17ab78f064 feat(@xen-orchestra/backups): 0.20.0 2022-02-28 17:22:27 +01:00
Rajaa.BARHTAOUI
c43a3343d8 fix(xo-server/sr.getAllUnhealthyVdiChainsLength): don't include empty SRs (#6126) 2022-02-28 15:07:33 +01:00
Julien Fontanet
095e40d1dd feat(xo-server/api): logs number of clients 2022-02-28 11:12:40 +01:00
Rajaa.BARHTAOUI
a400ef823f feat(delta backup/restoration): ability to choose SR for each VDI (#6117)
Fixes #4605
Fixes #4016
2022-02-28 09:29:30 +01:00
Julien Fontanet
7684fbd5ec fix(xo-server): add missing @vates/predicates
Introduced by 636025c1b
2022-02-25 14:43:15 +01:00
Julien Fontanet
cd64e8dc28 feat(CHANGELOG): integrate released changes 2022-02-25 13:43:13 +01:00
Julien Fontanet
dbba918b79 feat(xo-web): 5.93.0 2022-02-25 13:40:52 +01:00
Julien Fontanet
88dbe35c4b feat(xo-server): 5.88.0 2022-02-25 13:40:26 +01:00
Julien Fontanet
4a61fedf97 feat(xo-cli): 0.13.0 2022-02-25 13:39:49 +01:00
Julien Fontanet
110181679b feat(@xen-orchestra/proxy): 0.18.1 2022-02-25 13:38:43 +01:00
Julien Fontanet
b0a0092a73 feat(@xen-orchestra/backups): 0.19.1 2022-02-25 13:38:19 +01:00
Julien Fontanet
a6a975ce40 feat(@xen-orchestra/mixins): 0.2.0 2022-02-25 13:36:23 +01:00
Julien Fontanet
a73eb82ac6 feat(@vates/predicates): 1.0.0 2022-02-25 13:33:55 +01:00
Julien Fontanet
702cade0d7 feat(@xen-orchestra/xapi): 0.9.0 2022-02-25 13:33:12 +01:00
Julien Fontanet
367b86bc7a feat(xen-api): 0.36.0 2022-02-25 13:32:14 +01:00
Julien Fontanet
7c5e823805 chore: update deps 2022-02-25 13:18:16 +01:00
Mathieu
0975863d98 feat(xo-server/api/sr, xo-web/dashboard/health): list coalescing VDIs (#6120)
See zammad#5224
2022-02-25 10:26:47 +01:00
Rajaa.BARHTAOUI
6e6886a6ba feat(xo-web/new/sr): creating local SR requires confirmation (#6121) 2022-02-23 23:04:42 +01:00
Julien Fontanet
8bf11d6f6a chore(decorate-with): add tests 2022-02-22 15:26:10 +01:00
Julien Fontanet
6c97ccafd5 chore(xo-server-test/README): regenerate
Introduced by 2ee153509
2022-02-22 12:47:44 +01:00
Julien Fontanet
72ff66ebde chore: enforce strict mode for CJS files 2022-02-22 12:34:41 +01:00
Julien Fontanet
b3d0da7392 feat(eslint): use correct sourceType for scripts and modules 2022-02-22 12:02:57 +01:00
Julien Fontanet
a1c0d82889 fix(docs/from sources): change Node LTS version in example 2022-02-19 14:06:37 +01:00
Julien Fontanet
fbd708d1b5 chore: update dev deps 2022-02-19 14:02:32 +01:00
Julien Fontanet
710ce965a1 feat(gitignore): ignore .nyc_output 2022-02-18 17:24:26 +01:00
Julien Fontanet
2ee1535095 chore(xo-server-test): rename script teststart
By convention, `test` means running tests for the current package, but it's not the case here, `xo-server-test` is a an app (even if dedicated to test `xo-server`'s API) and should be run as such.
2022-02-18 17:20:55 +01:00
Julien Fontanet
471fbef6ef chore: hide USAGE.md
This highlight the fact that it's not designed for direct consumption and it no longer needs a special handling in `npmignore`.
2022-02-18 17:11:52 +01:00
Julien Fontanet
ab63709104 chore(predicates): add tests 2022-02-18 17:03:21 +01:00
Julien Fontanet
0924184358 fix(predicates): use strict mode 2022-02-18 17:03:21 +01:00
Julien Fontanet
6e38cf2bc1 fix(predicates): typo 2022-02-18 17:03:21 +01:00
Pierre Donias
2183422eb5 docs(users/auth-google): update doc with new screens (#6118)
See zammad#5306
2022-02-18 15:49:33 +01:00
Mathieu
3842f5b16d fix(Backup/FileRestore): hide unsupported S3 backups (#6116)
Fixes https://xcp-ng.org/forum/post/46166
2022-02-18 11:07:30 +01:00
Julien Fontanet
1dad6b37ef feat(xo-server): pass backup network address to proxy
Fixes zammad#4836
2022-02-16 18:38:48 +01:00
Julien Fontanet
7023db2264 chore: update dev deps 2022-02-16 14:55:16 +01:00
Julien Fontanet
bf194f5c85 feat(xo-server): add supportFileRestore prop to remote objects
Related to #6116
2022-02-14 14:23:54 +01:00
Julien Fontanet
bcdaa37f8a feat(backups/VmBackup#_callWriters): integrate sub-errors in logs
Fixes zammad#5264
2022-02-14 11:22:32 +01:00
Julien Fontanet
a5f8900d23 chore(CHANGELOG.unreleased): add changes for 3c684c7f4 2022-02-14 11:09:56 +01:00
Julien Fontanet
3c684c7f45 fix(xo-server): use pool.uuid/template.uuid for default templates instead of refs
Fixes https://help.vates.fr/#ticket/zoom/5221

Opaque refs are not persistent and should not be used as ids (e.g. resource sets in database).
2022-02-14 10:15:30 +01:00
Julien Fontanet
cd0f4baa15 fix(xo-server/docs): fix REST API path 2022-02-12 11:33:02 +01:00
Julien Fontanet
58f3050344 feat(xo-server/rest-api): add root collection 2022-02-12 11:32:38 +01:00
Julien Fontanet
ab110bb0df feat(xo-server/rest-api): add hosts, pools & SRs 2022-02-10 17:09:42 +01:00
Julien Fontanet
636025c1b9 chore(xo-server/rest-api): use @vates/predicates 2022-02-10 17:05:55 +01:00
Julien Fontanet
c28fa78963 feat(@vates/predicates): utils to compose predicates 2022-02-10 16:55:15 +01:00
Julien Fontanet
ecb66fb9f3 feat(xo-server): first endpoints of the beta REST API 2022-02-09 23:43:21 +01:00
Julien Fontanet
f8e4192d34 feat(xo-cli): --createToken command 2022-02-09 17:13:18 +01:00
Julien Fontanet
3d15cd57c4 chore: remove pump dep 2022-02-09 14:52:37 +01:00
Julien Fontanet
2e633f0df4 fix(xo-cli): support allowUnauthorized for $sendTo/$getFrom 2022-02-09 14:49:25 +01:00
Julien Fontanet
833b814fd5 fix(xo-cli): dont use deprecated http.resolve 2022-02-09 14:40:47 +01:00
Julien Fontanet
da52d905b6 chore(xo-cli): remove bluebird dep 2022-02-09 14:39:54 +01:00
Julien Fontanet
a2054c24d8 chore(xo-cli): remove mkdirp dep 2022-02-09 14:13:51 +01:00
Julien Fontanet
599db80467 chore: remove l33teral dep 2022-02-09 14:08:24 +01:00
Julien Fontanet
6075a3307e feat(xo-server): announce appliance in pool.other_config (#6115)
It will be used by XO Lite to list available XOs on the pool.
2022-02-09 11:29:01 +01:00
Julien Fontanet
9af06996c0 fix(backups/merge-worker): handle ENAMETOOLONG errors
Related to https://xcp-ng.org/forum/post/46424
2022-02-09 10:18:05 +01:00
Julien Fontanet
72c386cdce fix(backups/merge-worker): ignore missing VM dir
Fixes https://xcp-ng.org/forum/post/46578
2022-02-09 10:11:07 +01:00
Julien Fontanet
f6d4771603 feat(xen-api/barrier): remove stale entries 2022-02-07 16:21:02 +01:00
Julien Fontanet
15d06c591e chore: remove unnecessary strip-indent dep 2022-02-02 12:36:28 +01:00
Julien Fontanet
0a07765027 chore: update deps 2022-02-02 12:35:06 +01:00
Julien Fontanet
81e0d06604 chore: update to eslint-config-standard@-jsx@11.0.0-0
Follow up of 767762064
2022-02-01 10:03:15 +01:00
Julien Fontanet
809314e516 feat: release 5.67.0 2022-01-31 13:41:24 +01:00
Julien Fontanet
cbe37b2ccd feat(xo-server-audit): 0.9.2 2022-01-28 18:19:56 +01:00
Julien Fontanet
14fcbb6b8b chore: format with Prettier 2022-01-28 15:55:35 +01:00
Julien Fontanet
bac976144e chore: lint fixes 2022-01-28 15:55:35 +01:00
Julien Fontanet
7677620645 chore: update to ESLint@8
Brings the (private) class fields support, which is getting more and more used in XO.
2022-01-28 15:55:35 +01:00
Mathieu
c8597bd363 fix(xo-server-audit/getRecords): limit number of records returned (#6113) 2022-01-28 15:46:56 +01:00
Julien Fontanet
899be12418 feat(CHANGELOG): integrate released changes 2022-01-27 14:44:54 +01:00
Julien Fontanet
31975b6737 feat(xo-web): 5.92.0 2022-01-27 14:27:48 +01:00
Julien Fontanet
315549e588 feat(xo-server): 5.87.0 2022-01-27 14:25:20 +01:00
Julien Fontanet
457886d538 feat(xo-server-audit): 0.9.1 2022-01-27 14:25:00 +01:00
Julien Fontanet
8d02b206e0 feat(@xen-orchestra/proxy): 0.18.0 2022-01-27 14:24:23 +01:00
Julien Fontanet
45e5b94b4f feat(xo-vmdk-to-vhd): 2.1.0 2022-01-27 14:23:53 +01:00
Julien Fontanet
ec866b4a61 fix(xo-server-audit): dont log proxy.getApplianceUpdaterState calls
Fix zammad#4753
2022-01-27 14:17:36 +01:00
Mathieu
2e8e2522e5 feat(xo-web/dashboard/health): show pools with no default SR (#6083)
See zammad#4640
2022-01-26 11:20:56 +01:00
Julien Fontanet
96bd46c3a8 fix(xo-web): fix number of VMs when running a backup
Following aa27b3be6
2022-01-25 15:30:58 +01:00
Julien Fontanet
797ed9ac51 fix(xo-server/backups): fix VMs matching
Introduced by aa27b3be6

Fixes https://xcp-ng.org/forum/topic/5473/backup-broken
2022-01-25 15:29:06 +01:00
Julien Fontanet
7089dcddff chore: update dev deps 2022-01-25 09:38:00 +01:00
Julien Fontanet
8ee93dfe9c feat(@xen-orchestra/backups-cli): 0.7.0 2022-01-24 22:35:08 +01:00
Julien Fontanet
88f160820f feat(@xen-orchestra/backups): 0.19.0 2022-01-24 22:34:02 +01:00
Julien Fontanet
b61b3e75c1 feat(vhd-lib): 3.1.0 2022-01-24 22:33:16 +01:00
Julien Fontanet
a1bac51f7b feat(@xen-orchestra/fs): 0.20.0 2022-01-24 22:31:39 +01:00
Julien Fontanet
fa986fb4cb fix(proxy/ReverseProxy): dont 404 non proxy URLs
Introduced by b78a94645
2022-01-24 22:21:18 +01:00
Julien Fontanet
aa27b3be64 fix(backups): dont ignore restored VMs
Fixes zammad#4794

Introduced by cf9f0da6e

Check that the `start` operation is blocked which is the case for replicated VMs but (should) not for restored backups.
2022-01-24 17:11:48 +01:00
Florent Beauchamp
97d94b7952 feat(vhd-lib): merge blocks in parallel for VhdDirectory, throttle mergestate writes 2022-01-24 10:37:34 +01:00
Florent Beauchamp
96eb793298 feat(fs): s3#rmtree parallelize object deletion 2022-01-24 10:37:34 +01:00
Florent Beauchamp
b4f15de7be feat(fs): s3#copy don't use multi part copy for objects smaller than 5GB 2022-01-24 10:37:34 +01:00
Mathieu
ae5726b836 fix(xo-server-audit/generateFingerprint): handle the case when db is empty (#6071)
Fixes #6040
2022-01-21 12:47:56 +01:00
Florent BEAUCHAMP
692e72a78a fix(vhd-lib): fixes asserts on existing merge state (#6099)
Introduced by 5a933bad9
2022-01-21 12:40:45 +01:00
Pierre Donias
ff24364bb6 fix(CHANGELOG): fix and homogenize changelog (#6102) 2022-01-20 15:40:49 +01:00
Florent BEAUCHAMP
b60a1958b6 fix(fs#S3#{list,rmtree}): fix support of more than 1000 files (#6103)
Bug found when working on #6100
2022-01-20 14:31:13 +01:00
Florent Beauchamp
f6a2b505db feat(backups): execute cleanup on each related vm dir after a backup deletion 2022-01-19 10:46:15 +01:00
Florent Beauchamp
38aacdbd7d feat(xo-web): delete all the backups at once and let xo-server handle the cleanup 2022-01-19 10:46:15 +01:00
Florent Beauchamp
089b877cc5 fix(backups): use handler.unlink for deleting metadat instead of VhdAbstract.unlink 2022-01-19 10:46:15 +01:00
Julien Fontanet
81e55dcf77 fix(backups/listAllVmBackups): ignore empty dirs 2022-01-19 10:43:00 +01:00
Julien Fontanet
58dd44bf5d fix(backups/listAllVmBackups): ignore hidden and lock files 2022-01-19 10:41:20 +01:00
Julien Fontanet
3aa6669fd9 chore(vhd-lib): move alias utils to aliases submodule
Introduced in e15be7ebd
2022-01-18 15:33:31 +01:00
Florent BEAUCHAMP
c10601d905 fix(backups/_MixinBackupWriter#afterBackup): execute merge on S3 (#6095)
Introduced by 47f9da216
2022-01-18 11:05:55 +01:00
Florent BEAUCHAMP
e15be7ebd3 fix(backups/_cleanVm): fixes for aliases cleaning (#6094)
Introduced in 249f638495
2022-01-18 10:07:56 +01:00
Julien Fontanet
b465a91cd3 fix(value-matcher/README): __all → __and 2022-01-18 08:58:24 +01:00
Julien Fontanet
f304a46bea fix(vhd-lib/VhdDirectory): missing readChunkFilters in readHeaderAndFooter
Introduced by 249f63849
2022-01-17 10:18:54 +01:00
Pierre Donias
6756faa1cc feat(xo-server,xo-web): disable Load Balancer during Rolling Pool Update (#6089)
Fixes #5711
Follow-up of #6057
2022-01-17 10:08:32 +01:00
Julien Fontanet
73fd7c7d54 fix(backups/_cleanVm): temporary disable aliases checking 2022-01-17 09:52:42 +01:00
Julien Fontanet
60eda9ec69 chore(vhd-lib): remove contentVhdStreamWithLength export from main module 2022-01-16 22:44:41 +01:00
Julien Fontanet
a979c29a15 chore(vhd-lib): remove createReadableRawStream
Use `VhdAbstract#rawContent()` instead.
2022-01-16 22:34:04 +01:00
Julien Fontanet
8f25082917 fix(xo-vmdk-to-vhd): avoid requiring whole vhd-lib
Introduced by 9375b1c8b

Fixes #6093
2022-01-16 22:31:38 +01:00
Nicolas Raynaud
9375b1c8bd feat: support VDI export in VMDK (#5982)
Co-authored-by: Rajaa.BARHTAOUI <rajaa.barhtaoui@gmail.com>
Co-authored-by: Julien Fontanet <julien.fontanet@isonoe.net>
Co-authored-by: Florent BEAUCHAMP <flo850@free.fr>
2022-01-16 18:40:08 +01:00
Julien Fontanet
422a22a767 chore: update dev deps 2022-01-14 14:51:38 +01:00
Florent BEAUCHAMP
249f638495 feat(backups/_cleanVm): check VHD aliases (#6043) 2022-01-13 16:07:28 +01:00
Florent BEAUCHAMP
6cf5e10195 feat(fs/S3#_writeFile): retry on remote internal error (#6086) 2022-01-13 15:46:12 +01:00
Florent BEAUCHAMP
b78a946458 feat(proxy): implement reverse proxies (#6072) 2022-01-13 14:54:10 +01:00
Julien Fontanet
e8a5694d51 feat(backups/_cleanVm): clean orphan mergeState (#6087)
Fixes zammad#4778
2022-01-13 10:41:39 +01:00
Julien Fontanet
514fa72ee2 fix(package.json/jest): vhd-lib no longer has a build step
Introduced by 3a74c71f1
2022-01-12 22:50:49 +01:00
Julien Fontanet
e9ca13aa12 fix(backups/cleanVm): handle zstd-compressed XVAs
Related to zammad#4300
2022-01-12 11:31:09 +01:00
Julien Fontanet
57f1ec6716 chore(backups/_cleanVm/listVhds): make vhds directly a Set 2022-01-11 15:31:56 +01:00
Julien Fontanet
02e32cc9b9 chore(backups/_cleanVm/listVhds): minor simplification
This also removes the incorrect handling of an optional dir in `INTERRUPTED_VHDS_REG`.
2022-01-11 15:09:18 +01:00
Julien Fontanet
902abd5d94 chore: update deps 2022-01-06 13:59:31 +01:00
Julien Fontanet
53380802ec feat(xo-server): limit VM migration concurrency (#6076)
Related to #6065
2022-01-06 09:32:42 +01:00
Julien Fontanet
af5d8d02b6 feat: release 5.66.2 2022-01-05 11:30:29 +01:00
Julien Fontanet
7abba76f03 feat(CHANGELOG): integrate released changes 2022-01-05 10:36:05 +01:00
Julien Fontanet
79b22057d9 feat(xo-web): 5.91.2 2022-01-05 10:34:30 +01:00
Julien Fontanet
366daef718 feat(xo-server): 5.86.3 2022-01-05 10:33:30 +01:00
Julien Fontanet
a5ff0ba799 feat(@xen-orchestra/proxy): 0.17.3 2022-01-05 10:32:42 +01:00
Julien Fontanet
c2c6febb88 feat(@xen-orchestra/backups): 0.18.3 2022-01-05 10:18:02 +01:00
Julien Fontanet
f119c72a7f feat(xo-vmdk-to-vhd): 2.0.3 2022-01-05 10:16:47 +01:00
Julien Fontanet
8aee897d23 feat(vhd-lib): 3.0.0 2022-01-05 10:15:45 +01:00
Florent BEAUCHAMP
729db5c662 fix(backups): race condition in checkBaseVdi preventing delta backup (#6075)
Fixes zammad#4751, zammad#4729, zammad#4665 and zammad#4300
2022-01-05 09:58:06 +01:00
Julien Fontanet
61c46df7bf chore(xo-server): dont pass (unused) httpServer to app 2022-01-03 16:04:18 +01:00
Julien Fontanet
9b1a04338d chore(xo-server): attach express before creating app 2022-01-03 15:46:30 +01:00
Julien Fontanet
d307134d22 chore(xapi/_assertHealthyVdiChain): clearer warnings in case of missing VDI 2021-12-28 18:14:32 +01:00
Julien Fontanet
5bc44363f9 fix(xo-vmdk-to-vhd): fix createReadableSparseStream import
Introduced by 3a74c71f1

Fixes #6068
2021-12-23 23:40:58 +01:00
Julien Fontanet
68c4fac3ab chore: update deps 2021-12-23 13:25:48 +01:00
Julien Fontanet
6ad9245019 feat: release 5.66.1 2021-12-23 13:25:08 +01:00
Julien Fontanet
763cf771fb feat(CHANGELOG): integrate released changes 2021-12-23 12:18:50 +01:00
Julien Fontanet
3160b08637 feat(xo-web): 5.91.1 2021-12-23 12:18:14 +01:00
Julien Fontanet
f8949958a3 feat(xo-server): 5.86.2 2021-12-23 12:17:54 +01:00
Julien Fontanet
8b7ac07d2d feat(@xen-orchestra/proxy): 0.17.2 2021-12-23 12:17:25 +01:00
Julien Fontanet
044df9adba feat(@xen-orchestra/backups): 0.18.2 2021-12-23 12:16:53 +01:00
Julien Fontanet
040139f4cc fix(backups/cleanVm): computeVhdSize can return undefined 2021-12-23 12:09:11 +01:00
Julien Fontanet
7b73bb9df0 chore: format with Prettier 2021-12-23 12:06:11 +01:00
Julien Fontanet
24c8370daa fix(xo-server-test): add missing ESLint config 2021-12-23 11:58:14 +01:00
Julien Fontanet
029c4921d7 fix(backups/RemoteAdapter#isMergeableParent): #useVhdDirectory is a function (#6070)
Fixes zammad#4646
Fixes https://xcp-ng.org/forum/topic/5371/delta-backup-changes-in-5-66

Introduced by 5d605d1bd
2021-12-23 11:57:51 +01:00
Julien Fontanet
3a74c71f1a chore(vhd-lib): remove build step
BREAKING:
- removes `dist/` in the path of sub-modules
- requires Node >=12
2021-12-23 10:31:29 +01:00
Julien Fontanet
6022a1bbaa feat(normalize-packages): delete unused Babel configs 2021-12-23 09:26:00 +01:00
Julien Fontanet
4e88c993f7 chore: update dev deps 2021-12-22 11:07:25 +01:00
Julien Fontanet
c9a61f467c fix(xo-web/Dashboard/Health): handle no default_SR
Fixes zammad#4640

Introduced by 7bacd781c
2021-12-22 10:33:18 +01:00
Julien Fontanet
e6a5f42f63 feat: release 5.66.0 2021-12-21 18:00:39 +01:00
Julien Fontanet
a373823eea feat(xo-server): 5.86.1 2021-12-21 17:58:02 +01:00
Julien Fontanet
b5e010eac8 feat(@xen-orchestra/proxy): 0.17.1 2021-12-21 17:57:47 +01:00
Julien Fontanet
50ffe58655 feat(@xen-orchestra/backups): 0.18.1 2021-12-21 17:56:55 +01:00
Julien Fontanet
07eb3b59b3 feat(@xen-orchestra/mixins): 0.1.2 2021-12-21 17:56:52 +01:00
Julien Fontanet
5177b5e142 chore(backups/RemoteAdapter): remove default value for vhdDirectoryCompression
Introduced by 3c984e21c
2021-12-21 17:51:23 +01:00
Julien Fontanet
3c984e21cd fix({proxy,xo-server}): add backup.vhdDirectoryCompression setting
Introduced by 5d605d1bd
2021-12-21 17:49:43 +01:00
Julien Fontanet
aa2b27e22b fix(mixins/Config#get): fix missing entry error message 2021-12-21 17:37:07 +01:00
Julien Fontanet
14a7f00c90 chore(CHANGELOG): remove non-breakable spaces 2021-12-21 17:31:51 +01:00
Julien Fontanet
56f98601bd feat(CHANGELOG): integrate released changes 2021-12-21 17:24:19 +01:00
Julien Fontanet
027a8c675e feat(@xen-orchestra/proxy): 0.17.0 2021-12-21 17:22:29 +01:00
Julien Fontanet
bdaba9a767 feat(xo-server): 5.86.0 2021-12-21 17:22:07 +01:00
Julien Fontanet
4e9090f60d feat(@xen-orchestra/backups): 0.18.0 2021-12-21 17:21:37 +01:00
Julien Fontanet
73b445d371 feat(xo-vmdk-to-vhd): 2.0.2 2021-12-21 17:21:10 +01:00
Julien Fontanet
75bfc283af feat(vhd-lib): 2.1.0 2021-12-21 17:20:36 +01:00
Julien Fontanet
727de19b89 feat(@xen-orchestra/xapi): 0.8.5 2021-12-21 17:20:06 +01:00
Florent BEAUCHAMP
5d605d1bd7 feat(backups): compress VHDs on S3 (#5932) 2021-12-21 17:18:27 +01:00
Julien Fontanet
ffdd1dfd6f fix(xo-vmdk-to-vhd): avoid requiring whole vhd-lib
This library is used in the browser and a lot of parts of `vhd-lib` are not intended to be used in (or bundled for) the browser.
2021-12-21 17:10:33 +01:00
Julien Fontanet
d45418eb29 fix(backups/cleanVm): metadata.vhds is an object, not an array
Introduced by 93069159d
2021-12-21 16:23:03 +01:00
Julien Fontanet
6ccc9d1ade fix(xapi/VM_create): support NVRAM field (#6062)
Fixes #6054
Fixes https://xcp-ng.org/forum/topic/5319/bug-uefi-boot-parameters-not-preserved-with-delta-backups
2021-12-20 16:30:41 +01:00
Florent BEAUCHAMP
93069159dd fix(backups/cleanVm): don't warn on size change due to merged VHDs (#6010) 2021-12-20 14:57:54 +01:00
Julien Fontanet
8c4780131f feat: release 5.65.3 2021-12-20 10:50:51 +01:00
Julien Fontanet
02ae8bceda fix(backups/cleanVm): dont fail on broken metadata 2021-12-20 09:49:27 +01:00
Julien Fontanet
bb10bbc945 chore(backups/cleanVm): remove deleted files from jsons 2021-12-20 09:46:09 +01:00
Florent BEAUCHAMP
478d88e97f fix(fs/s3#_rmtree): infinite loop (#6067) 2021-12-17 16:01:57 +01:00
Florent BEAUCHAMP
6fb397a729 fix(vhd-lib): parseVhdStream int overflow when rebuilding the bat (#6066)
BAT should contain sector address, not byte address

We were not really rebuilding the BAT, since we were using the data read in the old bat and write it as is in the new one
2021-12-17 14:28:48 +01:00
Julien Fontanet
18dae34778 feat(vhd-lib/parseVhdStream): new public method (#6063)
Extracted from `createVhdDirectoryFromStream`

Co-authored-by: Florent Beauchamp <flo850@free.fr>
2021-12-17 10:08:29 +01:00
Julien Fontanet
243566e936 fix(xen-api): named import for @vates/coalesce-calls
Introduced by 87f4fd675
2021-12-16 14:00:49 +01:00
Julien Fontanet
87f4fd675d fix(xen-api): fix coalesceCalls
Introduced by dec6b59a9
2021-12-16 13:26:31 +01:00
Julien Fontanet
dec6b59a9f chore(xen-api): use @vates/coalesce-calls 2021-12-16 12:03:07 +01:00
Rajaa.BARHTAOUI
e51baedf7f feat: technical release (#6060) 2021-12-16 12:01:57 +01:00
Julien Fontanet
530da14e24 feat(@vates/decorate-with): 1.0.0 2021-12-16 11:49:29 +01:00
Julien Fontanet
02da7c272f feat(decorate-with): perInstance helper 2021-12-16 11:48:48 +01:00
Pierre Donias
a07c5418e9 feat(xo-server,xo-web): disable HA during Rolling Pool Update (#6057)
See #5711
2021-12-16 10:29:13 +01:00
Mathieu
c080db814b feat(xo-web/home/backed up VMs): filter out VMs in disabled backup jobs (#6037)
See xoa-support#4294
2021-12-16 10:06:45 +01:00
Julien Fontanet
3abe13c006 chore(backups/RemoteAdapter#deleteVmBackups): report unsupported backup modes
It was removed in 7e302fd1c
2021-12-16 10:05:08 +01:00
Julien Fontanet
fb331c0a2c fix(backups/RemoteAdapter#deleteVmBackups): dont delete undefined
Fixes https://xcp-ng.org/forum/topic/5331/backup-smart-mode-broken/6
Introduced by 7e302fd1c
2021-12-16 10:03:16 +01:00
Julien Fontanet
19ea78afc5 fix(xo-server): fix job matching for smart mode
Fixes https://xcp-ng.org/forum/topic/5331/backup-smart-mode-broken
Fixes #6058

Introduced by cf9f0da6e

XO VM objects have a `other` field instead of `other_config`.
2021-12-15 23:25:04 +01:00
Julien Fontanet
2096c782e3 feat(xo-server/api): new method backupNg.deleteVmBackups
Related to 7e302fd1c
2021-12-15 17:36:47 +01:00
Julien Fontanet
79a6a8a10c feat(proxy/api): new method backup.deleteVmBackups
Related to 7e302fd1c
2021-12-15 17:27:08 +01:00
Julien Fontanet
5a933bad93 fix(vhd-lib/merge): dont fail on invalid state file
Fixes zammad#4227
2021-12-15 16:36:18 +01:00
Julien Fontanet
7e302fd1cb feat(backups/RemoteAdapter): new method deleteVmBackups()
It's usually best to delete multiple backups at once instead of one by one because it allows some optimizations, for instance when merging unused VHDs.

This was already possible in private methods but not exposed in the public API.
2021-12-15 16:34:35 +01:00
Julien Fontanet
cf9f0da6e5 fix(backups): ignore VMs created by current job
See xoa-support#4271
2021-12-14 12:07:51 +01:00
Pierre Donias
10ac23e265 feat(docs/Netbox): specify minimum required permissions (#6047)
See https://xcp-ng.org/forum/topic/5300/
2021-12-14 11:48:19 +01:00
Rajaa.BARHTAOUI
dc2e1cba1f feat(xo-web/pool,VM/advanced): ability to set suspend SR (#6044)
Fixes #4163
2021-12-14 10:13:11 +01:00
Julien Fontanet
7bfd190c22 fix(backups/_VmBackup): no base VM when no base VDIs found
Introduced by 5b188f35b
2021-12-13 17:55:54 +01:00
Manon Mercier
c3bafeb468 fix(docs/xoa): must reboot after changing password (#6056)
Co-authored-by: Jon Sands <fohdeesha@gmail.com>
2021-12-13 17:48:14 +01:00
Mathieu
7bacd781cf feat(xo-web/health): display non shared default SRs (#6033)
Fixes #5871
2021-12-13 10:00:24 +01:00
Julien Fontanet
ee005c3679 fix(xo-server-usage-report): csv-stringify usage
Fixes #6053

Introduced by b179dc1d5
2021-12-13 09:39:00 +01:00
Florent BEAUCHAMP
315f54497a fix(vhd-lib/resolveAlias): limit size (#6004)
Current resolution loads whole file in memory. It can lead to crash is the alias is malformed (for example a full VHD named `.alias.vhd`).
2021-12-12 14:19:40 +01:00
Julien Fontanet
e30233347b feat: release 5.65.2 2021-12-10 17:19:54 +01:00
Julien Fontanet
56d4a7f01e fix(xo-web/about): show commit iff available & always versions
Fixes #6052
2021-12-10 16:40:26 +01:00
Julien Fontanet
7c110eebd8 feat(CHANGELOG): integrate released changes 2021-12-10 12:06:26 +01:00
Julien Fontanet
39394f8c09 feat(@xen-orchestra/proxy): 0.15.5 2021-12-10 12:04:33 +01:00
Julien Fontanet
3283130dfc feat(xo-server): 5.84.3 2021-12-10 12:04:33 +01:00
Julien Fontanet
3146a591d0 feat(@xen-orchestra/backups): 0.16.2 2021-12-10 12:04:30 +01:00
Julien Fontanet
e478b1ec04 feat(vhd-lib): 2.0.3 2021-12-10 12:04:00 +01:00
Julien Fontanet
7bc4d14f46 feat(@xen-orchestra/fs): 0.19.2 2021-12-10 11:38:20 +01:00
Florent BEAUCHAMP
f3eeeef389 fix(fs/S3#list): should not look into all the file tree (#6048) 2021-12-09 14:06:21 +01:00
Florent BEAUCHAMP
8d69208197 fix(backups/MixinBackupWriter#_cleanVm): always returns an object (#6050) 2021-12-09 10:38:31 +01:00
Julien Fontanet
2c689af1a9 fix(backups): add random suffixes to task files to avoid collitions
See https://xcp-ng.org/forum/post/44661
2021-12-08 18:03:13 +01:00
Julien Fontanet
cb2a34c765 feat(backups/RemoteAdapter#cleanVm): show missing VHDs
Related to investigation on zammad#4156
2021-12-08 11:41:18 +01:00
Julien Fontanet
465c8f9009 feat(xo-web/about): show build commit in sources version (#6045) 2021-12-08 09:57:15 +01:00
Florent BEAUCHAMP
8ea4c1c1fd fix(vhd-lib): output parent locator in VhdAbstract#stream (#6035) 2021-12-07 14:14:39 +01:00
Julien Fontanet
ba0f7df9e8 feat(xapi-explore-sr): 0.4.1 2021-12-06 17:59:27 +01:00
Julien Fontanet
e47dd723b0 fix(xapi-explore-sr): add missing @xen-orchestra/defined dep
Introduced by 2412f8b1e
2021-12-06 17:43:47 +01:00
Julien Fontanet
fca6e2f6bf fix(fs/S3#_list): throw if result is truncated 2021-12-06 14:25:55 +01:00
Florent BEAUCHAMP
faa7ba6f24 fix(vhd-lib, fs): use rmtree and not rmTree (#6041) 2021-12-06 14:25:09 +01:00
Julien Fontanet
fc2dbbe3ee feat: release 5.65.1 2021-12-03 16:42:11 +01:00
Julien Fontanet
cc98b81825 fix(CHANGELOG): incorrect secion name Packages to release
Introduced in ae24b10da
2021-12-03 15:29:48 +01:00
Julien Fontanet
eb4a7069d4 feat(CHANGELOG): integrate released changes 2021-12-03 15:27:54 +01:00
Julien Fontanet
4f65d9214e feat(xo-server): 5.84.2 2021-12-03 15:23:59 +01:00
Julien Fontanet
4d3c8ee63c feat(@xen-orchestra/proxy): 0.15.4 2021-12-03 15:23:26 +01:00
Julien Fontanet
e41c1b826a feat(@xen-orchestra/backups): 0.16.1 2021-12-03 15:23:02 +01:00
Julien Fontanet
644bb48135 feat(xo-vmdk-to-vhd): 2.0.1 2021-12-03 15:22:23 +01:00
Julien Fontanet
c9809285f6 feat(vhd-lib): 2.0.2 2021-12-03 15:19:07 +01:00
Julien Fontanet
5704949f4d feat(@vates/compose): 2.1.0 2021-12-03 15:17:47 +01:00
Julien Fontanet
a19e00fbc0 fix(backups/_VmBackup#_selectBaseVm): cant read .uuid of undefined srcVdi (#6034)
See xoa-support#4263

The debug message is now clearer and has correct associated data.
2021-12-03 10:22:17 +01:00
Julien Fontanet
470a9b3e27 chore(decorate-with/README): document usage with @vates/compose 2021-12-02 21:37:25 +01:00
Julien Fontanet
ace31dc566 feat(compose): supports attaching extra params 2021-12-02 21:37:25 +01:00
Julien Fontanet
ed252276cb fix(compose): dont mutate passed functions array 2021-12-02 21:37:25 +01:00
Julien Fontanet
26d0ff3c9a fix(vhd-lib/VhdAbtract#stream): explicitely ignore differencing
Because parentLocator entries handling are broken.
2021-12-02 16:48:19 +01:00
Florent Beauchamp
ff806a3ff9 fix(vhd-lib): use parent locator of root disk in VhdSynthetic 2021-12-02 16:48:19 +01:00
Florent Beauchamp
949b17dee6 fix(vhd-lib): fix footer and header accessor in vhd hierarchy 2021-12-02 16:48:19 +01:00
Florent Beauchamp
b1fdc68623 fix(vhd-lib): platformDataSpace in sectors not bytes 2021-12-02 16:48:19 +01:00
Florent BEAUCHAMP
f502facfd1 fix(backup): createAlias to data instead of circular alias (#6029) 2021-12-02 13:56:20 +01:00
Mathieu
bf0a74d709 fix(xo-web/SortedTable): properly disable collapsed actions (#6023) 2021-12-02 13:48:22 +01:00
538 changed files with 15201 additions and 5255 deletions

View File

@@ -1,5 +1,7 @@
'use strict'
module.exports = {
extends: ['plugin:eslint-comments/recommended', 'standard', 'standard-jsx', 'prettier'],
extends: ['plugin:eslint-comments/recommended', 'plugin:n/recommended', 'standard', 'standard-jsx', 'prettier'],
globals: {
__DEV__: true,
$Dict: true,
@@ -15,11 +17,40 @@ module.exports = {
{
files: ['cli.{,c,m}js', '*-cli.{,c,m}js', '**/*cli*/**/*.{,c,m}js'],
rules: {
'n/no-process-exit': 'off',
'no-console': 'off',
},
},
{
files: ['*.mjs'],
parserOptions: {
sourceType: 'module',
},
},
{
files: ['*.spec.{,c,m}js'],
rules: {
'n/no-unsupported-features/node-builtins': [
'error',
{
version: '>=16',
},
],
'n/no-unsupported-features/es-syntax': [
'error',
{
version: '>=16',
},
],
},
},
],
parserOptions: {
ecmaVersion: 13,
sourceType: 'script',
},
rules: {
// disabled because XAPI objects are using camel case
camelcase: ['off'],
@@ -34,5 +65,7 @@ module.exports = {
'lines-between-class-members': 'off',
'no-console': ['error', { allow: ['warn', 'error'] }],
strict: 'error',
},
}

View File

@@ -1,16 +0,0 @@
[ignore]
<PROJECT_ROOT>/node_modules/.*
[include]
[libs]
[lints]
[options]
esproposal.decorators=ignore
esproposal.optional_chaining=enable
include_warnings=true
module.use_strict=true
[strict]

View File

@@ -4,14 +4,26 @@ about: Create a report to help us improve
title: ''
labels: 'status: triaging :triangular_flag_on_post:, type: bug :bug:'
assignees: ''
---
**XOA or XO from the sources?**
If XOA:
- which release channel? (`stable` vs `latest`)
- please consider creating a support ticket in [your dedicated support area](https://xen-orchestra.com/#!/member/support)
If XO from the sources:
- Don't forget to [read this first](https://xen-orchestra.com/docs/community.html)
- As well as follow [this guide](https://xen-orchestra.com/docs/community.html#report-a-bug)
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
@@ -23,11 +35,12 @@ A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- Node: [e.g. 16.12.1]
- xo-server: [e.g. 5.82.3]
- xo-web: [e.g. 5.87.0]
- hypervisor: [e.g. XCP-ng 8.2.0]
**Environment (please provide the following information):**
- Node: [e.g. 16.12.1]
- xo-server: [e.g. 5.82.3]
- xo-web: [e.g. 5.87.0]
- hypervisor: [e.g. XCP-ng 8.2.0]
**Additional context**
Add any other context about the problem here.

13
.github/workflows/push.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
name: CI
on: [push]
jobs:
build:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: satackey/action-docker-layer-caching@v0.0.11
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
- run: docker-compose -f docker/docker-compose.dev.yml build
- run: docker-compose -f docker/docker-compose.dev.yml up

7
.gitignore vendored
View File

@@ -1,5 +1,4 @@
/_book/
/coverage/
/node_modules/
/lerna-debug.log
/lerna-debug.log.*
@@ -11,8 +10,6 @@
/packages/*/dist/
/packages/*/node_modules/
/@xen-orchestra/proxy/src/app/mixins/index.mjs
/packages/vhd-cli/src/commands/index.js
/packages/xen-api/examples/node_modules/
@@ -35,3 +32,7 @@ pnpm-debug.log.*
yarn-error.log
yarn-error.log.*
.env
# code coverage
.nyc_output/
coverage/

View File

@@ -1,23 +0,0 @@
language: node_js
node_js:
- 14
# Use containers.
# http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false
addons:
apt:
packages:
- qemu-utils
- blktap-utils
- vmdk-stream-converter
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
cache:
yarn: true
script:
- yarn run travis-tests

View File

@@ -1,3 +1,5 @@
'use strict'
exports.coalesceCalls = function (fn) {
let promise
const clean = () => {

View File

@@ -1,3 +1,5 @@
'use strict'
/* eslint-env jest */
const { coalesceCalls } = require('./')

View File

@@ -46,3 +46,20 @@ const f = compose(
[add2, mul3]
)
```
Functions can receive extra parameters:
```js
const isIn = (value, min, max) => min <= value && value <= max
// Only compatible when `fns` is passed as an array!
const f = compose([
[add, 2],
[isIn, 3, 10],
])
console.log(f(1))
// → true
```
> Note: if the first function is defined with extra parameters, it will only receive the first value passed to the composed function, instead of all the parameters.

View File

@@ -65,6 +65,23 @@ const f = compose(
)
```
Functions can receive extra parameters:
```js
const isIn = (value, min, max) => min <= value && value <= max
// Only compatible when `fns` is passed as an array!
const f = compose([
[add, 2],
[isIn, 3, 10],
])
console.log(f(1))
// → true
```
> Note: if the first function is defined with extra parameters, it will only receive the first value passed to the composed function, instead of all the parameters.
## Contributions
Contributions are _very_ welcomed, either on the documentation or on

View File

@@ -4,11 +4,13 @@ const defaultOpts = { async: false, right: false }
exports.compose = function compose(opts, fns) {
if (Array.isArray(opts)) {
fns = opts
fns = opts.slice() // don't mutate passed array
opts = defaultOpts
} else if (typeof opts === 'object') {
opts = Object.assign({}, defaultOpts, opts)
if (!Array.isArray(fns)) {
if (Array.isArray(fns)) {
fns = fns.slice() // don't mutate passed array
} else {
fns = Array.prototype.slice.call(arguments, 1)
}
} else {
@@ -20,6 +22,24 @@ exports.compose = function compose(opts, fns) {
if (n === 0) {
throw new TypeError('at least one function must be passed')
}
for (let i = 0; i < n; ++i) {
const entry = fns[i]
if (Array.isArray(entry)) {
const fn = entry[0]
const args = entry.slice()
args[0] = undefined
fns[i] = function composeWithArgs(value) {
args[0] = value
try {
return fn.apply(this, args)
} finally {
args[0] = undefined
}
}
}
}
if (n === 1) {
return fns[0]
}

View File

@@ -1,3 +1,5 @@
'use strict'
/* eslint-env jest */
const { compose } = require('./')

View File

@@ -14,7 +14,7 @@
"url": "https://vates.fr"
},
"license": "ISC",
"version": "2.0.0",
"version": "2.1.0",
"engines": {
"node": ">=7.6"
},

View File

@@ -0,0 +1,86 @@
### `decorateWith(fn, ...args)`
Creates a new ([legacy](https://babeljs.io/docs/en/babel-plugin-syntax-decorators#legacy)) method decorator from a function decorator, for instance, allows using Lodash's functions as decorators:
```js
import { decorateWith } from '@vates/decorate-with'
class Foo {
@decorateWith(lodash.debounce, 150)
bar() {
// body
}
}
```
### `decorateClass(class, map)`
Decorates a number of accessors and methods directly, without using the decorator syntax:
```js
import { decorateClass } from '@vates/decorate-with'
class Foo {
get bar() {
// body
}
set bar(value) {
// body
}
baz() {
// body
}
}
decorateClass(Foo, {
// getter and/or setter
bar: {
// without arguments
get: lodash.memoize,
// with arguments
set: [lodash.debounce, 150],
},
// method (with or without arguments)
baz: lodash.curry,
})
```
The decorated class is returned, so you can export it directly.
To apply multiple transforms to an accessor/method, you can either call `decorateClass` multiple times or use [`@vates/compose`](https://www.npmjs.com/package/@vates/compose):
```js
decorateClass(Foo, {
baz: compose([
[lodash.debounce, 150]
lodash.curry,
])
})
```
### `perInstance(fn, ...args)`
Helper to decorate the method by instance instead of for the whole class.
This is often necessary for caching or deduplicating calls.
```js
import { perInstance } from '@vates/decorateWith'
class Foo {
@decorateWith(perInstance, lodash.memoize)
bar() {
// body
}
}
```
Because it's a normal function, it can also be used with `decorateClass`, with `compose` or even by itself.
### `decorateMethodsWith(class, map)`
> Deprecated alias for [`decorateClass(class, map)`](#decorateclassclass-map).

View File

@@ -31,15 +31,19 @@ class Foo {
}
```
### `decorateMethodsWith(class, map)`
### `decorateClass(class, map)`
Decorates a number of methods directly, without using the decorator syntax:
Decorates a number of accessors and methods directly, without using the decorator syntax:
```js
import { decorateMethodsWith } from '@vates/decorate-with'
import { decorateClass } from '@vates/decorate-with'
class Foo {
bar() {
get bar() {
// body
}
set bar(value) {
// body
}
@@ -48,17 +52,57 @@ class Foo {
}
}
decorateMethodsWith(Foo, {
// without arguments
bar: lodash.curry,
decorateClass(Foo, {
// getter and/or setter
bar: {
// without arguments
get: lodash.memoize,
// with arguments
baz: [lodash.debounce, 150],
// with arguments
set: [lodash.debounce, 150],
},
// method (with or without arguments)
baz: lodash.curry,
})
```
The decorated class is returned, so you can export it directly.
To apply multiple transforms to an accessor/method, you can either call `decorateClass` multiple times or use [`@vates/compose`](https://www.npmjs.com/package/@vates/compose):
```js
decorateClass(Foo, {
baz: compose([
[lodash.debounce, 150]
lodash.curry,
])
})
```
### `perInstance(fn, ...args)`
Helper to decorate the method by instance instead of for the whole class.
This is often necessary for caching or deduplicating calls.
```js
import { perInstance } from '@vates/decorateWith'
class Foo {
@decorateWith(perInstance, lodash.memoize)
bar() {
// body
}
}
```
Because it's a normal function, it can also be used with `decorateClass`, with `compose` or even by itself.
### `decorateMethodsWith(class, map)`
> Deprecated alias for [`decorateClass(class, map)`](#decorateclassclass-map).
## Contributions
Contributions are _very_ welcomed, either on the documentation or on

View File

@@ -1,42 +0,0 @@
### `decorateWith(fn, ...args)`
Creates a new ([legacy](https://babeljs.io/docs/en/babel-plugin-syntax-decorators#legacy)) method decorator from a function decorator, for instance, allows using Lodash's functions as decorators:
```js
import { decorateWith } from '@vates/decorate-with'
class Foo {
@decorateWith(lodash.debounce, 150)
bar() {
// body
}
}
```
### `decorateMethodsWith(class, map)`
Decorates a number of methods directly, without using the decorator syntax:
```js
import { decorateMethodsWith } from '@vates/decorate-with'
class Foo {
bar() {
// body
}
baz() {
// body
}
}
decorateMethodsWith(Foo, {
// without arguments
bar: lodash.curry,
// with arguments
baz: [lodash.debounce, 150],
})
```
The decorated class is returned, so you can export it directly.

View File

@@ -1,3 +1,5 @@
'use strict'
exports.decorateWith = function decorateWith(fn, ...args) {
return (target, name, descriptor) => ({
...descriptor,
@@ -7,15 +9,40 @@ exports.decorateWith = function decorateWith(fn, ...args) {
const { getOwnPropertyDescriptor, defineProperty } = Object
exports.decorateMethodsWith = function decorateMethodsWith(klass, map) {
function applyDecorator(decorator, value) {
return typeof decorator === 'function' ? decorator(value) : decorator[0](value, ...decorator.slice(1))
}
exports.decorateClass = exports.decorateMethodsWith = function decorateClass(klass, map) {
const { prototype } = klass
for (const name of Object.keys(map)) {
const descriptor = getOwnPropertyDescriptor(prototype, name)
const { value } = descriptor
const decorator = map[name]
descriptor.value = typeof decorator === 'function' ? decorator(value) : decorator[0](value, ...decorator.slice(1))
const descriptor = getOwnPropertyDescriptor(prototype, name)
if (typeof decorator === 'function' || Array.isArray(decorator)) {
descriptor.value = applyDecorator(decorator, descriptor.value)
} else {
const { get, set } = decorator
if (get !== undefined) {
descriptor.get = applyDecorator(get, descriptor.get)
}
if (set !== undefined) {
descriptor.set = applyDecorator(set, descriptor.set)
}
}
defineProperty(prototype, name, descriptor)
}
return klass
}
exports.perInstance = function perInstance(fn, decorator, ...args) {
const map = new WeakMap()
return function () {
let decorated = map.get(this)
if (decorated === undefined) {
decorated = decorator(fn, ...args)
map.set(this, decorated)
}
return decorated.apply(this, arguments)
}
}

View File

@@ -0,0 +1,152 @@
'use strict'
const assert = require('assert')
const { describe, it } = require('tap').mocha
const { decorateClass, decorateWith, decorateMethodsWith, perInstance } = require('./')
const identity = _ => _
describe('decorateWith', () => {
it('works', () => {
const expectedArgs = [Math.random(), Math.random()]
const expectedFn = Function.prototype
const newFn = () => {}
const decorator = decorateWith(function wrapper(fn, ...args) {
assert.deepStrictEqual(fn, expectedFn)
assert.deepStrictEqual(args, expectedArgs)
return newFn
}, ...expectedArgs)
const descriptor = {
configurable: true,
enumerable: false,
value: expectedFn,
writable: true,
}
assert.deepStrictEqual(decorator({}, 'foo', descriptor), {
...descriptor,
value: newFn,
})
})
})
describe('decorateClass', () => {
it('works', () => {
class C {
foo() {}
bar() {}
get baz() {}
// eslint-disable-next-line accessor-pairs
set qux(_) {}
}
const expectedArgs = [Math.random(), Math.random()]
const P = C.prototype
const descriptors = Object.getOwnPropertyDescriptors(P)
const newFoo = () => {}
const newBar = () => {}
const newGetBaz = () => {}
const newSetQux = _ => {}
decorateClass(C, {
foo(fn) {
assert.strictEqual(arguments.length, 1)
assert.strictEqual(fn, P.foo)
return newFoo
},
bar: [
function (fn, ...args) {
assert.strictEqual(fn, P.bar)
assert.deepStrictEqual(args, expectedArgs)
return newBar
},
...expectedArgs,
],
baz: {
get(fn) {
assert.strictEqual(arguments.length, 1)
assert.strictEqual(fn, descriptors.baz.get)
return newGetBaz
},
},
qux: {
set: [
function (fn, ...args) {
assert.strictEqual(fn, descriptors.qux.set)
assert.deepStrictEqual(args, expectedArgs)
return newSetQux
},
...expectedArgs,
],
},
})
const newDescriptors = Object.getOwnPropertyDescriptors(P)
assert.deepStrictEqual(newDescriptors.foo, { ...descriptors.foo, value: newFoo })
assert.deepStrictEqual(newDescriptors.bar, { ...descriptors.bar, value: newBar })
assert.deepStrictEqual(newDescriptors.baz, { ...descriptors.baz, get: newGetBaz })
assert.deepStrictEqual(newDescriptors.qux, { ...descriptors.qux, set: newSetQux })
})
it('throws if using an accessor decorator for a method', function () {
assert.throws(() =>
decorateClass(
class {
foo() {}
},
{ foo: { get: identity, set: identity } }
)
)
})
it('throws if using a method decorator for an accessor', function () {
assert.throws(() =>
decorateClass(
class {
get foo() {}
},
{ foo: identity }
)
)
})
})
it('decorateMethodsWith is an alias of decorateClass', function () {
assert.strictEqual(decorateMethodsWith, decorateClass)
})
describe('perInstance', () => {
it('works', () => {
let calls = 0
const expectedArgs = [Math.random(), Math.random()]
const expectedFn = Function.prototype
function wrapper(fn, ...args) {
assert.strictEqual(fn, expectedFn)
assert.deepStrictEqual(args, expectedArgs)
const i = ++calls
return () => i
}
const wrapped = perInstance(expectedFn, wrapper, ...expectedArgs)
// decorator is not called before decorated called
assert.strictEqual(calls, 0)
const o1 = {}
const o2 = {}
assert.strictEqual(wrapped.call(o1), 1)
// the same decorated function is returned for the same instance
assert.strictEqual(wrapped.call(o1), 1)
// a new decorated function is returned for another instance
assert.strictEqual(wrapped.call(o2), 2)
})
})

View File

@@ -20,11 +20,15 @@
"url": "https://vates.fr"
},
"license": "ISC",
"version": "0.1.0",
"version": "2.0.0",
"engines": {
"node": ">=8.10"
},
"scripts": {
"postversion": "npm publish --access public"
"postversion": "npm publish --access public",
"test": "tap"
},
"devDependencies": {
"tap": "^16.0.1"
}
}

View File

@@ -1,3 +1,5 @@
'use strict'
const { asyncMap } = require('@xen-orchestra/async-map')
const { createLogger } = require('@xen-orchestra/log')

View File

@@ -1,3 +1,5 @@
'use strict'
/* eslint-env jest */
const { createDebounceResource } = require('./debounceResource')

View File

@@ -1,3 +1,5 @@
'use strict'
const ensureArray = require('ensure-array')
const { MultiKeyMap } = require('@vates/multi-key-map')

View File

@@ -1,3 +1,5 @@
'use strict'
/* eslint-env jest */
const { deduped } = require('./deduped')

View File

@@ -1,3 +1,5 @@
'use strict'
class Node {
constructor(value) {
this.children = new Map()

View File

@@ -1,3 +1,5 @@
'use strict'
/* eslint-env jest */
const { MultiKeyMap } = require('./')

View File

@@ -1,3 +1,5 @@
'use strict'
const ms = require('ms')
exports.parseDuration = value => {

View File

@@ -0,0 +1,57 @@
`undefined` predicates are ignored and `undefined` is returned if all predicates are `undefined`, this permits the most efficient composition:
```js
const compositePredicate = every(undefined, some(predicate2, undefined))
// ends up as
const compositePredicate = predicate2
```
Predicates can also be passed wrapped in an array:
```js
const compositePredicate = every([predicate1, some([predicate2, predicate3])])
```
`this` and all arguments are passed to the nested predicates.
### `every(predicates)`
> Returns a predicate that returns `true` iff every predicate returns `true`.
```js
const isBetween3And7 = every(
n => n >= 3,
n => n <= 7
)
isBetween3And10(0)
// → false
isBetween3And10(5)
// → true
isBetween3And10(10)
// → false
```
### `some(predicates)`
> Returns a predicate that returns `true` iff some predicate returns `true`.
```js
const isAliceOrBob = some(
name => name === 'Alice',
name => name === 'Bob'
)
isAliceOrBob('Alice')
// → true
isAliceOrBob('Bob')
// → true
isAliceOrBob('Oscar')
// → false
```

View File

@@ -0,0 +1 @@
../../scripts/npmignore

View File

@@ -0,0 +1,90 @@
<!-- DO NOT EDIT MANUALLY, THIS FILE HAS BEEN GENERATED -->
# @vates/predicates
[![Package Version](https://badgen.net/npm/v/@vates/predicates)](https://npmjs.org/package/@vates/predicates) ![License](https://badgen.net/npm/license/@vates/predicates) [![PackagePhobia](https://badgen.net/bundlephobia/minzip/@vates/predicates)](https://bundlephobia.com/result?p=@vates/predicates) [![Node compatibility](https://badgen.net/npm/node/@vates/predicates)](https://npmjs.org/package/@vates/predicates)
> Utilities to compose predicates
## Install
Installation of the [npm package](https://npmjs.org/package/@vates/predicates):
```
> npm install --save @vates/predicates
```
## Usage
`undefined` predicates are ignored and `undefined` is returned if all predicates are `undefined`, this permits the most efficient composition:
```js
const compositePredicate = every(undefined, some(predicate2, undefined))
// ends up as
const compositePredicate = predicate2
```
Predicates can also be passed wrapped in an array:
```js
const compositePredicate = every([predicate1, some([predicate2, predicate3])])
```
`this` and all arguments are passed to the nested predicates.
### `every(predicates)`
> Returns a predicate that returns `true` iff every predicate returns `true`.
```js
const isBetween3And7 = every(
n => n >= 3,
n => n <= 7
)
isBetween3And10(0)
// → false
isBetween3And10(5)
// → true
isBetween3And10(10)
// → false
```
### `some(predicates)`
> Returns a predicate that returns `true` iff some predicate returns `true`.
```js
const isAliceOrBob = some(
name => name === 'Alice',
name => name === 'Bob'
)
isAliceOrBob('Alice')
// → true
isAliceOrBob('Bob')
// → true
isAliceOrBob('Oscar')
// → false
```
## Contributions
Contributions are _very_ welcomed, either on the documentation or on
the code.
You may:
- report any [issue](https://github.com/vatesfr/xen-orchestra/issues)
you've encountered;
- fork and create a pull request.
## License
[ISC](https://spdx.org/licenses/ISC) © [Vates SAS](https://vates.fr)

View File

@@ -0,0 +1,71 @@
'use strict'
const {
isArray,
prototype: { filter },
} = Array
class InvalidPredicate extends TypeError {
constructor(value) {
super('not a valid predicate')
this.value = value
}
}
function isDefinedPredicate(value) {
if (value === undefined) {
return false
}
if (typeof value !== 'function') {
throw new InvalidPredicate(value)
}
return true
}
function handleArgs() {
let predicates
if (!(arguments.length === 1 && isArray((predicates = arguments[0])))) {
predicates = arguments
}
return filter.call(predicates, isDefinedPredicate)
}
exports.every = function every() {
const predicates = handleArgs.apply(this, arguments)
const n = predicates.length
if (n === 0) {
return
}
if (n === 1) {
return predicates[0]
}
return function everyPredicate() {
for (let i = 0; i < n; ++i) {
if (!predicates[i].apply(this, arguments)) {
return false
}
}
return true
}
}
exports.some = function some() {
const predicates = handleArgs.apply(this, arguments)
const n = predicates.length
if (n === 0) {
return
}
if (n === 1) {
return predicates[0]
}
return function somePredicate() {
for (let i = 0; i < n; ++i) {
if (predicates[i].apply(this, arguments)) {
return true
}
}
return false
}
}

View File

@@ -0,0 +1,65 @@
'use strict'
const assert = require('assert/strict')
const { describe, it } = require('tap').mocha
const { every, some } = require('./')
const T = () => true
const F = () => false
const testArgsHandling = fn => {
it('returns undefined if all predicates are undefined', () => {
assert.equal(fn(undefined), undefined)
assert.equal(fn([undefined]), undefined)
})
it('returns the predicate if only a single one is passed', () => {
assert.equal(fn(undefined, T), T)
assert.equal(fn([undefined, T]), T)
})
it('throws if it receives a non-predicate', () => {
const error = new TypeError('not a valid predicate')
error.value = 3
assert.throws(() => fn(3), error)
})
it('forwards this and arguments to predicates', () => {
const thisArg = 'qux'
const args = ['foo', 'bar', 'baz']
const predicate = function () {
assert.equal(this, thisArg)
assert.deepEqual(Array.from(arguments), args)
}
fn(predicate, predicate).apply(thisArg, args)
})
}
const runTests = (fn, truthTable) =>
it('works', () => {
truthTable.forEach(([result, ...predicates]) => {
assert.equal(fn(...predicates)(), result)
assert.equal(fn(predicates)(), result)
})
})
describe('every', () => {
testArgsHandling(every)
runTests(every, [
[true, T, T],
[false, T, F],
[false, F, T],
[false, F, F],
])
})
describe('some', () => {
testArgsHandling(some)
runTests(some, [
[true, T, T],
[true, T, F],
[true, F, T],
[false, F, F],
])
})

View File

@@ -0,0 +1,40 @@
{
"private": false,
"name": "@vates/predicates",
"description": "Utilities to compose predicates",
"keywords": [
"and",
"combine",
"compose",
"every",
"function",
"functions",
"or",
"predicate",
"predicates",
"some"
],
"homepage": "https://github.com/vatesfr/xen-orchestra/tree/master/@vates/predicates",
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"repository": {
"directory": "@vates/predicates",
"type": "git",
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
},
"license": "ISC",
"version": "1.0.0",
"engines": {
"node": ">=6"
},
"scripts": {
"postversion": "npm publish --access public",
"test": "tap"
},
"devDependencies": {
"tap": "^16.0.1"
}
}

View File

@@ -1,3 +1,5 @@
'use strict'
const readChunk = (stream, size) =>
size === 0
? Promise.resolve(Buffer.alloc(0))

View File

@@ -1,3 +1,5 @@
'use strict'
/* eslint-env jest */
const { Readable } = require('stream')

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env node
'use strict'
const fs = require('fs')
const mapKeys = (object, iteratee) => {

View File

@@ -1,3 +1,5 @@
'use strict'
const wrapCall = (fn, arg, thisArg) => {
try {
return Promise.resolve(fn.call(thisArg, arg))

View File

@@ -1,3 +1,5 @@
'use strict'
/* eslint-env jest */
const { asyncMapSettled } = require('./')

View File

@@ -1,3 +1,5 @@
'use strict'
// type MaybePromise<T> = Promise<T> | T
//
// declare export function asyncMap<T1, T2>(

View File

@@ -1 +0,0 @@
module.exports = require('../../@xen-orchestra/babel-config')(require('./package.json'))

View File

@@ -1,12 +1,14 @@
import assert from 'assert'
import hash from 'object-hash'
import { createLogger } from '@xen-orchestra/log'
import { decorateWith } from '@vates/decorate-with'
import { defer } from 'golike-defer'
'use strict'
const assert = require('assert')
const hash = require('object-hash')
const { createLogger } = require('@xen-orchestra/log')
const { decorateClass } = require('@vates/decorate-with')
const { defer } = require('golike-defer')
const log = createLogger('xo:audit-core')
export class Storage {
exports.Storage = class Storage {
constructor() {
this._lock = Promise.resolve()
}
@@ -29,7 +31,7 @@ const ID_TO_ALGORITHM = {
5: 'sha256',
}
export class AlteredRecordError extends Error {
class AlteredRecordError extends Error {
constructor(id, nValid, record) {
super('altered record')
@@ -38,8 +40,9 @@ export class AlteredRecordError extends Error {
this.record = record
}
}
exports.AlteredRecordError = AlteredRecordError
export class MissingRecordError extends Error {
class MissingRecordError extends Error {
constructor(id, nValid) {
super('missing record')
@@ -47,8 +50,10 @@ export class MissingRecordError extends Error {
this.nValid = nValid
}
}
exports.MissingRecordError = MissingRecordError
export const NULL_ID = 'nullId'
const NULL_ID = 'nullId'
exports.NULL_ID = NULL_ID
const HASH_ALGORITHM_ID = '5'
const createHash = (data, algorithmId = HASH_ALGORITHM_ID) =>
@@ -57,13 +62,12 @@ const createHash = (data, algorithmId = HASH_ALGORITHM_ID) =>
excludeKeys: key => key === 'id',
})}`
export class AuditCore {
class AuditCore {
constructor(storage) {
assert.notStrictEqual(storage, undefined)
this._storage = storage
}
@decorateWith(defer)
async add($defer, subject, event, data) {
const time = Date.now()
$defer(await this._storage.acquireLock())
@@ -148,7 +152,6 @@ export class AuditCore {
}
}
@decorateWith(defer)
async deleteRangeAndRewrite($defer, newest, oldest) {
assert.notStrictEqual(newest, undefined)
assert.notStrictEqual(oldest, undefined)
@@ -189,3 +192,9 @@ export class AuditCore {
}
}
}
exports.AuditCore = AuditCore
decorateClass(AuditCore, {
add: defer,
deleteRangeAndRewrite: defer,
})

View File

@@ -1,6 +1,9 @@
/* eslint-env jest */
'use strict'
import { AlteredRecordError, AuditCore, MissingRecordError, NULL_ID, Storage } from '.'
const assert = require('assert/strict')
const { afterEach, describe, it } = require('tap').mocha
const { AlteredRecordError, AuditCore, MissingRecordError, NULL_ID, Storage } = require('.')
const asyncIteratorToArray = async asyncIterator => {
const array = []
@@ -72,7 +75,7 @@ const auditCore = new AuditCore(db)
const storeAuditRecords = async () => {
await Promise.all(DATA.map(data => auditCore.add(...data)))
const records = await asyncIteratorToArray(auditCore.getFrom())
expect(records.length).toBe(DATA.length)
assert.equal(records.length, DATA.length)
return records
}
@@ -83,10 +86,11 @@ describe('auditCore', () => {
const [newestRecord, deletedRecord] = await storeAuditRecords()
const nValidRecords = await auditCore.checkIntegrity(NULL_ID, newestRecord.id)
expect(nValidRecords).toBe(DATA.length)
assert.equal(nValidRecords, DATA.length)
await db.del(deletedRecord.id)
await expect(auditCore.checkIntegrity(NULL_ID, newestRecord.id)).rejects.toEqual(
await assert.rejects(
auditCore.checkIntegrity(NULL_ID, newestRecord.id),
new MissingRecordError(deletedRecord.id, 1)
)
})
@@ -97,7 +101,8 @@ describe('auditCore', () => {
alteredRecord.event = ''
await db.put(alteredRecord)
await expect(auditCore.checkIntegrity(NULL_ID, newestRecord.id)).rejects.toEqual(
await assert.rejects(
auditCore.checkIntegrity(NULL_ID, newestRecord.id),
new AlteredRecordError(alteredRecord.id, 1, alteredRecord)
)
})
@@ -107,8 +112,8 @@ describe('auditCore', () => {
await auditCore.deleteFrom(secondRecord.id)
expect(await db.get(firstRecord.id)).toBe(undefined)
expect(await db.get(secondRecord.id)).toBe(undefined)
assert.equal(await db.get(firstRecord.id), undefined)
assert.equal(await db.get(secondRecord.id), undefined)
await auditCore.checkIntegrity(secondRecord.id, thirdRecord.id)
})

View File

@@ -9,28 +9,14 @@
},
"version": "0.2.0",
"engines": {
"node": ">=10"
"node": ">=14"
},
"main": "dist/",
"scripts": {
"build": "cross-env NODE_ENV=production babel --source-maps --out-dir=dist/ src/",
"dev": "cross-env NODE_ENV=development babel --watch --source-maps --out-dir=dist/ src/",
"postversion": "npm publish --access public",
"prebuild": "rimraf dist/",
"predev": "yarn run prebuild",
"prepublishOnly": "yarn run build"
},
"devDependencies": {
"@babel/cli": "^7.7.4",
"@babel/core": "^7.7.4",
"@babel/plugin-proposal-decorators": "^7.8.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.0",
"@babel/preset-env": "^7.7.4",
"cross-env": "^7.0.2",
"rimraf": "^3.0.0"
"test": "tap --lines 67 --functions 92 --branches 52 --statements 67"
},
"dependencies": {
"@vates/decorate-with": "^0.1.0",
"@vates/decorate-with": "^2.0.0",
"@xen-orchestra/log": "^0.3.0",
"golike-defer": "^0.5.1",
"object-hash": "^2.0.1"
@@ -40,5 +26,8 @@
"author": {
"name": "Vates SAS",
"url": "https://vates.fr"
},
"devDependencies": {
"tap": "^16.0.1"
}
}

View File

@@ -10,7 +10,7 @@
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"engines": {
"node": ">=6"
"node": ">=8.3"
},
"license": "AGPL-3.0-or-later",
"author": {

View File

@@ -1,3 +1,5 @@
'use strict'
const getopts = require('getopts')
const { version } = require('./package.json')

View File

@@ -1,3 +1,5 @@
'use strict'
const { dirname } = require('path')
const fs = require('promise-toolbox/promisifyAll')(require('fs'))

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env node
'use strict'
// -----------------------------------------------------------------------------

View File

@@ -1,3 +1,5 @@
'use strict'
const filenamify = require('filenamify')
const get = require('lodash/get')
const { asyncMap } = require('@xen-orchestra/async-map')

View File

@@ -1,3 +1,5 @@
'use strict'
const groupBy = require('lodash/groupBy')
const { asyncMap } = require('@xen-orchestra/async-map')
const { createHash } = require('crypto')

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env node
'use strict'
require('./_composeCommands')({
'clean-vms': {
get main() {

View File

@@ -7,12 +7,12 @@
"bugs": "https://github.com/vatesfr/xen-orchestra/issues",
"dependencies": {
"@xen-orchestra/async-map": "^0.1.2",
"@xen-orchestra/backups": "^0.16.0",
"@xen-orchestra/fs": "^0.19.1",
"@xen-orchestra/backups": "^0.21.0",
"@xen-orchestra/fs": "^1.0.0",
"filenamify": "^4.1.0",
"getopts": "^2.2.5",
"lodash": "^4.17.15",
"promise-toolbox": "^0.20.0"
"promise-toolbox": "^0.21.0"
},
"engines": {
"node": ">=7.10.1"
@@ -27,7 +27,7 @@
"scripts": {
"postversion": "npm publish --access public"
},
"version": "0.6.1",
"version": "0.7.0",
"license": "AGPL-3.0-or-later",
"author": {
"name": "Vates SAS",

View File

@@ -1,6 +1,8 @@
'use strict'
const { asyncMap, asyncMapSettled } = require('@xen-orchestra/async-map')
const Disposable = require('promise-toolbox/Disposable.js')
const ignoreErrors = require('promise-toolbox/ignoreErrors.js')
const Disposable = require('promise-toolbox/Disposable')
const ignoreErrors = require('promise-toolbox/ignoreErrors')
const { compileTemplate } = require('@xen-orchestra/template')
const { limitConcurrency } = require('limit-concurrency-decorator')

View File

@@ -1,3 +1,5 @@
'use strict'
const { asyncMap } = require('@xen-orchestra/async-map')
exports.DurablePartition = class DurablePartition {

View File

@@ -1,3 +1,5 @@
'use strict'
const assert = require('assert')
const { formatFilenameDate } = require('./_filenameDate.js')
@@ -6,9 +8,9 @@ const { Task } = require('./Task.js')
const { watchStreamSize } = require('./_watchStreamSize.js')
exports.ImportVmBackup = class ImportVmBackup {
constructor({ adapter, metadata, srUuid, xapi, settings: { newMacAddresses } = {} }) {
constructor({ adapter, metadata, srUuid, xapi, settings: { newMacAddresses, mapVdisSrs = {} } = {} }) {
this._adapter = adapter
this._importDeltaVmSettings = { newMacAddresses }
this._importDeltaVmSettings = { newMacAddresses, mapVdisSrs }
this._metadata = metadata
this._srUuid = srUuid
this._xapi = xapi
@@ -28,7 +30,12 @@ exports.ImportVmBackup = class ImportVmBackup {
} else {
assert.strictEqual(metadata.mode, 'delta')
backup = await adapter.readDeltaVmBackup(metadata)
const ignoredVdis = new Set(
Object.entries(this._importDeltaVmSettings.mapVdisSrs)
.filter(([_, srUuid]) => srUuid === null)
.map(([vdiUuid]) => vdiUuid)
)
backup = await adapter.readDeltaVmBackup(metadata, ignoredVdis)
Object.values(backup.streams).forEach(stream => watchStreamSize(stream, sizeContainer))
}

View File

@@ -1,12 +1,18 @@
'use strict'
const { asyncMap, asyncMapSettled } = require('@xen-orchestra/async-map')
const Disposable = require('promise-toolbox/Disposable.js')
const fromCallback = require('promise-toolbox/fromCallback.js')
const fromEvent = require('promise-toolbox/fromEvent.js')
const pDefer = require('promise-toolbox/defer.js')
const Disposable = require('promise-toolbox/Disposable')
const fromCallback = require('promise-toolbox/fromCallback')
const fromEvent = require('promise-toolbox/fromEvent')
const pDefer = require('promise-toolbox/defer')
const groupBy = require('lodash/groupBy.js')
const pickBy = require('lodash/pickBy.js')
const { dirname, join, normalize, resolve } = require('path')
const { createLogger } = require('@xen-orchestra/log')
const { Constants, createVhdDirectoryFromStream, openVhd, VhdAbstract, VhdSynthetic } = require('vhd-lib')
const { Constants, createVhdDirectoryFromStream, openVhd, VhdAbstract, VhdDirectory, VhdSynthetic } = require('vhd-lib')
const { deduped } = require('@vates/disposable/deduped.js')
const { decorateMethodsWith } = require('@vates/decorate-with')
const { compose } = require('@vates/compose')
const { execFile } = require('child_process')
const { readdir, stat } = require('fs-extra')
const { v4: uuidv4 } = require('uuid')
@@ -67,10 +73,11 @@ const debounceResourceFactory = factory =>
}
class RemoteAdapter {
constructor(handler, { debounceResource = res => res, dirMode } = {}) {
constructor(handler, { debounceResource = res => res, dirMode, vhdDirectoryCompression } = {}) {
this._debounceResource = debounceResource
this._dirMode = dirMode
this._handler = handler
this._vhdDirectoryCompression = vhdDirectoryCompression
}
get handler() {
@@ -86,9 +93,6 @@ class RemoteAdapter {
return partition
}
_getLvmLogicalVolumes = Disposable.factory(this._getLvmLogicalVolumes)
_getLvmLogicalVolumes = deduped(this._getLvmLogicalVolumes, (devicePath, pvId, vgName) => [devicePath, pvId, vgName])
_getLvmLogicalVolumes = debounceResourceFactory(this._getLvmLogicalVolumes)
async *_getLvmLogicalVolumes(devicePath, pvId, vgName) {
yield this._getLvmPhysicalVolume(devicePath, pvId && (await this._findPartition(devicePath, pvId)))
@@ -100,9 +104,6 @@ class RemoteAdapter {
}
}
_getLvmPhysicalVolume = Disposable.factory(this._getLvmPhysicalVolume)
_getLvmPhysicalVolume = deduped(this._getLvmPhysicalVolume, (devicePath, partition) => [devicePath, partition?.id])
_getLvmPhysicalVolume = debounceResourceFactory(this._getLvmPhysicalVolume)
async *_getLvmPhysicalVolume(devicePath, partition) {
const args = []
if (partition !== undefined) {
@@ -123,9 +124,6 @@ class RemoteAdapter {
}
}
_getPartition = Disposable.factory(this._getPartition)
_getPartition = deduped(this._getPartition, (devicePath, partition) => [devicePath, partition?.id])
_getPartition = debounceResourceFactory(this._getPartition)
async *_getPartition(devicePath, partition) {
const options = ['loop', 'ro']
@@ -178,7 +176,6 @@ class RemoteAdapter {
})
}
_usePartitionFiles = Disposable.factory(this._usePartitionFiles)
async *_usePartitionFiles(diskId, partitionId, paths) {
const path = yield this.getPartition(diskId, partitionId)
@@ -190,6 +187,22 @@ class RemoteAdapter {
return files
}
// check if we will be allowed to merge a a vhd created in this adapter
// with the vhd at path `path`
async isMergeableParent(packedParentUid, path) {
return await Disposable.use(openVhd(this.handler, path), vhd => {
// this baseUuid is not linked with this vhd
if (!vhd.footer.uuid.equals(packedParentUid)) {
return false
}
const isVhdDirectory = vhd instanceof VhdDirectory
return isVhdDirectory
? this.#useVhdDirectory() && this.#getCompressionType() === vhd.compressionType
: !this.#useVhdDirectory()
})
}
fetchPartitionFiles(diskId, partitionId, paths) {
const { promise, reject, resolve } = pDefer()
Disposable.use(
@@ -212,8 +225,8 @@ class RemoteAdapter {
async deleteDeltaVmBackups(backups) {
const handler = this._handler
// unused VHDs will be detected by `cleanVm`
await asyncMapSettled(backups, ({ _filename }) => VhdAbstract.unlink(handler, _filename))
// this will delete the json, unused VHDs will be detected by `cleanVm`
await asyncMapSettled(backups, ({ _filename }) => handler.unlink(_filename))
}
async deleteMetadataBackup(backupId) {
@@ -243,22 +256,42 @@ class RemoteAdapter {
)
}
async deleteVmBackup(filename) {
const metadata = JSON.parse(String(await this._handler.readFile(filename)))
metadata._filename = filename
deleteVmBackup(file) {
return this.deleteVmBackups([file])
}
if (metadata.mode === 'delta') {
await this.deleteDeltaVmBackups([metadata])
} else if (metadata.mode === 'full') {
await this.deleteFullVmBackups([metadata])
} else {
throw new Error(`no deleter for backup mode ${metadata.mode}`)
async deleteVmBackups(files) {
const { delta, full, ...others } = groupBy(await asyncMap(files, file => this.readVmBackupMetadata(file)), 'mode')
const unsupportedModes = Object.keys(others)
if (unsupportedModes.length !== 0) {
throw new Error('no deleter for backup modes: ' + unsupportedModes.join(', '))
}
await Promise.all([
delta !== undefined && this.deleteDeltaVmBackups(delta),
full !== undefined && this.deleteFullVmBackups(full),
])
const dirs = new Set(files.map(file => dirname(file)))
for (const dir of dirs) {
// don't merge in main process, unused VHDs will be merged in the next backup run
await this.cleanVm(dir, { remove: true, onLog: warn })
}
}
getDisk = Disposable.factory(this.getDisk)
getDisk = deduped(this.getDisk, diskId => [diskId])
getDisk = debounceResourceFactory(this.getDisk)
#getCompressionType() {
return this._vhdDirectoryCompression
}
#useVhdDirectory() {
return this.handler.type === 's3'
}
#useAlias() {
return this.#useVhdDirectory()
}
async *getDisk(diskId) {
const handler = this._handler
@@ -295,7 +328,6 @@ class RemoteAdapter {
// - `<partitionId>`: partitioned disk
// - `<pvId>/<vgName>/<lvName>`: LVM on a partitioned disk
// - `/<vgName>/lvName>`: LVM on a raw disk
getPartition = Disposable.factory(this.getPartition)
async *getPartition(diskId, partitionId) {
const devicePath = yield this.getDisk(diskId)
if (partitionId === undefined) {
@@ -312,13 +344,10 @@ class RemoteAdapter {
return yield this._getPartition(devicePath, await this._findPartition(devicePath, partitionId))
}
// this function will be the one where we plug the logic of the storage format by fs type/user settings
// if the file is named .vhd => vhd
// if the file is named alias.vhd => alias to a vhd
// if we use alias on this remote, we have to name the file alias.vhd
getVhdFileName(baseName) {
if (this._handler.type === 's3') {
return `${baseName}.alias.vhd` // we want an alias to a vhddirectory
if (this.#useAlias()) {
return `${baseName}.alias.vhd`
}
return `${baseName}.vhd`
}
@@ -327,9 +356,14 @@ class RemoteAdapter {
const handler = this._handler
const backups = { __proto__: null }
await asyncMap(await handler.list(BACKUP_DIR), async vmUuid => {
const vmBackups = await this.listVmBackups(vmUuid)
backups[vmUuid] = vmBackups
await asyncMap(await handler.list(BACKUP_DIR), async entry => {
// ignore hidden and lock files
if (entry[0] !== '.' && !entry.endsWith('.lock')) {
const vmBackups = await this.listVmBackups(entry)
if (vmBackups.length !== 0) {
backups[entry] = vmBackups
}
}
})
return backups
@@ -469,11 +503,12 @@ class RemoteAdapter {
async writeVhd(path, input, { checksum = true, validator = noop } = {}) {
const handler = this._handler
let dataPath = path
if (path.endsWith('.alias.vhd')) {
await createVhdDirectoryFromStream(handler, `${dirname(path)}/data/${uuidv4()}.vhd`, input, {
if (this.#useVhdDirectory()) {
const dataPath = `${dirname(path)}/data/${uuidv4()}.vhd`
await createVhdDirectoryFromStream(handler, dataPath, input, {
concurrency: 16,
compression: this.#getCompressionType(),
async validator() {
await input.task
return validator.apply(this, arguments)
@@ -481,7 +516,7 @@ class RemoteAdapter {
})
await VhdAbstract.createAlias(handler, path, dataPath)
} else {
await this.outputStream(dataPath, input, { checksum, validator })
await this.outputStream(path, input, { checksum, validator })
}
}
@@ -501,8 +536,8 @@ class RemoteAdapter {
// if it's a path : open all hierarchy of parent
if (typeof paths === 'string') {
let vhd,
vhdPath = paths
let vhd
let vhdPath = paths
do {
const disposable = await openVhd(handler, vhdPath)
vhd = disposable.value
@@ -542,14 +577,15 @@ class RemoteAdapter {
return stream
}
async readDeltaVmBackup(metadata) {
async readDeltaVmBackup(metadata, ignoredVdis) {
const handler = this._handler
const { vbds, vdis, vhds, vifs, vm } = metadata
const { vbds, vhds, vifs, vm } = metadata
const dir = dirname(metadata._filename)
const vdis = ignoredVdis === undefined ? metadata.vdis : pickBy(metadata.vdis, vdi => !ignoredVdis.has(vdi.uuid))
const streams = {}
await asyncMapSettled(Object.keys(vdis), async id => {
streams[`${id}.vhd`] = await this._createSyntheticStream(handler, join(dir, vhds[id]))
await asyncMapSettled(Object.keys(vdis), async ref => {
streams[`${ref}.vhd`] = await this._createSyntheticStream(handler, join(dir, vhds[ref]))
})
return {
@@ -582,4 +618,30 @@ Object.assign(RemoteAdapter.prototype, {
isValidXva,
})
decorateMethodsWith(RemoteAdapter, {
_getLvmLogicalVolumes: compose([
Disposable.factory,
[deduped, (devicePath, pvId, vgName) => [devicePath, pvId, vgName]],
debounceResourceFactory,
]),
_getLvmPhysicalVolume: compose([
Disposable.factory,
[deduped, (devicePath, partition) => [devicePath, partition?.id]],
debounceResourceFactory,
]),
_getPartition: compose([
Disposable.factory,
[deduped, (devicePath, partition) => [devicePath, partition?.id]],
debounceResourceFactory,
]),
_usePartitionFiles: Disposable.factory,
getDisk: compose([Disposable.factory, [deduped, diskId => [diskId]], debounceResourceFactory]),
getPartition: Disposable.factory,
})
exports.RemoteAdapter = RemoteAdapter

View File

@@ -1,3 +1,5 @@
'use strict'
const { DIR_XO_POOL_METADATA_BACKUPS } = require('./RemoteAdapter.js')
const { PATH_DB_DUMP } = require('./_PoolMetadataBackup.js')

View File

@@ -1,4 +1,6 @@
const CancelToken = require('promise-toolbox/CancelToken.js')
'use strict'
const CancelToken = require('promise-toolbox/CancelToken')
const Zone = require('node-zone')
const logAfterEnd = () => {
@@ -7,6 +9,8 @@ const logAfterEnd = () => {
const noop = Function.prototype
const serializeErrors = errors => (Array.isArray(errors) ? errors.map(serializeError) : errors)
// Create a serializable object from an error.
//
// Otherwise some fields might be non-enumerable and missing from logs.
@@ -15,6 +19,7 @@ const serializeError = error =>
? {
...error, // Copy enumerable properties.
code: error.code,
errors: serializeErrors(error.errors), // supports AggregateError
message: error.message,
name: error.name,
stack: error.stack,

View File

@@ -1,3 +1,5 @@
'use strict'
const { asyncMap } = require('@xen-orchestra/async-map')
const { DIR_XO_POOL_METADATA_BACKUPS } = require('./RemoteAdapter.js')

View File

@@ -1,11 +1,14 @@
'use strict'
const assert = require('assert')
const findLast = require('lodash/findLast.js')
const groupBy = require('lodash/groupBy.js')
const ignoreErrors = require('promise-toolbox/ignoreErrors.js')
const ignoreErrors = require('promise-toolbox/ignoreErrors')
const keyBy = require('lodash/keyBy.js')
const mapValues = require('lodash/mapValues.js')
const { asyncMap } = require('@xen-orchestra/async-map')
const { createLogger } = require('@xen-orchestra/log')
const { decorateMethodsWith } = require('@vates/decorate-with')
const { defer } = require('golike-defer')
const { formatDateTime } = require('@xen-orchestra/xapi')
@@ -21,6 +24,13 @@ const { watchStreamSize } = require('./_watchStreamSize.js')
const { debug, warn } = createLogger('xo:backups:VmBackup')
class AggregateError extends Error {
constructor(errors, message) {
super(message)
this.errors = errors
}
}
const asyncEach = async (iterable, fn, thisArg = iterable) => {
for (const item of iterable) {
await fn.call(thisArg, item)
@@ -34,8 +44,14 @@ const forkDeltaExport = deltaExport =>
},
})
exports.VmBackup = class VmBackup {
class VmBackup {
constructor({ config, getSnapshotNameLabel, job, remoteAdapters, remotes, schedule, settings, srs, vm }) {
if (vm.other_config['xo:backup:job'] === job.id && 'start' in vm.blocked_operations) {
// don't match replicated VMs created by this very job otherwise they
// will be replicated again and again
throw new Error('cannot backup a VM created by this very job')
}
this.config = config
this.job = job
this.remoteAdapters = remoteAdapters
@@ -119,16 +135,18 @@ exports.VmBackup = class VmBackup {
return
}
const errors = []
await (parallel ? asyncMap : asyncEach)(writers, async function (writer) {
try {
await fn(writer)
} catch (error) {
errors.push(error)
this.delete(writer)
warn(warnMessage, { error, writer: writer.constructor.name })
}
})
if (writers.size === 0) {
throw new Error('all targets have failed, step: ' + warnMessage)
throw new AggregateError(errors, 'all targets have failed, step: ' + warnMessage)
}
}
@@ -333,13 +351,16 @@ exports.VmBackup = class VmBackup {
const baseUuidToSrcVdi = new Map()
await asyncMap(await baseVm.$getDisks(), async baseRef => {
const snapshotOf = await xapi.getField('VDI', baseRef, 'snapshot_of')
const [baseUuid, snapshotOf] = await Promise.all([
xapi.getField('VDI', baseRef, 'uuid'),
xapi.getField('VDI', baseRef, 'snapshot_of'),
])
const srcVdi = srcVdis[snapshotOf]
if (srcVdi !== undefined) {
baseUuidToSrcVdi.set(await xapi.getField('VDI', baseRef, 'uuid'), srcVdi)
baseUuidToSrcVdi.set(baseUuid, srcVdi)
} else {
debug('no base VDI found', {
vdi: srcVdi.uuid,
debug('ignore snapshot VDI because no longer present on VM', {
vdi: baseUuid,
})
}
})
@@ -351,6 +372,11 @@ exports.VmBackup = class VmBackup {
false
)
if (presentBaseVdis.size === 0) {
debug('no base VM found')
return
}
const fullVdisRequired = new Set()
baseUuidToSrcVdi.forEach((srcVdi, baseUuid) => {
if (presentBaseVdis.has(baseUuid)) {
@@ -371,7 +397,6 @@ exports.VmBackup = class VmBackup {
this._fullVdisRequired = fullVdisRequired
}
run = defer(this.run)
async run($defer) {
const settings = this._settings
assert(
@@ -419,3 +444,8 @@ exports.VmBackup = class VmBackup {
}
}
}
exports.VmBackup = VmBackup
decorateMethodsWith(VmBackup, {
run: defer,
})

View File

@@ -1,3 +1,5 @@
'use strict'
const { asyncMap } = require('@xen-orchestra/async-map')
const { DIR_XO_CONFIG_BACKUPS } = require('./RemoteAdapter.js')

View File

@@ -1,4 +1,6 @@
'use strict'
exports.isMetadataFile = filename => filename.endsWith('.json')
exports.isVhdFile = filename => filename.endsWith('.vhd')
exports.isXvaFile = filename => filename.endsWith('.xva')
exports.isXvaSumFile = filename => filename.endsWith('.xva.cheksum')
exports.isXvaSumFile = filename => filename.endsWith('.xva.checksum')

View File

@@ -1,11 +1,14 @@
'use strict'
require('@xen-orchestra/log/configure.js').catchGlobalErrors(
require('@xen-orchestra/log').createLogger('xo:backups:worker')
)
const Disposable = require('promise-toolbox/Disposable.js')
const ignoreErrors = require('promise-toolbox/ignoreErrors.js')
const Disposable = require('promise-toolbox/Disposable')
const ignoreErrors = require('promise-toolbox/ignoreErrors')
const { compose } = require('@vates/compose')
const { createDebounceResource } = require('@vates/disposable/debounceResource.js')
const { decorateMethodsWith } = require('@vates/decorate-with')
const { deduped } = require('@vates/disposable/deduped.js')
const { getHandler } = require('@xen-orchestra/fs')
const { parseDuration } = require('@vates/parse-duration')
@@ -58,11 +61,6 @@ class BackupWorker {
}).run()
}
getAdapter = Disposable.factory(this.getAdapter)
getAdapter = deduped(this.getAdapter, remote => [remote.url])
getAdapter = compose(this.getAdapter, function (resource) {
return this.debounceResource(resource)
})
async *getAdapter(remote) {
const handler = getHandler(remote, this.#remoteOptions)
await handler.sync()
@@ -70,17 +68,13 @@ class BackupWorker {
yield new RemoteAdapter(handler, {
debounceResource: this.debounceResource,
dirMode: this.#config.dirMode,
vhdDirectoryCompression: this.#config.vhdDirectoryCompression,
})
} finally {
await handler.forget()
}
}
getXapi = Disposable.factory(this.getXapi)
getXapi = deduped(this.getXapi, ({ url }) => [url])
getXapi = compose(this.getXapi, function (resource) {
return this.debounceResource(resource)
})
async *getXapi({ credentials: { username: user, password }, ...opts }) {
const xapi = new Xapi({
...this.#xapiOptions,
@@ -102,6 +96,30 @@ class BackupWorker {
}
}
decorateMethodsWith(BackupWorker, {
getAdapter: compose([
Disposable.factory,
[deduped, remote => [remote.url]],
[
compose,
function (resource) {
return this.debounceResource(resource)
},
],
]),
getXapi: compose([
Disposable.factory,
[deduped, xapi => [xapi.url]],
[
compose,
function (resource) {
return this.debounceResource(resource)
},
],
]),
})
// Received message:
//
// Message {

View File

@@ -1,5 +1,7 @@
const cancelable = require('promise-toolbox/cancelable.js')
const CancelToken = require('promise-toolbox/CancelToken.js')
'use strict'
const cancelable = require('promise-toolbox/cancelable')
const CancelToken = require('promise-toolbox/CancelToken')
// Similar to `Promise.all` + `map` but pass a cancel token to the callback
//

View File

@@ -1,3 +1,5 @@
'use strict'
/* eslint-env jest */
const rimraf = require('rimraf')
@@ -9,6 +11,8 @@ const crypto = require('crypto')
const { RemoteAdapter } = require('./RemoteAdapter')
const { VHDFOOTER, VHDHEADER } = require('./tests.fixtures.js')
const { VhdFile, Constants, VhdDirectory, VhdAbstract } = require('vhd-lib')
const { checkAliases } = require('./_cleanVm')
const { dirname, basename } = require('path')
let tempDir, adapter, handler, jobId, vdiId, basePath
@@ -35,7 +39,11 @@ const uniqueId = () => crypto.randomBytes(16).toString('hex')
async function generateVhd(path, opts = {}) {
let vhd
const dataPath = opts.useAlias ? path + '.data' : path
let dataPath = path
if (opts.useAlias) {
await handler.mkdir(dirname(path) + '/data/')
dataPath = dirname(path) + '/data/' + basename(path)
}
if (opts.mode === 'directory') {
await handler.mkdir(dataPath)
vhd = new VhdDirectory(handler, dataPath)
@@ -162,7 +170,7 @@ test('it remove backup meta data referencing a missing vhd in delta backup', asy
`${basePath}/deleted.vhd`, // in metadata but not in vhds
`${basePath}/orphan.vhd`,
`${basePath}/child.vhd`,
// abandonned.json is not here
// abandonned.vhd is not here anymore
],
}),
{ flags: 'w' }
@@ -178,7 +186,7 @@ test('it merges delta of non destroyed chain', async () => {
`metadata.json`,
JSON.stringify({
mode: 'delta',
size: 209920,
size: 12000, // a size too small
vhds: [
`${basePath}/grandchild.vhd`, // grand child should not be merged
`${basePath}/child.vhd`,
@@ -204,20 +212,25 @@ test('it merges delta of non destroyed chain', async () => {
},
})
let loggued = ''
let loggued = []
const onLog = message => {
loggued += message + '\n'
loggued.push(message)
}
await adapter.cleanVm('/', { remove: true, onLog })
expect(loggued).toEqual(`the parent /${basePath}/orphan.vhd of the child /${basePath}/child.vhd is unused\n`)
loggued = ''
expect(loggued[0]).toEqual(`the parent /${basePath}/orphan.vhd of the child /${basePath}/child.vhd is unused`)
expect(loggued[1]).toEqual(`incorrect size in metadata: 12000 instead of 209920`)
loggued = []
await adapter.cleanVm('/', { remove: true, merge: true, onLog })
const [unused, merging] = loggued.split('\n')
const [unused, merging] = loggued
expect(unused).toEqual(`the parent /${basePath}/orphan.vhd of the child /${basePath}/child.vhd is unused`)
expect(merging).toEqual(`merging /${basePath}/child.vhd into /${basePath}/orphan.vhd`)
// merging is already tested in vhd-lib, don't retest it here (and theses vhd are as empty as my stomach at 12h12)
const metadata = JSON.parse(await handler.readFile(`metadata.json`))
// size should be the size of children + grand children after the merge
expect(metadata.size).toEqual(209920)
// merging is already tested in vhd-lib, don't retest it here (and theses vhd are as empty as my stomach at 12h12)
// only check deletion
const remainingVhds = await handler.list(basePath)
expect(remainingVhds.length).toEqual(2)
@@ -231,11 +244,7 @@ test('it finish unterminated merge ', async () => {
JSON.stringify({
mode: 'delta',
size: 209920,
vhds: [
`${basePath}/orphan.vhd`, // grand child should not be merged
`${basePath}/child.vhd`,
// orphan is not here, he should be merged in child
],
vhds: [`${basePath}/orphan.vhd`, `${basePath}/child.vhd`],
})
)
@@ -261,7 +270,6 @@ test('it finish unterminated merge ', async () => {
})
)
// a unfinished merging
await adapter.cleanVm('/', { remove: true, merge: true })
// merging is already tested in vhd-lib, don't retest it here (and theses vhd are as empty as my stomach at 12h12)
@@ -274,12 +282,17 @@ test('it finish unterminated merge ', async () => {
// each of the vhd can be a file, a directory, an alias to a file or an alias to a directory
// the message an resulting files should be identical to the output with vhd files which is tested independantly
describe('tests mulitple combination ', () => {
describe('tests multiple combination ', () => {
for (const useAlias of [true, false]) {
for (const vhdMode of ['file', 'directory']) {
test(`alias : ${useAlias}, mode: ${vhdMode}`, async () => {
// a broken VHD
const brokenVhdDataPath = basePath + useAlias ? 'broken.data' : 'broken.vhd'
if (useAlias) {
await handler.mkdir(basePath + '/data')
}
const brokenVhdDataPath = basePath + (useAlias ? '/data/broken.vhd' : '/broken.vhd')
if (vhdMode === 'directory') {
await handler.mkdir(brokenVhdDataPath)
} else {
@@ -300,6 +313,7 @@ describe('tests mulitple combination ', () => {
parentUid: crypto.randomBytes(16),
},
})
// an ancestor of a vhd present in metadata
const ancestor = await generateVhd(`${basePath}/ancestor.vhd`, {
useAlias,
@@ -362,22 +376,29 @@ describe('tests mulitple combination ', () => {
],
})
)
await adapter.cleanVm('/', { remove: true, merge: true })
const metadata = JSON.parse(await handler.readFile(`metadata.json`))
// size should be the size of children + grand children + clean after the merge
expect(metadata.size).toEqual(vhdMode === 'file' ? 314880 : undefined)
// broken vhd, non referenced, abandonned should be deleted ( alias and data)
// ancestor and child should be merged
// grand child and clean vhd should not have changed
const survivors = await handler.list(basePath)
// console.log(survivors)
if (useAlias) {
const dataSurvivors = await handler.list(basePath + '/data')
// the goal of the alias : do not move a full folder
expect(survivors).toContain('ancestor.vhd.data')
expect(survivors).toContain('grandchild.vhd.data')
expect(survivors).toContain('cleanAncestor.vhd.data')
expect(dataSurvivors).toContain('ancestor.vhd')
expect(dataSurvivors).toContain('grandchild.vhd')
expect(dataSurvivors).toContain('cleanAncestor.vhd')
expect(survivors).toContain('clean.vhd.alias.vhd')
expect(survivors).toContain('child.vhd.alias.vhd')
expect(survivors).toContain('grandchild.vhd.alias.vhd')
expect(survivors.length).toEqual(6)
expect(survivors.length).toEqual(4) // the 3 ok + data
expect(dataSurvivors.length).toEqual(3) // the 3 ok + data
} else {
expect(survivors).toContain('clean.vhd')
expect(survivors).toContain('child.vhd')
@@ -388,3 +409,31 @@ describe('tests mulitple combination ', () => {
}
}
})
test('it cleans orphan merge states ', async () => {
await handler.writeFile(`${basePath}/.orphan.vhd.merge.json`, '')
await adapter.cleanVm('/', { remove: true })
expect(await handler.list(basePath)).toEqual([])
})
test('check Aliases should work alone', async () => {
await handler.mkdir('vhds')
await handler.mkdir('vhds/data')
await generateVhd(`vhds/data/ok.vhd`)
await VhdAbstract.createAlias(handler, 'vhds/ok.alias.vhd', 'vhds/data/ok.vhd')
await VhdAbstract.createAlias(handler, 'vhds/missingData.alias.vhd', 'vhds/data/nonexistent.vhd')
await generateVhd(`vhds/data/missingalias.vhd`)
await checkAliases(['vhds/missingData.alias.vhd', 'vhds/ok.alias.vhd'], 'vhds/data', { remove: true, handler })
// only ok have suvived
const alias = (await handler.list('vhds')).filter(f => f.endsWith('.vhd'))
expect(alias.length).toEqual(1)
const data = await handler.list('vhds/data')
expect(data.length).toEqual(1)
})

View File

@@ -1,7 +1,10 @@
'use strict'
const assert = require('assert')
const sum = require('lodash/sum')
const { asyncMap } = require('@xen-orchestra/async-map')
const { Constants, mergeVhd, openVhd, VhdAbstract, VhdFile } = require('vhd-lib')
const { isVhdAlias, resolveVhdAlias } = require('vhd-lib/aliases')
const { dirname, resolve } = require('path')
const { DISK_TYPES } = Constants
const { isMetadataFile, isVhdFile, isXvaFile, isXvaSumFile } = require('./_backupType.js')
@@ -10,6 +13,24 @@ const { limitConcurrency } = require('limit-concurrency-decorator')
const { Task } = require('./Task.js')
const { Disposable } = require('promise-toolbox')
// checking the size of a vhd directory is costly
// 1 Http Query per 1000 blocks
// we only check size of all the vhd are VhdFiles
function shouldComputeVhdsSize(vhds) {
return vhds.every(vhd => vhd instanceof VhdFile)
}
const computeVhdsSize = (handler, vhdPaths) =>
Disposable.use(
vhdPaths.map(vhdPath => openVhd(handler, vhdPath)),
async vhds => {
if (shouldComputeVhdsSize(vhds)) {
const sizes = await asyncMap(vhds, vhd => vhd.getSize())
return sum(sizes)
}
}
)
// chain is an array of VHDs from child to parent
//
// the whole chain will be merged into parent, parent will be renamed to child
@@ -64,7 +85,6 @@ async function mergeVhdChain(chain, { handler, onLog, remove, merge }) {
)
clearInterval(handle)
await Promise.all([
VhdAbstract.rename(handler, parent, child),
asyncMap(children.slice(0, -1), child => {
@@ -82,10 +102,11 @@ async function mergeVhdChain(chain, { handler, onLog, remove, merge }) {
const noop = Function.prototype
const INTERRUPTED_VHDS_REG = /^(?:(.+)\/)?\.(.+)\.merge.json$/
const INTERRUPTED_VHDS_REG = /^\.(.+)\.merge.json$/
const listVhds = async (handler, vmDir) => {
const vhds = []
const interruptedVhds = new Set()
const vhds = new Set()
const aliases = {}
const interruptedVhds = new Map()
await asyncMap(
await handler.list(`${vmDir}/vdis`, {
@@ -100,25 +121,77 @@ const listVhds = async (handler, vmDir) => {
async vdiDir => {
const list = await handler.list(vdiDir, {
filter: file => isVhdFile(file) || INTERRUPTED_VHDS_REG.test(file),
prependDir: true,
})
aliases[vdiDir] = list.filter(vhd => isVhdAlias(vhd)).map(file => `${vdiDir}/${file}`)
list.forEach(file => {
const res = INTERRUPTED_VHDS_REG.exec(file)
if (res === null) {
vhds.push(file)
vhds.add(`${vdiDir}/${file}`)
} else {
const [, dir, file] = res
interruptedVhds.add(`${dir}/${file}`)
interruptedVhds.set(`${vdiDir}/${res[1]}`, `${vdiDir}/${file}`)
}
})
}
)
)
return { vhds, interruptedVhds }
return { vhds, interruptedVhds, aliases }
}
async function checkAliases(aliasPaths, targetDataRepository, { handler, onLog = noop, remove = false }) {
const aliasFound = []
for (const path of aliasPaths) {
const target = await resolveVhdAlias(handler, path)
if (!isVhdFile(target)) {
onLog(`Alias ${path} references a non vhd target: ${target}`)
if (remove) {
await handler.unlink(target)
await handler.unlink(path)
}
continue
}
try {
const { dispose } = await openVhd(handler, target)
try {
await dispose()
} catch (e) {
// error during dispose should not trigger a deletion
}
} catch (error) {
onLog(`target ${target} of alias ${path} is missing or broken`, { error })
if (remove) {
try {
await VhdAbstract.unlink(handler, path)
} catch (e) {
if (e.code !== 'ENOENT') {
onLog(`Error while deleting target ${target} of alias ${path}`, { error: e })
}
}
}
continue
}
aliasFound.push(resolve('/', target))
}
const entries = await handler.list(targetDataRepository, {
ignoreMissing: true,
prependDir: true,
})
entries.forEach(async entry => {
if (!aliasFound.includes(entry)) {
onLog(`the Vhd ${entry} is not referenced by a an alias`)
if (remove) {
await VhdAbstract.unlink(handler, entry)
}
}
})
}
exports.checkAliases = checkAliases
const defaultMergeLimiter = limitConcurrency(1)
exports.cleanVm = async function cleanVm(
@@ -129,17 +202,16 @@ exports.cleanVm = async function cleanVm(
const handler = this._handler
const vhds = new Set()
const vhdsToJSons = new Set()
const vhdParents = { __proto__: null }
const vhdChildren = { __proto__: null }
const vhdsList = await listVhds(handler, vmDir)
const { vhds, interruptedVhds, aliases } = await listVhds(handler, vmDir)
// remove broken VHDs
await asyncMap(vhdsList.vhds, async path => {
await asyncMap(vhds, async path => {
try {
await Disposable.use(openVhd(handler, path, { checkSecondFooter: !vhdsList.interruptedVhds.has(path) }), vhd => {
vhds.add(path)
await Disposable.use(openVhd(handler, path, { checkSecondFooter: !interruptedVhds.has(path) }), vhd => {
if (vhd.footer.diskType === DISK_TYPES.DIFFERENCING) {
const parent = resolve('/', dirname(path), vhd.header.parentUnicodeName)
vhdParents[path] = parent
@@ -154,6 +226,7 @@ exports.cleanVm = async function cleanVm(
}
})
} catch (error) {
vhds.delete(path)
onLog(`error while checking the VHD with path ${path}`, { error })
if (error?.code === 'ERR_ASSERTION' && remove) {
onLog(`deleting broken ${path}`)
@@ -162,7 +235,28 @@ exports.cleanVm = async function cleanVm(
}
})
// @todo : add check for data folder of alias not referenced in a valid alias
// remove interrupted merge states for missing VHDs
for (const interruptedVhd of interruptedVhds.keys()) {
if (!vhds.has(interruptedVhd)) {
const statePath = interruptedVhds.get(interruptedVhd)
interruptedVhds.delete(interruptedVhd)
onLog('orphan merge state', {
mergeStatePath: statePath,
missingVhdPath: interruptedVhd,
})
if (remove) {
onLog(`deleting orphan merge state ${statePath}`)
await handler.unlink(statePath)
}
}
}
// check if alias are correct
// check if all vhd in data subfolder have a corresponding alias
await asyncMap(Object.keys(aliases), async dir => {
await checkAliases(aliases[dir], `${dir}/data`, { handler, onLog, remove })
})
// remove VHDs with missing ancestors
{
@@ -202,7 +296,7 @@ exports.cleanVm = async function cleanVm(
await Promise.all(deletions)
}
const jsons = []
const jsons = new Set()
const xvas = new Set()
const xvaSums = []
const entries = await handler.list(vmDir, {
@@ -210,7 +304,7 @@ exports.cleanVm = async function cleanVm(
})
entries.forEach(path => {
if (isMetadataFile(path)) {
jsons.push(path)
jsons.add(path)
} else if (isXvaFile(path)) {
xvas.add(path)
} else if (isXvaSumFile(path)) {
@@ -232,22 +326,25 @@ exports.cleanVm = async function cleanVm(
// compile the list of unused XVAs and VHDs, and remove backup metadata which
// reference a missing XVA/VHD
await asyncMap(jsons, async json => {
const metadata = JSON.parse(await handler.readFile(json))
let metadata
try {
metadata = JSON.parse(await handler.readFile(json))
} catch (error) {
onLog(`failed to read metadata file ${json}`, { error })
jsons.delete(json)
return
}
const { mode } = metadata
let size
if (mode === 'full') {
const linkedXva = resolve('/', vmDir, metadata.xva)
if (xvas.has(linkedXva)) {
unusedXvas.delete(linkedXva)
size = await handler.getSize(linkedXva).catch(error => {
onLog(`failed to get size of ${json}`, { error })
})
} else {
onLog(`the XVA linked to the metadata ${json} is missing`)
if (remove) {
onLog(`deleting incomplete backup ${json}`)
jsons.delete(json)
await handler.unlink(json)
}
}
@@ -256,50 +353,25 @@ exports.cleanVm = async function cleanVm(
const { vhds } = metadata
return Object.keys(vhds).map(key => resolve('/', vmDir, vhds[key]))
})()
const missingVhds = linkedVhds.filter(_ => !vhds.has(_))
// FIXME: find better approach by keeping as much of the backup as
// possible (existing disks) even if one disk is missing
if (linkedVhds.every(_ => vhds.has(_))) {
if (missingVhds.length === 0) {
linkedVhds.forEach(_ => unusedVhds.delete(_))
// checking the size of a vhd directory is costly
// 1 Http Query per 1000 blocks
// we only check size of all the vhd are VhdFiles
const shouldComputeSize = linkedVhds.every(vhd => vhd instanceof VhdFile)
if (shouldComputeSize) {
try {
await Disposable.use(Disposable.all(linkedVhds.map(vhdPath => openVhd(handler, vhdPath))), async vhds => {
const sizes = await asyncMap(vhds, vhd => vhd.getSize())
size = sum(sizes)
})
} catch (error) {
onLog(`failed to get size of ${json}`, { error })
}
}
linkedVhds.forEach(path => {
vhdsToJSons[path] = json
})
} else {
onLog(`Some VHDs linked to the metadata ${json} are missing`)
onLog(`Some VHDs linked to the metadata ${json} are missing`, { missingVhds })
if (remove) {
onLog(`deleting incomplete backup ${json}`)
jsons.delete(json)
await handler.unlink(json)
}
}
}
const metadataSize = metadata.size
if (size !== undefined && metadataSize !== size) {
onLog(`incorrect size in metadata: ${metadataSize ?? 'none'} instead of ${size}`)
// don't update if the the stored size is greater than found files,
// it can indicates a problem
if (fixMetadata && (metadataSize === undefined || metadataSize < size)) {
try {
metadata.size = size
await handler.writeFile(json, JSON.stringify(metadata), { flags: 'w' })
} catch (error) {
onLog(`failed to update size in backup metadata ${json}`, { error })
}
}
}
})
// TODO: parallelize by vm/job/vdi
@@ -347,9 +419,9 @@ exports.cleanVm = async function cleanVm(
})
// merge interrupted VHDs
vhdsList.interruptedVhds.forEach(parent => {
for (const parent of interruptedVhds.keys()) {
vhdChainsToMerge[parent] = [vhdChildren[parent], parent]
})
}
Object.values(vhdChainsToMerge).forEach(chain => {
if (chain !== undefined) {
@@ -358,9 +430,15 @@ exports.cleanVm = async function cleanVm(
})
}
const doMerge = () => {
const promise = asyncMap(toMerge, async chain => limitedMergeVhdChain(chain, { handler, onLog, remove, merge }))
return merge ? promise.then(sizes => ({ size: sum(sizes) })) : promise
const metadataWithMergedVhd = {}
const doMerge = async () => {
await asyncMap(toMerge, async chain => {
const merged = await limitedMergeVhdChain(chain, { handler, onLog, remove, merge })
if (merged !== undefined) {
const metadataPath = vhdsToJSons[chain[0]] // all the chain should have the same metada file
metadataWithMergedVhd[metadataPath] = true
}
})
}
await Promise.all([
@@ -385,6 +463,52 @@ exports.cleanVm = async function cleanVm(
}),
])
// update size for delta metadata with merged VHD
// check for the other that the size is the same as the real file size
await asyncMap(jsons, async metadataPath => {
const metadata = JSON.parse(await handler.readFile(metadataPath))
let fileSystemSize
const merged = metadataWithMergedVhd[metadataPath] !== undefined
const { mode, size, vhds, xva } = metadata
try {
if (mode === 'full') {
// a full backup : check size
const linkedXva = resolve('/', vmDir, xva)
fileSystemSize = await handler.getSize(linkedXva)
} else if (mode === 'delta') {
const linkedVhds = Object.keys(vhds).map(key => resolve('/', vmDir, vhds[key]))
fileSystemSize = await computeVhdsSize(handler, linkedVhds)
// the size is not computed in some cases (e.g. VhdDirectory)
if (fileSystemSize === undefined) {
return
}
// don't warn if the size has changed after a merge
if (!merged && fileSystemSize !== size) {
onLog(`incorrect size in metadata: ${size ?? 'none'} instead of ${fileSystemSize}`)
}
}
} catch (error) {
onLog(`failed to get size of ${metadataPath}`, { error })
return
}
// systematically update size after a merge
if ((merged || fixMetadata) && size !== fileSystemSize) {
metadata.size = fileSystemSize
try {
await handler.writeFile(metadataPath, JSON.stringify(metadata), { flags: 'w' })
} catch (error) {
onLog(`failed to update size in backup metadata ${metadataPath} after merge`, { error })
}
}
})
return {
// boolean whether some VHDs were merged (or should be merged)
merge: toMerge.length !== 0,

View File

@@ -1,7 +1,9 @@
'use strict'
const compareVersions = require('compare-versions')
const find = require('lodash/find.js')
const groupBy = require('lodash/groupBy.js')
const ignoreErrors = require('promise-toolbox/ignoreErrors.js')
const ignoreErrors = require('promise-toolbox/ignoreErrors')
const omit = require('lodash/omit.js')
const { asyncMap } = require('@xen-orchestra/async-map')
const { CancelToken } = require('promise-toolbox')
@@ -9,6 +11,8 @@ const { createVhdStreamWithLength } = require('vhd-lib')
const { defer } = require('golike-defer')
const { cancelableMap } = require('./_cancelableMap.js')
const { Task } = require('./Task.js')
const { pick } = require('lodash')
const TAG_BASE_DELTA = 'xo:base_delta'
exports.TAG_BASE_DELTA = TAG_BASE_DELTA
@@ -17,6 +21,17 @@ const TAG_COPY_SRC = 'xo:copy_of'
exports.TAG_COPY_SRC = TAG_COPY_SRC
const ensureArray = value => (value === undefined ? [] : Array.isArray(value) ? value : [value])
const resolveUuid = async (xapi, cache, uuid, type) => {
if (uuid == null) {
return uuid
}
let ref = cache.get(uuid)
if (ref === undefined) {
ref = await xapi.call(`${type}.get_by_uuid`, uuid)
cache.set(uuid, ref)
}
return ref
}
exports.exportDeltaVm = async function exportDeltaVm(
vm,
@@ -165,6 +180,12 @@ exports.importDeltaVm = defer(async function importDeltaVm(
}
}
const cache = new Map()
const mapVdisSrRefs = {}
for (const [vdiUuid, srUuid] of Object.entries(mapVdisSrs)) {
mapVdisSrRefs[vdiUuid] = await resolveUuid(xapi, cache, srUuid, 'SR')
}
const baseVdis = {}
baseVm &&
baseVm.$VBDs.forEach(vbd => {
@@ -179,19 +200,25 @@ exports.importDeltaVm = defer(async function importDeltaVm(
let suspendVdi
if (vmRecord.power_state === 'Suspended') {
const vdi = vdiRecords[vmRecord.suspend_VDI]
suspendVdi = await xapi.getRecord(
'VDI',
await xapi.VDI_create({
...vdi,
other_config: {
...vdi.other_config,
[TAG_BASE_DELTA]: undefined,
[TAG_COPY_SRC]: vdi.uuid,
},
sr: mapVdisSrs[vdi.uuid] ?? sr.$ref,
if (vdi === undefined) {
Task.warning('Suspend VDI not available for this suspended VM', {
vm: pick(vmRecord, 'uuid', 'name_label'),
})
)
$defer.onFailure(() => suspendVdi.$destroy())
} else {
suspendVdi = await xapi.getRecord(
'VDI',
await xapi.VDI_create({
...vdi,
other_config: {
...vdi.other_config,
[TAG_BASE_DELTA]: undefined,
[TAG_COPY_SRC]: vdi.uuid,
},
sr: mapVdisSrRefs[vdi.uuid] ?? sr.$ref,
})
)
$defer.onFailure(() => suspendVdi.$destroy())
}
}
// 1. Create the VM.
@@ -255,7 +282,7 @@ exports.importDeltaVm = defer(async function importDeltaVm(
[TAG_BASE_DELTA]: undefined,
[TAG_COPY_SRC]: vdi.uuid,
},
SR: mapVdisSrs[vdi.uuid] ?? sr.$ref,
SR: mapVdisSrRefs[vdi.uuid] ?? sr.$ref,
})
)
$defer.onFailure(() => newVdi.$destroy())

View File

@@ -1,3 +1,5 @@
'use strict'
exports.extractIdsFromSimplePattern = function extractIdsFromSimplePattern(pattern) {
if (pattern === undefined) {
return []

View File

@@ -1,3 +1,5 @@
'use strict'
const { utcFormat, utcParse } = require('d3-time-format')
// Format a date in ISO 8601 in a safe way to be used in filenames

View File

@@ -1,3 +1,5 @@
'use strict'
const eos = require('end-of-stream')
const { PassThrough } = require('stream')

View File

@@ -1,3 +1,5 @@
'use strict'
// returns all entries but the last retention-th
exports.getOldEntries = function getOldEntries(retention, entries) {
return entries === undefined ? [] : retention > 0 ? entries.slice(0, -retention) : entries

View File

@@ -1,4 +1,6 @@
const Disposable = require('promise-toolbox/Disposable.js')
'use strict'
const Disposable = require('promise-toolbox/Disposable')
const { join } = require('path')
const { mkdir, rmdir } = require('fs-extra')
const { tmpdir } = require('os')

View File

@@ -1,3 +1,5 @@
'use strict'
const BACKUP_DIR = 'xo-vm-backups'
exports.BACKUP_DIR = BACKUP_DIR

View File

@@ -1,11 +1,26 @@
'use strict'
const assert = require('assert')
const isGzipFile = async (handler, fd) => {
const COMPRESSED_MAGIC_NUMBERS = [
// https://tools.ietf.org/html/rfc1952.html#page-5
const magicNumber = Buffer.allocUnsafe(2)
Buffer.from('1F8B', 'hex'),
assert.strictEqual((await handler.read(fd, magicNumber, 0)).bytesRead, magicNumber.length)
return magicNumber[0] === 31 && magicNumber[1] === 139
// https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#zstandard-frames
Buffer.from('28B52FFD', 'hex'),
]
const MAGIC_NUMBER_MAX_LENGTH = Math.max(...COMPRESSED_MAGIC_NUMBERS.map(_ => _.length))
const isCompressedFile = async (handler, fd) => {
const header = Buffer.allocUnsafe(MAGIC_NUMBER_MAX_LENGTH)
assert.strictEqual((await handler.read(fd, header, 0)).bytesRead, header.length)
for (const magicNumber of COMPRESSED_MAGIC_NUMBERS) {
if (magicNumber.compare(header, 0, magicNumber.length) === 0) {
return true
}
}
return false
}
// TODO: better check?
@@ -43,8 +58,8 @@ async function isValidXva(path) {
return false
}
return (await isGzipFile(handler, fd))
? true // gzip files cannot be validated at this time
return (await isCompressedFile(handler, fd))
? true // compressed files cannot be validated at this time
: await isValidTar(handler, size, fd)
} finally {
handler.closeFile(fd).catch(noop)

View File

@@ -1,4 +1,6 @@
const fromCallback = require('promise-toolbox/fromCallback.js')
'use strict'
const fromCallback = require('promise-toolbox/fromCallback')
const { createLogger } = require('@xen-orchestra/log')
const { createParser } = require('parse-pairs')
const { execFile } = require('child_process')

View File

@@ -1,4 +1,6 @@
const fromCallback = require('promise-toolbox/fromCallback.js')
'use strict'
const fromCallback = require('promise-toolbox/fromCallback')
const { createParser } = require('parse-pairs')
const { execFile } = require('child_process')

View File

@@ -1,3 +1,5 @@
'use strict'
exports.watchStreamSize = function watchStreamSize(stream, container = { size: 0 }) {
stream.on('data', data => {
container.size += data.length

View File

@@ -0,0 +1,52 @@
- [File structure on remote](#file-structure-on-remote)
- [Structure of `metadata.json`](#structure-of-metadatajson)
- [Task logs](#task-logs)
- [During backup](#during-backup)
## File structure on remote
```
<remote>
├─ xo-config-backups
│ └─ <schedule ID>
│ └─ <YYYYMMDD>T<HHmmss>
│ ├─ metadata.json
│ └─ data.json
└─ xo-pool-metadata-backups
└─ <schedule ID>
└─ <pool UUID>
└─ <YYYYMMDD>T<HHmmss>
├─ metadata.json
└─ data
```
## Structure of `metadata.json`
```ts
interface Metadata {
jobId: String
jobName: String
scheduleId: String
scheduleName: String
timestamp: number
pool?: Pool
poolMaster?: Host
}
```
## Task logs
### During backup
```
job.start(data: { reportWhen: ReportWhen })
├─ task.start(data: { type: 'pool', id: string, pool?: Pool, poolMaster?: Host })
│ ├─ task.start(data: { type: 'remote', id: string })
│ │ └─ task.end
│ └─ task.end
├─ task.start(data: { type: 'xo' })
│ ├─ task.start(data: { type: 'remote', id: string })
│ │ └─ task.end
│ └─ task.end
└─ job.end
```

View File

@@ -0,0 +1,97 @@
- [File structure on remote](#file-structure-on-remote)
- [Attributes](#attributes)
- [Of created snapshots](#of-created-snapshots)
- [Of created VMs and snapshots](#of-created-vms-and-snapshots)
- [Of created VMs](#of-created-vms)
- [Task logs](#task-logs)
- [During backup](#during-backup)
- [During restoration](#during-restoration)
## File structure on remote
```
<remote>
└─ xo-vm-backups
├─ index.json // TODO
└─ <VM UUID>
├─ index.json // TODO
├─ vdis
│ └─ <job UUID>
│ └─ <VDI UUID>
│ ├─ index.json // TODO
│ └─ <YYYYMMDD>T<HHmmss>.vhd
├─ <YYYYMMDD>T<HHmmss>.json // backup metadata
├─ <YYYYMMDD>T<HHmmss>.xva
└─ <YYYYMMDD>T<HHmmss>.xva.checksum
```
## Attributes
### Of created snapshots
- `other_config`:
- `xo:backup:deltaChainLength` = n (number of delta copies/replicated since a full)
- `xo:backup:exported` = 'true' (added at the end of the backup)
### Of created VMs and snapshots
- `other_config`:
- `xo:backup:datetime`: format is UTC %Y%m%dT%H:%M:%SZ
- from snapshots: snapshot.snapshot_time
- with offline backup: formatDateTime(Date.now())
- `xo:backup:job` = job.id
- `xo:backup:schedule` = schedule.id
- `xo:backup:vm` = vm.uuid
### Of created VMs
- `name_label`: `${original name} - ${job name} - (${safeDateFormat(backup timestamp)})`
- tag:
- copy in delta mode: `Continuous Replication`
- copy in full mode: `Disaster Recovery`
- imported from backup: `restored from backup`
- `blocked_operations.start`: message
- for copies/replications only, added after complete transfer
- `other_config[xo:backup:sr]` = sr.uuid
## Task logs
### During backup
```
job.start(data: { mode: Mode, reportWhen: ReportWhen })
├─ task.info(message: 'vms', data: { vms: string[] })
├─ task.warning(message: string)
├─ task.start(data: { type: 'VM', id: string })
│ ├─ task.warning(message: string)
│ ├─ task.start(message: 'snapshot')
│ │ └─ task.end
│ ├─ task.start(message: 'export', data: { type: 'SR' | 'remote', id: string })
│ │ ├─ task.warning(message: string)
│ │ ├─ task.start(message: 'transfer')
│ │ │ ├─ task.warning(message: string)
│ │ │ └─ task.end(result: { size: number })
│ │ │
│ │ │ // in case of full backup, DR and CR
│ │ ├─ task.start(message: 'clean')
│ │ │ ├─ task.warning(message: string)
│ │ │ └─ task.end
│ │ │
│ │ │ // in case of delta backup
│ │ ├─ task.start(message: 'merge')
│ │ │ ├─ task.warning(message: string)
│ │ │ └─ task.end(result: { size: number })
│ │ │
│ │ └─ task.end
│ └─ task.end
└─ job.end
```
### During restoration
```
task.start(message: 'restore', data: { jobId: string, srId: string, time: number })
├─ task.start(message: 'transfer')
│ └─ task.end(result: { id: string, size: number })
└─ task.end
```

View File

@@ -1,3 +1,5 @@
'use strict'
const mapValues = require('lodash/mapValues.js')
const { dirname } = require('path')

View File

@@ -1,5 +1,7 @@
#!/usr/bin/env node
'use strict'
const { catchGlobalErrors } = require('@xen-orchestra/log/configure.js')
const { createLogger } = require('@xen-orchestra/log')
const { getSyncedHandler } = require('@xen-orchestra/fs')
@@ -41,13 +43,32 @@ const main = Disposable.wrap(async function* main(args) {
let taskFiles
while ((taskFiles = await listRetry()) !== undefined) {
const taskFileBasename = min(taskFiles)
const previousTaskFile = join(CLEAN_VM_QUEUE, taskFileBasename)
const taskFile = join(CLEAN_VM_QUEUE, '_' + taskFileBasename)
// move this task to the end
await handler.rename(join(CLEAN_VM_QUEUE, taskFileBasename), taskFile)
try {
await handler.rename(previousTaskFile, taskFile)
} catch (error) {
// this error occurs if the task failed too many times (i.e. too many `_` prefixes)
// there is nothing more that can be done
if (error.code === 'ENAMETOOLONG') {
await handler.unlink(previousTaskFile)
}
throw error
}
try {
const vmDir = getVmBackupDir(String(await handler.readFile(taskFile)))
await adapter.cleanVm(vmDir, { merge: true, onLog: info, remove: true })
try {
await adapter.cleanVm(vmDir, { merge: true, onLog: info, remove: true })
} catch (error) {
// consider the clean successful if the VM dir is missing
if (error.code !== 'ENOENT') {
throw error
}
}
handler.unlink(taskFile).catch(error => warn('deleting task failure', { error }))
} catch (error) {

View File

@@ -1,3 +1,5 @@
'use strict'
const { join, resolve } = require('path')
const { spawn } = require('child_process')
const { check } = require('proper-lockfile')

View File

@@ -8,7 +8,7 @@
"type": "git",
"url": "https://github.com/vatesfr/xen-orchestra.git"
},
"version": "0.16.0",
"version": "0.21.0",
"engines": {
"node": ">=14.6"
},
@@ -16,11 +16,12 @@
"postversion": "npm publish --access public"
},
"dependencies": {
"@vates/compose": "^2.0.0",
"@vates/compose": "^2.1.0",
"@vates/decorate-with": "^2.0.0",
"@vates/disposable": "^0.1.1",
"@vates/parse-duration": "^0.1.1",
"@xen-orchestra/async-map": "^0.1.2",
"@xen-orchestra/fs": "^0.19.1",
"@xen-orchestra/fs": "^1.0.0",
"@xen-orchestra/log": "^0.3.0",
"@xen-orchestra/template": "^0.1.0",
"compare-versions": "^4.0.1",
@@ -32,15 +33,18 @@
"lodash": "^4.17.20",
"node-zone": "^0.4.0",
"parse-pairs": "^1.1.0",
"promise-toolbox": "^0.20.0",
"promise-toolbox": "^0.21.0",
"proper-lockfile": "^4.1.2",
"pump": "^3.0.0",
"uuid": "^8.3.2",
"vhd-lib": "^2.0.1",
"vhd-lib": "^3.1.0",
"yazl": "^2.5.1"
},
"devDependencies": {
"rimraf": "^3.0.2",
"tmp": "^0.2.1"
},
"peerDependencies": {
"@xen-orchestra/xapi": "^0.8.4"
"@xen-orchestra/xapi": "^0.10.0"
},
"license": "AGPL-3.0-or-later",
"author": {

View File

@@ -1,3 +1,5 @@
'use strict'
const { DIR_XO_CONFIG_BACKUPS, DIR_XO_POOL_METADATA_BACKUPS } = require('./RemoteAdapter.js')
exports.parseMetadataBackupId = function parseMetadataBackupId(backupId) {

View File

@@ -1,3 +1,5 @@
'use strict'
const path = require('path')
const { createLogger } = require('@xen-orchestra/log')
const { fork } = require('child_process')

View File

@@ -1,3 +1,5 @@
'use strict'
// a valid footer of a 2
exports.VHDFOOTER = {
cookie: 'conectix',

View File

@@ -1,7 +1,9 @@
'use strict'
const assert = require('assert')
const map = require('lodash/map.js')
const mapValues = require('lodash/mapValues.js')
const ignoreErrors = require('promise-toolbox/ignoreErrors.js')
const ignoreErrors = require('promise-toolbox/ignoreErrors')
const { asyncMap } = require('@xen-orchestra/async-map')
const { chainVhd, checkVhdChain, openVhd, VhdAbstract } = require('vhd-lib')
const { createLogger } = require('@xen-orchestra/log')
@@ -24,6 +26,7 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
async checkBaseVdis(baseUuidToSrcVdi) {
const { handler } = this._adapter
const backup = this._backup
const adapter = this._adapter
const backupDir = getVmBackupDir(backup.vm.uuid)
const vdisDir = `${backupDir}/vdis/${backup.job.id}`
@@ -35,13 +38,18 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
filter: _ => _[0] !== '.' && _.endsWith('.vhd'),
prependDir: true,
})
const packedBaseUuid = packUuid(baseUuid)
await asyncMap(vhds, async path => {
try {
await checkVhdChain(handler, path)
await Disposable.use(
openVhd(handler, path),
vhd => (found = found || vhd.footer.uuid.equals(packUuid(baseUuid)))
)
// Warning, this should not be written as found = found || await adapter.isMergeableParent(packedBaseUuid, path)
//
// since all the checks of a path are done in parallel, found would be containing
// only the last answer of isMergeableParent which is probably not the right one
// this led to the support tickets https://help.vates.fr/#ticket/zoom/4751 , 4729, 4665 and 4300
const isMergeable = await adapter.isMergeableParent(packedBaseUuid, path)
found = found || isMergeable
} catch (error) {
warn('checkBaseVdis', { error })
await ignoreErrors.call(VhdAbstract.unlink(handler, path))

View File

@@ -1,5 +1,7 @@
'use strict'
const { asyncMap, asyncMapSettled } = require('@xen-orchestra/async-map')
const ignoreErrors = require('promise-toolbox/ignoreErrors.js')
const ignoreErrors = require('promise-toolbox/ignoreErrors')
const { formatDateTime } = require('@xen-orchestra/xapi')
const { formatFilenameDate } = require('../_filenameDate.js')

View File

@@ -1,3 +1,5 @@
'use strict'
const { formatFilenameDate } = require('../_filenameDate.js')
const { getOldEntries } = require('../_getOldEntries.js')
const { getVmBackupDir } = require('../_getVmBackupDir.js')

Some files were not shown because too many files have changed in this diff Show More