3116 Commits

Author SHA1 Message Date
Daan Hoogland
2d1d2944e5 merge release branch 4.17 into main 2023-01-09 12:57:40 +01:00
Abhishek Kumar
eb5c8a5a8c
server: correctly list suitable hosts for migration with uefi capability (#7024)
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2023-01-09 11:03:10 +01:00
Sina Kashipazha
20306d6129
Allow creating atmost 1 physical network with null tag (#6781) 2023-01-05 21:36:31 +01:00
Wei Zhou
1380c604b1
server: add Host Control Plane State to uservm and systemvm response (#6946)
Co-authored-by: dahn <daan.hoogland@gmail.com>
2023-01-05 09:59:28 +01:00
Abhishek Kumar
d0b34b7576
test: fix NetworkOrchestrator unit test failure (#7049)
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2023-01-04 13:30:05 +01:00
Pearl Dsilva
3044d63a8b
Configurable MTU for VR (#6426)
Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2023-01-04 09:42:24 +01:00
dahn
af59e76df6
add index to speed up querying IPs in the network-tab (#7028)
* procedure to add index and add index

* sloppy mistakes, thanks Wei

Co-authored-by: Wei Zhou <weizhou@apache.org>

Co-authored-by: Wei Zhou <weizhou@apache.org>
2023-01-03 20:57:05 +01:00
João Jandre
4133f0e979
Update usage when scaling vms (#7011) 2022-12-31 14:48:36 +01:00
Wei Zhou
0bedb58fbe
engine/orchestration: enable unit tests and fix errors (#7034)
The unit tests in engine/orchestration module are skipped for now.

This PR enables the unit tests and fixes the errors with the unit tests.
2022-12-30 16:03:36 +05:30
Wei Zhou
512aa9cbc5
AutoScaling: update smoke test and consider db upgrade from a fork (#6977) 2022-12-21 09:31:55 +01:00
Wei Zhou
889045fba5
new plugins: Add non-strict affinity groups (#6845) 2022-12-20 15:09:52 +01:00
dahn
41717b0977
allow a new upgrade version without DB changes to be inserted (#6858) 2022-12-19 11:03:07 +01:00
Rohit Yadav
458883575a Updating pom.xml version numbers for release 4.17.3.0-SNAPSHOT
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-12-16 15:25:16 +00:00
GaOrtiga
8fd4ed88c2
delete configuration task.cleanup.retry.interval (#6910)
* fix range of configuration `task.cleanup.retry.interval`

* delete unused configuration

* fix on sql

* add name of the PR to the sql

Co-authored-by: Gabriel Ortiga Fernandes <gabriel.fernandes@scclouds.com.br>
2022-12-14 18:09:02 -03:00
Rohit Yadav
5b9a989ab0 Updating pom.xml version numbers for release 4.17.2.0
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-12-14 05:22:52 +00:00
John Bampton
def7ce655d
Fix spelling (#6898)
Co-authored-by: davidjumani <dj.davidjumani1994@gmail.com>
2022-12-13 14:58:14 +01:00
Marcus Sorensen
f2e7d6b90e
Allow ssvm agent certs to contain host IP for NAT situations (#6864)
Co-authored-by: Marcus Sorensen <mls@apple.com>
2022-12-13 10:58:43 +01:00
Rohit Yadav
72b6ab9c51 Merge remote-tracking branch 'origin/4.17' into main
Due to merge conflict, and schema changes in 4.17 branch the previous
4.17.1->4.18.0 DB upgrade path class was renamed to 4.17.2->4.18.0

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-12-13 07:50:36 +00:00
Rohit Yadav
d331b2f98f
schema: Add upgrade path from 4.17.1.0 to 4.17.2.0 (#6981)
This implements a blank/noop upgrade path from 4.17.1.0 to 4.17.2.0
which implements DbUpgradeSystemVmTemplate to kick the systemvm template
upgrade.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-12-13 12:42:20 +05:30
Daniel Augusto Veronezi Salvador
ed1ac1c161
schema: Fix migration path (#6927)
PR #5909 was created before the announce of release 4.17.1.0 and the changes in the databases were addressed in the 4.17.0.0 -> 4.18.0.0 migration path. However, #5909 was merged after 4.17.1.0 releasing, with the original migration path.

This PR intends to fix the migration path of PR #5909.

Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
2022-12-12 12:42:34 +05:30
Rohit Yadav
44e13900e6
schema: Add upgrade path from 4.17.2.0 same as 4.17.1.0 (#6965)
There's no DB upgrade path b/w 4.17.1.0 and 4.17.2.0, this adds the
same upgrade path of 4.17.1.0 when source version is 4.17.2.0.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-12-12 12:38:57 +05:30
mprokopchuk
ffe2fa51d5
When VM is created and ROOT volume is created it should emit a VOLUME.CREATE event (#6939)
* When VM is created and ROOT volume is created it should emit a VOLUME.CREATE event

Co-authored-by: Maxim Prokopchuk <mprokopchuk@apple.com>
2022-12-08 09:14:17 -07:00
João Jandre
7c61d8aeaf
Set root volume as destroyed when destroying a VM (#6868)
* Set root volume as destroyed when destroying a VM

* Address review

* Address review

Co-authored-by: João Jandre <joao@scclouds.com.br>
2022-12-06 17:48:35 -03:00
Wei Zhou
a63b2aba7a
VM Autoscaling with virtual router (#6571) 2022-12-05 15:23:03 +01:00
Rohit Yadav
3d8ea4f3b3 Merge remote-tracking branch 'origin/4.17'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2022-11-30 21:02:17 +05:30
Abhishek Kumar
c8d27765d8
orchestration: fix diskoffering for vr rootdisk (#6853)
Fixes incorrect call of using service offering's ID while trying to retrieve linked disk offering.

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>

Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-11-24 15:08:20 +05:30
John Bampton
e65c22d883
Fix spelling (#6860) 2022-11-13 10:56:15 +01:00
John Bampton
fa39e61a4c
Fix spelling (#6609) 2022-11-01 08:30:01 +01:00
João Jandre
14937e1adb
Fixed NPE on volume creation from snapshot (#6839)
Co-authored-by: João Jandre <joao@scclouds.com.br>
2022-10-26 08:44:01 +02:00
dahn
13d22c2f54
Set network state to implemented when no services (#6838)
Co-authored-by: Nicolas Vazquez <nicovazquez90@gmail.com>
Co-authored-by: Wei Zhou <weizhou@apache.org>
2022-10-24 08:59:17 +02:00
dahn
4a06363749
Ova download fix (#6758) 2022-10-21 14:31:19 +02:00
Daniel Augusto Veronezi Salvador
2ca164ac96
Quota custom tariffs (#5909)
Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
Co-authored-by: dahn <daan.hoogland@gmail.com>
2022-10-17 10:03:50 +02:00
Daniel Augusto Veronezi Salvador
7936eb04e9
server: Fix delete parent snapshot (#6630)
ACS + Xenserver works with differential snapshots. ACS takes a volume full snapshot and the next ones are referenced as a child of the previous snapshot until the chain reaches the limit defined in the global setting snapshot.delta.max; then, a new full snapshot is taken. PR #5297 introduced disk-only snapshots for KVM volumes. Among the changes, the delete process was also refactored. Before the changes, when one was removing a snapshot with children, ACS was marking it as Destroyed and it was keeping the Image entry on the table cloud.snapshot_store_ref as Ready. When ACS was rotating the snapshots (the max delta was reached) and all the children were already marked as removed; then, ACS would start removing the whole hierarchy, completing the differential snapshot cycle. After the changes, the snapshots with children stopped being marked as removed and the differential snapshot cycle was not being completed.

This PR intends to honor again the differential snapshot cycle for XenServer, making the snapshots to be marked as removed when deleted while having children and following the differential snapshot cycle.

Also, when one takes a volume snapshot and ACS backs it up to the secondary storage, ACS inserts 2 entries on table cloud.snapshot_store_ref (Primary and Image). When one deletes a volume snapshot, ACS first tries to remove the snapshot from the secondary storage and mark the entry Image as removed; then, it tries to remove the snapshot from the primary storage and mark the entry Primary as removed. If ACS cannot remove the snapshot from the primary storage, it will keep the snapshot as BackedUp; however, If it does not exist in the secondary storage and without the entry SNAPSHOT.DELETE on cloud.usage_event. In the end, after the garbage collector flow, the snapshot will be marked as BackedUp, with a value in the field removed and still being rated. This PR also addresses the correction for this situation.

Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
2022-10-13 12:31:11 +05:30
Eduardo Zanetta
5a54dc19b6
Rename validateUUID method to isUuid (#6793)
* Rename validateUUID method to isUuid

* adds JavaDoc to isUuid method

Co-authored-by: Eduardo Zanetta <eduardo.zanetta@scclouds.com.br>
2022-10-12 20:42:12 +02:00
GaOrtiga
8d276c0220
Improve description of secstorage.encrypt.copy (#6811)
The description of the configuration secstorage.encrypt.copy fails to mention that it is also used to make sure the certificate assigned to the zone is used when creating links for external access (download/upload of disks,templates and ISOs). This PR improves this description.

Co-authored-by: Gabriel Ortiga Fernandes <gabriel.fernandes@scclouds.com.br>
2022-10-11 21:16:36 +05:30
Daniel Augusto Veronezi Salvador
f7b29856d1
Refactor SnapshotDataStoreDaoImpl (#6751)
* Refactor SnapshotDataStoreDaoImpl and add unit tests

* Create constants for duplicated literals

* Refactor search builders

Co-authored-by: GutoVeronezi <daniel@scclouds.com.br>
Co-authored-by: dahn <daan.hoogland@gmail.com>
2022-10-11 13:53:02 +02:00
Codegass
69e158d77d
Refactor TestHttp.testHttpclient to avoid the Exception Suppression (#6733)
* Refactor TestHttp.testHttpclient to avoid the Exception Suppression

* Remove the unnecessary import
2022-10-09 15:22:32 +05:30
Stephan Krug
b8d834e759
quota: Improves email configurations descriptions (#6806)
The alert.email.addresses description is ambiguous and can cause doubts to operators. This description has been altered to avoid confusion. In addition, typos in alert.smtp.useStartTLS and project.smtp.useStartTLS have been fixed.

Co-authored-by: Stephan Krug <stephan.krug@scclouds.com.br>
2022-10-08 11:59:55 +05:30
Harikrishna
713a236843
UserData as first class resource (#6202)
This PR introduces a new feature to make userdata as a first class resource much like existing SSH keys.

Detailed feature specification document:
https://cwiki.apache.org/confluence/display/CLOUDSTACK/Userdata+as+a+first+class+resource
2022-10-05 17:34:59 +05:30
Sina Kashipazha
4e2f461b31
Prometheus exporter enhancement (#4438)
* Export count of total/up/down hosts by tags

* Export count of vms by state and host tag.

* Add host tags to host cpu/cores/memory usage in Prometheus exporter

* Cloudstack Prometheus exporter: Add allocated capacity group by host tag.

* Show count of Active domains on grafana.

* Show count of Active accounts and vms by size on grafana

* Use prepared statement to query database for a number of VM who use a specific tag.

* Extract repeated codes to new methods.
2022-09-30 17:02:01 +02:00
João Jandre
8ab8fdc1db
Fix migrate volume permissions (#6224)
* changed when to show migrate volume button on the UI.

Co-authored-by: Joao <JoaoJandre@gitlab.com>
2022-09-27 10:26:07 +02:00
Marcus Sorensen
697e12f8f7
kvm: volume encryption feature (#6522)
This PR introduces a feature designed to allow CloudStack to manage a generic volume encryption setting. The encryption is handled transparently to the guest OS, and is intended to handle VM guest data encryption at rest and possibly over the wire, though the actual encryption implementation is up to the primary storage driver.

In some cases cloud customers may still prefer to maintain their own guest-level volume encryption, if they don't trust the cloud provider. However, for private cloud cases this greatly simplifies the guest OS experience in terms of running volume encryption for guests without the user having to manage keys, deal with key servers and guest booting being dependent on network connectivity to them (i.e. Tang), etc, especially in cases where users are attaching/detaching data disks and moving them between VMs occasionally.

The feature can be thought of as having two parts - the API/control plane (which includes scheduling aspects), and the storage driver implementation.

This initial PR adds the encryption setting to disk offerings and service offerings (for root volume), and implements encryption support for KVM SharedMountPoint, NFS, Local, and ScaleIO storage pools.

NOTE: While not required, operations can be significantly sped up by ensuring that hosts have the `rng-tools` package and service installed and running on the management server and hypervisors. For EL hosts the service is `rngd` and for Debian it is `rng-tools`. In particular, the use of SecureRandom for generating volume passphrases can be slow if there isn't a good source of entropy. This could affect testing and build environments, and otherwise would only affect users who actually use the encryption feature. If you find tests or volume creates blocking on encryption, check this first.

### Management Server

##### API

* createDiskOffering now has an 'encrypt' Boolean
* createServiceOffering now has an 'encryptroot' Boolean. The 'root' suffix is added here in case there is ever any other need to encrypt something related to the guest configuration, like the RAM of a VM.  This has been refactored to deal with the new separation of service offering from disk offering internally.
* listDiskOfferings shows encryption support on each offering, and has an encrypt boolean to choose to list only offerings that do or do not support encryption
* listServiceOfferings shows encryption support on each offering, and has an encrypt boolean to choose to list only offerings that do or do not support encryption
* listHosts now shows encryption support of each hypervisor host via `encryptionsupported`
* Volumes themselves don't show encryption on/off, rather the offering should be referenced. This follows the same pattern as other disk offering based settings such as the IOPS of the volume.

##### Volume functions

A decent effort has been made to ensure that the most common volume functions have either been cleanly supported or blocked. However, for the first release it is advised to mark this feature as *experimental*, as the code base is complex and there are certainly edge cases to be found.

Many of these features could eventually be supported over time, such as creating templates from encrypted volumes, but the effort and size of the change is already overwhelming.

Supported functions:
* Data Volume create
* VM root volume create
* VM root volume reinstall
* Offline volume snapshot/restore
* Migration of VM with storage (e.g. local storage VM migration)
* Resize volume
* Detach/attach volume

Blocked functions:
* Online volume snapshot
* VM snapshot w/memory
* Scheduled snapshots (would fail when VM is running)
* Disk offering migration to offerings that don't have matching encryption
* Creating template from encrypted volume
* Creating volume from encrypted volume
* Volume extraction (would we decrypt it first, or expose the key? Probably the former).

##### Primary Storage Support

For storage developers, adding encryption support involves:

1. Updating the `StoragePoolType` for your primary storage to advertise encryption support. This is used during allocation of storage to match storage types that support encryption to storage that supports it.

2. Implementing encryption feature when your `PrimaryDataStoreDriver` is called to perform volume lifecycle functions on volumes that are requesting encryption. You are free to do what your storage supports - this could be as simple as calling a storage API with the right flag when creating a volume. Or (as is the case with the KVM storage types), as complex as managing volume details directly at the hypervisor host. The data objects passed to the storage driver will contain volume passphrases, if encryption is requested.

##### Scheduling

For the KVM implementations specified above, we are dependent on the KVM hosts having support for volume encryption tools. As such, the hosts `StartupRoutingCommand` has been modified to advertise whether the host supports encryption. This is done via a probe during agent startup to look for functioning `cryptsetup` and support in `qemu-img`. This is also visible via the listHosts API and the host details in the UI.  This was patterned after other features that require hypervisor support such as UEFI.

The `EndPointSelector` interface and `DefaultEndpointSelector` have had new methods added, which allow the caller to ask for endpoints that support encryption.  This can be used by storage drivers to find the proper hosts to send storage commands that involve encryption. Not all volume activities will require a host to support encryption (for example a snapshot backup is a simple file copy), and this is the reason why the interface has been modified to allow for the storage driver to decide, rather than just passing the data objects to the EndpointSelector and letting the implementation decide.

VM scheduling has also been modified. When a VM start is requested, if any volume that requires encryption is attached, it will filter out hosts that don't support encryption.

##### DB Changes

A volume whose disk offering enables encryption will get a passphrase generated for it before its first use. This is stored in the new 'passphrase' table, and is encrypted using the CloudStack installation's standard configured DB encryption. A field has been added to the volumes table, referencing this passphrase, and a foreign key added to ensure passphrases that are referenced can't be removed from the database.  The volumes table now also contains an encryption format field, which is set by the implementer of the encryption and used as it sees fit.

#### KVM Agent

For the KVM storage pool types supported, the encryption has been implemented at Qemu itself, using the built-in LUKS storage support. This means that the storage remains encrypted all the way to the VM process, and decrypted before the block device is visible to the guest.  This may not be necessary in order to implement encryption for /your/ storage pool type, maybe you have a kernel driver that decrypts before the block device on the system, or something like that. However, it seemed like the simplest, common place to terminate the encryption, and provides the lowest surface area for decrypted guest data.

For qcow2 based storage, `qemu-img` is used to set up a qcow2 file with LUKS encryption. For block based (currently just ScaleIO storage), the `cryptsetup` utility is used to format the block device as LUKS for data disks, but `qemu-img` and its LUKS support is used for template copy.

Any volume that requires encryption will contain a passphrase ID as a byte array when handed down to the KVM agent. Care has been taken to ensure this doesn't get logged, and it is cleared after use in attempt to avoid exposing it before garbage collection occurs.  On the agent side, this passphrase is used in two ways:

1. In cases where the volume experiences some libvirt interaction it is loaded into libvirt as an ephemeral, private secret and then referenced by secret UUID in any libvirt XML. This applies to things like VM startup, migration preparation, etc.

2. In cases where `qemu-img` needs to use this passphrase for volume operations, it is written to a `KeyFile` on the cloudstack agent's configured tmpfs and passed along. The `KeyFile` is a `Closeable` and when it is closed, it is deleted. This allows us to try-with-resources any volume operations and get the KeyFile removed regardless.

In order to support the advanced syntax required to handle encryption and passphrases with `qemu-img`, the `QemuImg` utility has been modified to support the new `--object` and `--image-opts` flags. These are modeled as `QemuObject` and `QemuImageOptions`.  These `qemu-img` flags have been designed to supersede some of the existing, older flags being used today (such as choosing file formats and paths), and an effort could be made to switch over to these wholesale. However, for now we have instead opted to keep existing functions and do some wrapping to ensure backward compatibility, so callers of `QemuImg` can choose to use either way.

It should be noted that there are also a few different Enums that represent the encryption format for various purposes. While these are analogous in principle, they represent different things and should not be confused. For example, the supported encryption format strings for the `cryptsetup` utility has `LuksType.LUKS` while `QemuImg` has a `QemuImg.PhysicalDiskFormat.LUKS`.

Some additional effort could potentially be made to support advanced encryption configurations, such as choosing between LUKS1 and LUKS2 or changing cipher details. These may require changes all the way up through the control plane. However, in practice Libvirt and Qemu currently only support LUKS1 today. Additionally, the cipher details aren't required in order to use an encrypted volume, as they're stored in the LUKS header on the volume there is no need to store these elsewhere.  As such, we need only set the one encryption format upon volume creation, which is persisted in the volumes table and then available later as needed.  In the future when LUKS2 is standard and fully supported, we could move to it as the default and old volumes will still reference LUKS1 and have the headers on-disk to ensure they remain usable. We could also possibly support an automatic upgrade of the headers down the road, or a volume migration mechanism.

Every version of cryptsetup and qemu-img tested on variants of EL7 and Ubuntu that support encryption use the XTS-AES 256 cipher, which is the leading industry standard and widely used cipher today (e.g. BitLocker and FileVault).

Signed-off-by: Marcus Sorensen <mls@apple.com>
Co-authored-by: Marcus Sorensen <mls@apple.com>
2022-09-27 10:20:59 +05:30
João Jandre
efbf74ee06
Added new logs to volume creation (#6689)
Co-authored-by: João Paraquetti <joao@scclouds.com.br>
2022-09-26 19:11:14 -03:00
GaOrtiga
3889e46eb6
fix description of configuration max.data.migration.wait.time (#6749)
Co-authored-by: Gabriel Ortiga Fernandes <gabriel.fernandes@scclouds.com.br>
2022-09-24 20:27:34 +02:00
Abhishek Kumar
7905a76bd2 Merge remote-tracking branch 'apache/4.17' into main
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-09-23 17:14:59 +05:30
Rohit Yadav
dcffdc1c0b
DatabaseUpgradeChecker: add upgrade path from 4.17.0.1 to 4.17.1.0 (#6759)
Fixes DB upgrade for 4.17.0.1 to 4.17.1.0
2022-09-23 17:12:18 +05:30
Marcus Sorensen
1a0a61fd9f
Allow option of exposing VM domain info via instance metadata (#6710)
This PR allows the cloud admin to set either a global or domain-specific value "metadata.allow.expose.domain", and when set this allows the VM to see the name and ID of the immediate domain that contains the VM in instance metadata. This can be useful or a variety of things such as bootstrapping VM configuration and access according to domain.

This PR also deletes the CloudZonesNetworkElement because it isn't referred to anywhere, and there was initially some confusion as to whether this code needed to be updated when extending metadata. If it needs to be kept we can remove that delete from the PR.

Signed-off-by: Marcus Sorensen <mls@apple.com>
Co-authored-by: Marcus Sorensen <mls@apple.com>
Co-authored-by: dahn <daan.hoogland@gmail.com>
Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
2022-09-22 15:14:21 +05:30
Abhishek Kumar
d724a9d15c Updating pom.xml version numbers for release 4.17.2.0-SNAPSHOT
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-09-19 16:21:35 +05:30
dahn
bbc1260576
Resource reservation framework (#6694)
This PR addresses parallel resource allocation as a generalization of the problem and solution described in #6644. Instead of the Global lock on the resources a reservation record is created which is added in the resource check count in the ResourceLimitService/ResourceLimitManagerImpl. As a convenience a CheckedReservation is created. This is an implementation of AutoClosable and can be used as a guard in a try-with-resource fashion. The close method of the CheckedReservation wil delete the reservation record.

Co-authored-by: Boris Stoyanov - a.k.a Bobby <bss.stoyanov@gmail.com>
2022-09-16 15:44:35 +05:30
Abhishek Kumar
350ef38e1c Updating pom.xml version numbers for release 4.17.1.0
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
2022-09-14 12:58:03 +05:30