Commit Graph

239 Commits

Author SHA1 Message Date
Michal Nasiadka 38a0f41c94 SQLA 2.0 - Fix connection.execute
execute() in SQL Alchemy 2.x has different behaviour,
this patch adapts alembic scripts.
See [1].

[1]: https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#execute-method-more-strict-execution-options-are-more-prominent

Change-Id: I597eed6f24f13f96f78f6596e16b6edcff989a90
2024-03-02 07:30:50 +00:00
Michal Nasiadka d544698fae Remove use of autocommit
Change-Id: I6e973935edf5e754ba054e724b6963b6d5fd795a
2024-02-29 11:54:28 +00:00
Jake Yip 8a30ad3462 Add feature to specify driver explicitly
Allow ClusterTemplate to explicitly specify a driver to use for creating
Clusters.

This is initially sourced from the image property 'magnum_driver', but
may be improved to be specified via client in the future.

Falls back to old driver discovery using (coe, server_type, os) tuple to
keep existing behaviour.

Change-Id: I9e206b589951a02360d3cef0282a9538236ef53b
2024-02-26 14:50:18 +11:00
Takashi Kajinami 206d19ec52 Remove six from db module
This is part of the steps to remove usage of six library, which is no
longer needed since python 2 support was removed.

Change-Id: I529759167f960714ebf93be7b89ee849040361b2
2024-02-19 10:43:16 +00:00
Michal Nasiadka 021293d8f8 SQL Alchemy 2.x: Stop using deprecated API
This patch fixes magnum/db/sqlalchemy/models.py:99: MovedIn20Warning:
Deprecated API features detected! errors.

See [1].

[1]: https://docs.sqlalchemy.org/en/20/changelog/migration_20.html#migration-orm-configuration

Change-Id: I397fc59fefab86149a023ff8102e0823fa5ab6a7
2024-02-01 12:10:07 +00:00
Michal Nasiadka d18aa8ffa2 sqlalchemy: Import String from sqlalchemy directly
With dropping of MySQL NDB cluster support in oslo.db the String
subclass that implemented specific options is gone [1]

[1]: Ia8b4ed8cd755d283bb773e55293457190b34c482

Change-Id: I4ae0943a9cfdf6ed96bcd9ca54d98d008f6a5573
2023-09-27 12:48:55 +02:00
Diogo Guerra 11bcc17568 Drop bay and baymodel from magnum
- Drop bay and baymodel tests
- Drop bay and baymodel from controllers

Depends-On: Ib85e4fda8e4ac467bd49590dc72ba5913bb9a19d

Story: 2009104
Task: 42957
Task: 42959

Signed-off-by: Diogo Guerra <diogo.filipe.tomas.guerra@cern.ch>
Change-Id: Ida2e42c86400438951d9804e3ce122c56a46b94f
2023-05-09 13:59:57 +00:00
karolinku fd6f2d5238 Fix compatibility with oslo.db 12.1.0
oslo.db 12.1.0 has changed the default value for the 'autocommit'
parameter of 'LegacyEngineFacade' from 'True' to 'False'. This is a
necessary step to ensure compatibility with SQLAlchemy 2.0. However, we
are currently relying on the autocommit behavior and need changes to
explicitly manage sessions. Until that happens, we need to override the
default.

Also squashed change: [CI] move queue setting to project level

Jobs are currently not running. Fix as described in [1][2]

[1] https://lists.opendev.org/pipermail/service-announce/2022-September/000044.html
[2] https://lists.zuul-ci.org/pipermail/zuul-discuss/2022-May/001801.html

Story: 2010296
Co-Authored-By: Stephen Finucane <stephenfin@redhat.com>
Co-Authored-By: Jake Yip <jake.yip@ardc.edu.au>
Change-Id: I625500d9e6670a429c70a0f6d582d0865ce78fd1
2022-09-20 12:35:28 +00:00
Jake Yip cb40fb3685 Add back pep8 test
In Change I523a4a85867f82d234ba1f3e6fad8b8cd2291182, the pep8 test was
accidentally dropped.

Fix up code so that pep8 passes.

In addition to that following change has been added here to unbreak CI:

Add WebTest as an indirect test dependency

Pecan has made webtest an optional dependency for testing only [1].
Since it is still used for testing we need to add it to our
test-requirements.txt.

[1]: https://github.com/pecan/pecan/pull/140

Change-Id: I2f85adb4ef29a43389897c201e6152fd4c7be9d6
2022-07-19 12:35:14 +00:00
Stephen Crawley 5fca23f2fc Quota deletion bug fix
Due to a bug in the db api code for sqlalchemy, deleting a single
quota was actually deleting all existing quotas.

Change-Id: Ia588db99fad0276ca9c512799e4e8c89d29d42fb
2021-12-22 09:09:33 +11:00
Bharat Kunwar ba75dce28a Ensure backward compatibility with SQLAlchemy<1.4
In Ib6e3ed40dc8b075c3cecb967b7417097e3cab60d, a breaking change was
introduced to suppose SQLAlchemy 1.4.x but this PS ensures backward
compatibility with 1.3.x.

Change-Id: I73ef4f99f02abc8b1083860f34a8a8e084ad96fd
2021-06-29 15:44:53 +00:00
Bharat Kunwar b2e20a1143 Make code compatible with SQLAlchemy 1.4.18
Also, plugins do not need to enable any network service other than what
devstack is already doing [1].

Also, fix doc build:
- bump up tox minversion to 3.18
- set ignore_basepython_conflict to True [2]
- add tex-gyre to binddep.txt [3]

[1] https://review.opendev.org/c/openstack/devstack/+/791436
[2] a0ec2de968/tox.ini (L7)
[3] https://review.opendev.org/c/openstack/openstack-health/+/793984

Change-Id: Ib6e3ed40dc8b075c3cecb967b7417097e3cab60d
Co-authored-by: Ghanshyam Mann <gmann@ghanshyammann.com>
2021-06-28 12:26:19 +00:00
Feilong Wang 16344a5a95 Add separated CA cert for etcd and front-proxy
Support creating different for k8s, etcd and front-proxy for
security hardening. We're following some best practices[1][2] but
adjusted based on the current Magnum deployment approach.

[1] https://kubernetes.io/docs/setup/best-practices/certificates/
[2] https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/kubeadm-certs/

Task: 40687
Story: 2008031

Change-Id: I523a4a85867f82d234ba1f3e6fad8b8cd2291182
2021-04-01 17:31:34 +00:00
Zuul 8dcf91b2d3 Merge "Do not create constraints for boolean fields" 2021-02-11 22:47:11 +00:00
Diogo Guerra 332e2b6fe4 Add CT tags field to the database and API
We noticed that from the user perspective it is hard
to know when a cluster_template provided by the cloud
admin is mature enough for a production release.
This field will allow the administrator to add an
annotation to the cluster template like
{deprecated, recommended, testing} giving further
usefull information to the end user about the
template's life cycle

This patch adds the necessary database column and
API objects to handle the new argument.

story: 2007857
task: 40160

Change-Id: I5d1c4221f089bc5cd12b25f620aa01771a029df9
Signed-off-by: Diogo Guerra <diogo.filipe.tomas.guerra@cern.ch>
2021-02-05 22:45:47 +00:00
Spyros Trigazis bcf771bc6f Do not create constraints for boolean fields
On mysql 8, Boolean fields create constraints which later
make it impossible to alter the name of the column.
See: https://github.com/sqlalchemy/alembic/issues/699

Per upstream alembic recommendation, do not create constraints
explicitly.
https://github.com/sqlalchemy/alembic/issues/699#issuecomment-760983057

story: 2008488
task: 41537

Change-Id: I51659c6e179d7e4e2cfc5be46348fac483d76e3b
Signed-off-by: Spyros Trigazis <spyridon.trigazis@cern.ch>
2021-02-04 19:35:38 +01:00
Feilong Wang f5cf6b958c Fix database migrations
The pattern of adding a column and then reading a table with it
no longer works in SQLAlchemy 1.3.20. This has been reported
upstream [1].

[1] https://github.com/sqlalchemy/sqlalchemy/issues/5669

Change-Id: I5fd1deeef9cf70794bc61c101e1d7d4379d4b96b
2020-11-05 14:32:03 +13:00
Feilong Wang 946c1d67c7 Add master_lb_enabled to cluster
Adding the master_lb_enabled option when creating a cluster,
which will benefit both the cloud provider side and the end
user side. For cloud prodiver, they don't have to maintain
separate cluster templates with or w/o master_lb_enabled enabled.
For end user, they can easily use one single template to create
different clusters with different configs.

Task: 39680
Story: 2007634

Change-Id: I0b586f05168ece84fd340ef7493a56688191053d
2020-07-21 11:07:33 +12:00
Andreas Jaeger ae228bb5cc Update hacking for Python3
The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Update local hacking checks for new flake8.

Remove hacking and friends from lower-constraints, those are not needed
for co-installing.

Change-Id: I926efaef501f190e78da9cab40c1e94203277258
2020-03-31 20:09:46 +02:00
Theodoros Tsioutsias cbe05aa97d ng-6: Add new fields to nodegroup objects
Since each nodegroup will be one independent stack, we have to add
more fields to the table and object in order to track each stack
contained in the cluster. This adds the stack_id, version, status,
status_reason and version fields to the nodegroup object.

Change-Id: I6d36b2d3bc6476efbef6a9f702ffc73cfa0fab8c
2019-09-25 12:26:00 +00:00
Zuul c099128a61 Merge "Hardcode the names of the default NGs" 2019-09-03 10:22:57 +00:00
Feilong Wang 32989b4f7b Allow setting network, subnet and FIP when creating cluster
When using a public cluster template, user still need the capability
to reuse their existing network/subnet, and they also need to be
able to turn of/off the floatingip to overwrite the setting in the
public template. This patch supports that by adding those three
items as parameters when creating cluster.

Story: 2006208
Task: 35797

Change-Id: I11579ff6b83d133c71c2cbf49ee4b20996dfb918
2019-07-31 20:41:20 +12:00
Theodoros Tsioutsias a1d385cc4a Hardcode the names of the default NGs
As decided, the names of the default NGs should follow the convention
"default-<role>". This change fixes the migration responsible for
populating the default nodegroups.

Change-Id: I7a3ea4c14e1353a02ed91cfe47f89e2b00d802a1
Story: 2005953
Task: 34318
2019-06-25 15:53:20 +02:00
Theodoros Tsioutsias 3f80cbab06 ng-4: Adapt cluster object
This commit removes the fields node_addresses, master_addresses,
node_count and master_count from the cluster object since this info
will be stored in the nodegroups. At the same time, provides the way
to adapt existing clusters to the new schema.

story: 2005266

Change-Id: Iaf2cef3cc50b956c9b6d7bae13dbb716ae54eaf7
2019-03-29 10:31:48 +00:00
Theodoros Tsioutsias 0607c7a9d6 ng-1: Add nodegroup representation
This adds the object and db schema changes needed for supporting
nodegroups.

story: 2005266

Change-Id: Ibf10277a52aa94c4b217cf3b364844b04baab1e0
2019-03-21 16:19:56 +00:00
Ricardo Rocha 6aee864954 Add hidden flag to cluster template
Add a new hidden flag to cluster templates. This allows an operator to
keep a cluster public (accessible to all users) while not showing them
in cluster template listing.

Story: 2004941
Task: 29342

Change-Id: Ia2717ca960041753f6e772bf2d41c7f5a196dae6
2019-02-12 11:38:15 +01:00
Feilong Wang 766a64a41a Allow cluster template being renamed
To get a better cluster template versioning and relieve the pain
of maintaining public cluster template, the patch is proposing
that the name of cluster template can be changed.

A folllowing patch/spec will be proposed to add a new field
'deprecated' to allow ops to hide old/deprecated templates.

Task: 26889
Story: 2003960

Change-Id: Id1db81d35bc3dccff0fac481be7801de200d52de
2019-01-28 18:57:16 +00:00
Erik Olof Gunnar Andersson daf34d9df8 Use oslo_serialization instead of the json module directly
* Always use oslo jsonutils.
* Consistently import jsonutils as-is.
* Use dump_as_bytes instead of dumps.
https://wiki.openstack.org/wiki/Python3#Serialization:_base64.2C_JSON.2C_etc.

Change-Id: I2b65faa7df43a1d58205e8ff106ff62f73d78198
2019-01-21 16:28:03 -08:00
Feilong Wang d80febb384 Add health_status and health_status_reason to cluster
APIImpact
Related blueprint cluster-healing

Change-Id: I78d4d14fb064996de77bdd6a381d2df53a9488b8
2018-08-27 14:28:46 +12:00
oorgeron 0e6e27eb7a Enables MySQL Cluster Support for Magnum
This enables the usage of the mysql_enable_ndb setting
in oslo_db from bug 1564110. This allows operators to
select from MySQL (InnoDB) or MySQL Cluster (NDB)
as the storage engine backend. There are only two
tables that need to have their columns auto adjusted
to fit with in the 14k row width limit of NDB, cluster
and cluster_templates. The modifications here will
have zero affect on users of MySQL (InnoDB). Additionally,
this fix will auto adjust those tables in models.py
module to support this enhancement.

Closes-Bug: 1691514
Change-Id: Ia0584059f998baf3db4a44bccbb6f6ff8a058ae1
Depends-On: I7f9c830073bf9a30abce0aa4bb55b5c9cf661afe
2018-02-19 12:15:58 +00:00
Clenimar Filemon 34754f36f0 federation api: federation table and db layer
this commit introduces a new `Federation` table to
Magnum database, as well as the necessary DB layer
APIs to access and manage it.

this belongs to the first phase of the implementation
of the federation api. check [1] for more details.

[1] https://review.openstack.org/#/c/489609/

Change-Id: Ie8a68cd3198c8fc7930069fd2e55f1cad55b6c9b
Partially-Implements: blueprint federation-api
2018-01-15 14:58:04 -03:00
Ricardo Rocha 84006f63d7 Allow flavor_id on cluster create
Add flavor_id as an option during cluster create. If not given,
the default is taken from the cluster template.

Add flavor_id in the Cluster object and use that instead
of the one from ClusterTemplate.

Update both magnum and magnum cli documentation to reflect the above changes.

Partial-Bug: #1699245
Change-Id: Ib60c05cce1cf2639ca4740abdd264403033433f9
2017-12-15 16:32:40 +00:00
Ricardo Rocha 28fff8006a Make docker_storage_driver a str instead of enum
Allow any value to be passed on the docker_storage_driver field by turning it
into a StringField (was EnumField), and remove the constraints limiting the
values to 'devicemapper' and 'overlay'.

Change the docker storage setup to have a generic setup for all drivers with
the exception of 'devicemapper', which keeps its own specific storage config
function. For all others, do the same we already did for overlay (with two
cases for usage of a cinder volume or not) and simply set the storage driver
in the docker configuration to the value provided in the cluster template.

Change-Id: I9aa8f232ce64ece4d439c0a476f463820a499617
Closes-Bug: #1722522
2017-12-14 14:41:09 +00:00
Ricardo Rocha 446b159349 Allow master_flavor_id on cluster create
Add master_flavor_id as an option during cluster create. If not given,
the default is taken from the cluster template.

Add master_flavor_id in the Cluster object and use that instead
of the one from ClusterTemplate.

Update both magnum and magnum cli documentation to reflect the above changes.

Partial-Bug: #1699247
Change-Id: Id1d973167b381538121583a0a9691304b39e98de
2017-09-27 09:30:18 +00:00
Jenkins 04b4df0d74 Merge "Allow labels on cluster create" 2017-09-07 07:49:12 +00:00
Ricardo Rocha 3d04ed4cbb Allow labels on cluster create
Add labels as an option during cluster create. If not given,
the default is taken from the cluster template.

Add labels in the Cluster object and use that instead
of the one from ClusterTemplate.

Update both magnum and magnum cli documentation to reflect the above changes.

Partial-Bug: #1697651
Implements: blueprint flatten-attributes
Change-Id: I8990c78433dcbbca5bc4aa121678b02636346802
2017-08-21 12:27:52 +00:00
chestack c22f9cd882 Deal with db_exc.DBDuplicate of conductor startup
we have enable multiple workers of magnum-conductor that
result in multiple processes save same DB entry concurrently.

This patch logs warning message instead of raising exception

Change-Id: I548d50bed5d80e96042f88039e880075e1bffc53
Close-Bug: #1711324
2017-08-17 19:40:43 +08:00
Ricardo Rocha 79039bb419 Allow docker_volume_size on cluster create
Add docker_volume_size as an option during cluster create. If not given,
the default is taken from the cluster template.

Add docker_volume_size in the Cluster object and use that instead
of the one from ClusterTemplate.

Update both magnum and magnum cli documentation to reflect the above changes.

Partial-Bug: #1697648
Implements: blueprint flatten-attributes
Change-Id: Ic6d77e6fdf5b068fa5319b238f4fd98b4d499be4
2017-06-23 11:31:27 +00:00
yuanpeng 71d25456d2 Remove log translations
Log messages are no longer being translated. This removes all use of
the _LE, _LI, and _LW translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: If1f4bd2f6be967368f52fb367c5a428d3eb58a9d
Closes-Bug:#1674551
2017-03-30 17:05:10 +08:00
Johannes Grassler e93d82e8b3 Fix CVE-2016-7404
This commit addresses multiple potential vulnerabilities in
Magnum. It makes the following changes:

* Permissions for /etc/sysconfig/heat-params inside Magnum
  created instances are tightened to 0600 (used to be 0755).
* Certificate retrieval is modified to work without the need
  for a Keystone trust.
* The cluster's Keystone trust id is only passed into
  instances for clusters where that is actually needed. This
  prevents the trustee user from consuming the trust in cases
  where it is not needed.
* The configuration setting trust/cluster_user_trust (False by
  default) is introduced. It needs to be explicitely enabled
  by the cloud operator to allow clusters that need the
  trust_id to be passed into instances to work. Without this
  setting, attempts to create such clusters will fail.

Please note, that none of these changes apply to existing
clusters. They will have to be deleted and rebuilt to benefit
from these changes.

Change-Id: I643d408cde0d6e30812cf6429fb7118184793400
2017-02-09 16:44:27 +01:00
Jenkins cb7d36ea0f Merge "Resource Quota - Limit clusters per project" 2017-01-26 22:15:52 +00:00
Vijendar Komalla 206d17f8ca Resource Quota - Limit clusters per project
Currently there is no limit on the number of clusters that can
be created in a project. This change limits number of clusters
in a project by checking cluster quota on cluster-create.

Change-Id: Ifa17d12692751fc6929e62be8bb59d481a2fd205
Partially-Implements: blueprint resource-quota
2017-01-25 08:55:45 -06:00
Jenkins 4e1ada7914 Merge "Integrate OSProfiler in Magnum" 2017-01-25 06:47:12 +00:00
Tovin Seven 32d088b2c1 Integrate OSProfiler in Magnum
* Add osprofiler wsgi middleware. This middleware is used for 2 things:
  1) It checks that person who wants to trace is trusted and knows
     secret HMAC key.
  2) It starts tracing in case of proper trace headers
     and adds first wsgi trace point, with info about HTTP request

* Add initialization of osprofiler at start of service
  Currently that includes oslo.messaging notifer instance creation
  to send Ceilometer backend notifications.

* Traces HTTP/RPC/DB API calls

Demo: https://hieulq.github.io/cluster-create-false-new-html.html

Co-Authored-By: Hieu LE <hieulq@vn.fujitsu.com>
Implements: blueprint osprofiler-support-in-magnum
Change-Id: I7d68995aab81d365433950aada078ef1fcd5469b
2017-01-24 07:43:31 +07:00
Vijendar Komalla ccc04d67fc Resource Quota - DB layer changes
Change-Id: Ib1d4d8634eabdba76c5f7f858efc16702ebc0d2a
Partially-Implements: blueprint resource-quota
2017-01-23 11:00:10 -06:00
Jenkins 942fa495b6 Merge "Magnum stats API" 2017-01-19 07:24:33 +00:00
Vijendar Komalla 51e833137b Magnum stats API
This change introduces a new /stats REST endpoint that
provide the following basic information;
1) Total number of clusters and nodes for the given tenant.
2) Total number of clusters and nodes across all the tenants.
Follow-up patches include more stats.

Change-Id: Iac0bf9343549de31654545d5b1fd7601e56142a7
Partially Implements blueprint magnum-stats-api
2017-01-17 09:48:54 -06:00
Hongbin Lu 900c2af483 Remove unused context variable in db api
Change-Id: I78d7ddccddcc3630ddaf8fc6ddfc62dcff352bcd
2017-01-15 04:26:39 +00:00
yatin 5902daf8ae Remove provision_state parameters(specific to ironic)
The provision_state parameter was copied from ironic
with following patch:
https://review.openstack.org/#/c/138280

It should be removed as it's not required in magnum.

Change-Id: Id9e08ee731ae79531c8e29fd47e4fa650b1c5dcc
Partial-Bug: #1627663
2016-12-29 11:34:09 +05:30
Jaycen Grant 06f056f606 Allow keypair to be added during cluster create
Keypair can now be added during Cluster create command. This allows
Clusters to be created from the same ClusterTemplate but have
different keypair values when created. If not specified on create
then the value from the ClusterTemplate will be used. Adds keypair_id
to Cluster object and uses of keypair_id will use the value from Cluster
instead of ClusterTemplate.

Added release note for new features in magnum and magnum CLI.

Change-Id: I177a5aa06f881156944a9f74c9ccc3cd2abac492
Implements: blueprint keypair-override-on-create
2016-10-06 17:25:09 +00:00