Commit Graph

487 Commits

Author SHA1 Message Date
Zuul 05c2b170c0 Merge "Bugfix: Clean up trusts for all deleted clusters" 2024-02-27 15:03:36 +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
Dale Smith 1b00074c6a Bugfix: Clean up trusts for all deleted clusters
Cluster conductor creates trusts for all drivers, but does not clean
them up. The Heat driver has previously performed this action.

This change moves the lifecycle of trust and certificate creation
to the Conductor, so drivers do not need to clean up resources they
didn't create.

Change-Id: I2b3e99589d2d3069191d0727406601f0647a9722
2024-02-22 15:38:48 +13:00
Takashi Kajinami 627b9a8260 Remove six from common 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: I14ebd809b39079d06a8ecc8f747b6bb80d550acb
2024-02-19 10:43:31 +00:00
Michal Nasiadka 68c8acba39 Remove execution bit on unnecessary files
Change-Id: Ia41b843fdf20154750b129a8ab5dd42f5c3989fb
2024-02-19 00:30:21 +00:00
Michal Nasiadka bc79012f46 Drop Swarm support
Label validator function has been left behind, although it's not
checking for anything right now - might be useful in future.

Change-Id: I74c744dc957d73aef7556aff00837611dadbada7
2024-01-24 13:20:21 +13:00
ricolin a48df816cb Enable secure rbac
This setting policies (RBAC) new defaults and scope to ``True`` by default.
Note: This should only merged, after at least a cycle gap to allow
operators to adopt new changes.

Depends-On: https://review.opendev.org/c/openstack/magnum-tempest-plugin/+/877086

Change-Id: I6db4eaa64e2efd455dc3d37ccc74ebd8e7a5dbb2
2023-10-26 13:20:40 +08:00
ricolin 0ff50c542e Remove unused policy rule for Certificate APIs
Cluster user is no longer used for drivers in Magnum since [1].
Remove unused policy rule to reflect that fix.

[1] https://review.opendev.org/c/openstack/magnum/+/889144

Change-Id: Ic7ef89a61835a7045d81dbf5af77714a3270cd7c
2023-08-30 00:38:27 +08:00
ricolin 74897768e3 Allow Admin to perform all API requests
This propose changes is base on same concerns as this bug in neutron
https://bugs.launchpad.net/neutron/+bug/1997089

This propose to keep and make sure ADMIN can perform all API requests.

Change-Id: I9a3003963bf13a591cc363fa04ec8e5719ae9114
2023-08-30 00:35:35 +08:00
ricolin 5971243169 Support enables rbac policies new defaults
The Magnum service allow enables policies (RBAC) new defaults and scope by
default. The Default value of config options ``[oslo_policy] enforce_scope``
and ``[oslo_policy] oslo_policy.enforce_new_defaults`` are both to
``False``, but will change to ``True`` in following cycles.

To enable them then modify the below config options value in
``magnum.conf`` file::

  [oslo_policy]
  enforce_new_defaults=True
  enforce_scope=True

reference tc goal for more detail:
https://governance.openstack.org/tc/goals/selected/consistent-and-secure-rbac.html

Related blueprint secure-rbac

Change-Id: I249942a355577c4f1ef51b3988f0cc4979959d0b
2023-08-30 00:35:24 +08:00
Zuul 209f07f1e5 Merge "Use new get_rpc_client API from oslo.messaging" 2023-07-24 09:23:41 +00: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
scrungus 33ab4e9cb4 Update barbicanclient
The changes in version 5.5 barbicanclient cause breaking changes.
Changing which barbicanclient is used fixes this issue.

Story: 2010629
Task: 47581
Change-Id: I1b6b0a4c1960fb5cb6ce04ea755074944fe4bb6f
2023-03-14 02:09:51 +00:00
ricolin 6169eb26ed Fix pep8 gate
This fix propose two parts:
* introduce timeout (60s) to requests calls
* remove `file` scheme support for requests calls.

Change-Id: Ide2c2915ba5d6ff03933160b74f7206492276968
2023-03-14 09:17:54 +08:00
Tobias Urdin c28760c8ac Use new get_rpc_client API from oslo.messaging
Use the new API that is consistent with
the existing API instead of instantiating the client
class directly.

This was introduced in release 14.1.0 here [1] and
added into oslo.messaging here [2]

[1] https://review.opendev.org/c/openstack/requirements/+/869340
[2] https://review.opendev.org/c/openstack/oslo.messaging/+/862419

Change-Id: I4db6bbbbdc2f311f4c159b2d4f9992cfdbdafac4
2023-01-23 19:17:21 +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
Spyros Trigazis cd113dfc0c Remove use of tenant in common/context.py
Tenant has been removed from context.
Fixes UTs and pep8.

Signed-off-by: Spyros Trigazis <spyridon.trigazis@cern.ch>
Change-Id: I10daa22b614aab456b837c03278eb04da0355ff7
2022-03-18 13:20:46 +00:00
Zuul 285f91bd18 Merge "Optimize cluster list api" 2021-11-26 10:58:13 +00:00
Zuul 784351af4e Merge "Fix cluster template default policy" 2021-11-26 10:39:22 +00:00
Mohammed Naser 4888f706c8 Fix deleting clusters if stack is deleted
If a stack has been deleted (either by Magnum or the user) but
Magnum did not update and set `stack_id` to empty, the cluster
will fail to delete inside pre-deletion.

This will have a safe failover to skip if it can't find the
Heat stack, it assumes things are gone.

Change-Id: I6ebe188895e51ed83ad1514a380e4772fed5eb42
2021-11-25 12:41:31 +00:00
Takashi Kajinami 0bf324278a Fix errors caused by cryptography>=35.0.0
- _OID_NAMES was moved to a different module by [1].
- default_backend() is silently ignored, so should be dropped[2].
- The new Rust backend does not accept mocked private keys
  which caused failures with invalid private keys for tests.

[1]: 7b5634911c
[2]: https://cryptography.io/en/latest/faq/#faq-missing-backend

Change-Id: I44407703fbcf2da97c29a28043520c781ef4c3b2
2021-11-25 07:35:27 -05:00
vagrant 8ca92e6d70 Fix cluster template default policy
In Change I643d408cde0d6e30812cf6429fb7118184793400 a bunch of actions
were changed from

 is_admin:True or project_id:%(project_id)s

to

 rule:deny_cluster_user

Which means that those actions are not verifying that the project ID of
a token matches the project ID of the resource. This only seems to work
for resources that a user can otherwise see.

As public cluster templates can be seen by a user, a user is hence able
to delete a CT.

Fix it so that CT can only be modifiable or deletable by admin or
owner.

Story: 2008824
Task: 42289
Change-Id: I6dec817725338387a614f83e85a5f1f2814b020e
2021-09-20 09:37:14 +10:00
Takashi Kajinami 67acf2c5e9 Use Block Storage API v3 instead of API v2
Block Storage API v2 was deprecated during Pike cycle and is being
removed during Xena cycle, and current v3 API should be used instead.

Additional Zuul config for Devstack allows CI to pass which can be
reverted later [1].

[1] https://bugs.launchpad.net/glance/+bug/1938151

Change-Id: Ib66b754f4a0854a0d62d62047a69b04a24434634
2021-07-27 20:41:52 +00:00
Stavros Moiras 0792885a1b Optimize cluster list api
Up till now, cluster api controller cluster_template_id was a
property field loading the id from the DB every time. With this
change the field becomes of text type and mandatory, so wsme fwk
guarantees that the field is provided when needed.

Cluster objects will not load the cluster template on creation.
Instead cluster templates will be loaded when they are actually
needed.

story: 2006693
task: 36989

Co-Authored-By: Stavros Moiras <stavros.moiras@cern.ch>

Change-Id: I2313c6a8b647e521cfa476f9cec65ab286fa5a23
2021-07-01 07:42:08 +00:00
Erik Olof Gunnar Andersson b336bb34dc Re-factored rpc serializer
This patch cleans up the current rpc
implementation by moving the seralizer
back to the rpc module, this is more in
line with other projects; such as Nova.

- Moved _init_serializer back into rpc.
- Added back unit-tests for profiler.

Change-Id: Ia148b2d3bc352e96e7633f7af82ecd26b5f35e35
2021-03-09 00:13:45 +00:00
Ghanshyam Mann 3b7a33eb64 [goal] Deprecate the JSON formatted policy file
As per the community goal of migrating the policy file
the format from JSON to YAML[1], we need to do two things:

1. Change the default value of '[oslo_policy] policy_file''
config option from 'policy.json' to 'policy.yaml' with
upgrade checks.

2. Deprecate the JSON formatted policy file on the project side
via warning in doc and releasenotes.

Also replace policy.json to policy.yaml ref from doc.

[1]https://governance.openstack.org/tc/goals/selected/wallaby/migrate-policy-format-from-json-to-yaml.html

Change-Id: Icfd9e2a75d8fdfb24cbd1c850f498aadee91f543
2021-03-08 15:11:01 +00:00
Bharat Kunwar 0e6d178939 Only allow zero node count from microversion 1.10
At present, all clients can request resize of cluster nodes to zero.
This PS ensures that only requests with 1.10 microversion header or more
are fulfilled.

Story: 2007851
Task: 41841

Additionally, unit tests are also included to ensure that the
microversions are respected for create, update and resizing clusters
with zero node count.

Additionally, unit tests for the following APIs are tested explictly:
- resize API with microversion 1.7
- upgrade API with microversion 1.8
- nodegroup API with microversion 1.9

Story: 2005054
Task: 41840

Change-Id: Iba9d619d2e92abcbaa3eca5da68f5e0f203dea8d
2021-02-16 14:04:36 +00:00
Erik Olof Gunnar Andersson 672b119507 Re-use transport for rpc server
This patch changes the rpc server to re-use
the transport in the same manner as the rpc client.

Story: 2008494
Task: 41752

Change-Id: I93eecacbe45d19c4f73e9a974d60e642e87bbdf0
2021-02-03 19:38:42 +00:00
Zuul d614499825 Merge "Re-use transport for rpc calls" 2021-02-03 10:38:19 +00:00
Erik Olof Gunnar Andersson 987c9d809e Re-use transport for rpc calls
We are currently creating a new transport for each api
call. This patch changes that so that each worker
can re-use the same transport for multiple requests.

Story: 2008494
Task: 41544
Change-Id: I11a24f035a9d66a536e5e58328084ee08f0c6285
2021-01-29 21:21:24 +00:00
Mark Goddard 8018bf9124 Fix cluster deletion when load balancers don't exist
During cluster deletion, magnum tries to delete the cluster's load
balancers in advance of deleting the heat stack. If these load balancers
do not exist for some reason, the cluster deletion will fail with an
error such as the following:

    Failed to pre-delete resources for cluster
    748b628a-2cd8-456f-8aee-c93804b2099b, error: list indices must be
    integers or slices, not str.

This happens because the heat stack has the physical_resource_id set to
None for the load balancer, which causes the load_balancer_show method
of octavia client to GET all load balancers, rather than just one. The
returned data is a list, rather than a dict, leading to the error above.

This change fixes the issue by checking if physical_resource_id is set
to None, and skipping the load balancer deletion if so.

Change-Id: I8f4ca497a01ad04db6cb6c4bc81caed0d714b5a6
Story: 2008548
Task: 41669
2021-01-22 15:22:45 +00:00
Sharma-Ritika 2a61e7dc1f [goal] Prepare pep8 testing for Ubuntu Focal
As per victoria cycle testing runtime and community goal,
we need to migrate upstream CI/CD to Ubuntu Focal(20.04).

Add noqa doe C901 and F811 pep8 for Focal, failure can be
seen in - https://review.opendev.org/#/c/743130

Depends-On: https://review.opendev.org/#/c/738328/

Change-Id: I95fa40551d842ce652ab937b8848c64f09a3e131
Story: #2007865
Task: #40190
2020-09-09 13:31:45 +05:30
Zuul e8467e94d8 Merge "Support upgrade on behalf of user by admin" 2020-05-26 11:19:19 +00:00
Feilong Wang 2cb23153bd Support upgrade on behalf of user by admin
Unleash the capability that admin user can do rolling upgrade on
behalf of the end user so that cloud admin can do urgent security
patching when it's really necessary.

Task: 39784
Story: 2007675

Change-Id: I8fa9a30ee8252b94baa80e4bbca197b285fb7f71
2020-05-19 08:49:49 +00:00
Bharat Kunwar f5d32eb51c [k8s] Fix PreDeletionFailed if Heat stack is missing
When a stack has already been deleted, the pre-deletion tries to check
for loadbalancer for stack_id=None which returns PreDeletionFailed
exception. This patch addresses this issue.

Change-Id: Id7a9c5080633bca411398b7989026004e74ccb65
Story: 2007657
Task: 39783
2020-05-19 08:47:17 +00:00
Lingxian Kong 33cc92efe2 [K8S] Delete all related load balancers before deleting cluster
When deleting cluster, Magnum only deletes the load balancers for
Kubernetes services/ingresses before deleting Heat stack. The process of
stack deletion is to delete resources in dependencies, which means, for
Octavia resources, member is deleted first, then pool, listener, and
finally load balancer. The whole process is error-prone, especially
Octavia controller needs to talk to amphora for each API call before
deleting load balancer, if any step fails, the deletion operation will
fail.

Octavia provides cascade deletion API[1] for the load balancer, which
could delete all the related resources in one API call and doesn't
involve communication between Octavia controller and amphora instance.

This patch deletes the api/etcd load balancers (if applicable) before
deleting Heat stack, making the cluster deletion process more robust.

[1]: https://docs.openstack.org/api-ref/load-balancer/v2/index.html?expanded=remove-a-load-balancer-detail#remove-a-load-balancer

story: 2007657
task: 39743
Change-Id: Ibe8f788559d0977475d0991fc99ad91ccfd7dca7
2020-05-12 09:48:11 +00:00
Feilong Wang 63e80c3108 [k8s] Support updating k8s cluster health status
The original design of k8s cluster health status is allowing
the health status being updated by Magnum control plane. However,
it doesn't work when the cluster is private. This patch supports
updating the k8s cluster health status via the Magnum cluster
update API by a 3rd party service so that a controller (e.g.
magnum-auto-healer) running inside the k8s cluster can call
the Magnum update API to update the cluster health status.

Task: 38583
Story: 2007242

Change-Id: Ie7189d328c4038403576b0324e7b0e8a9b305a5e
2020-04-09 16:59:26 +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
Lingxian Kong 84803e3f03 Fix the load balancer description regex pattern for deleting cluster
Change-Id: I3339a66ceedb3e02c478f3842422e01f1da4a2b5
Story: #2007254
Task: #38613
2020-02-04 09:45:23 +13:00
Theodoros Tsioutsias 23ca0d3c66 No new NGs for clusters without an api_address
With this change, the nodegroup api controller raises an exception
if the user tries to create a nodegroup in a cluster that does not
have an api_address yet. If the nodegroup is created without the
cluster's API address as an input then the new nodes will not be
able to join the cluster.

Change-Id: If3b168d7f756a055b80d38a4f80cedc97f1b47e8
story: 2006716
task: 37087
2019-10-23 10:04:57 +00:00
Zuul 669a4e523c Merge "bug: Cluster should be creatable w/o fixed subnet" 2019-10-19 08:25:20 +00:00
Bharat Kunwar 756a85b70c bug: Cluster should be creatable w/o fixed subnet
Without this patch, it is impossible to create a cluster without
defining a fixed_network or a fixed_subnet that already exists since we
get a Fixed{Network,Subnet}NotFound error, and Heat is unable to create
these for us.

Story: 2002652
Task: 37201

Change-Id: I0e26682b0b6093b215393eb4ce8e94eae8e5e8f7
Signed-off-by: Bharat Kunwar <brtknr@bath.edu>
2019-10-17 22:33:27 +00:00
Theodoros Tsioutsias 0ac4db955f ng-13: Support nodegroup upgrade
Adds support for upgrading nodegroups. All non-default nodegroups,
are allowed to be upgraded using the CT set in the cluster. The
only label that gets upgraded for now is kube_tag. All other labels
in the new cluster_template are ignored.

Change-Id: Icade1a70f160d5ec1c0e6f06ee642e29fe9b02ff
2019-10-16 11:53:44 +00:00
Bharat Kunwar 97dbd49d82 Convert fixed_subnet name to uuid for OCCM
Since OpenStack Cloud Controller Manager only accepts fixed_subnet uuid,
convert fixed_subnet name to uuid when a cluster is created.

Without this patch, there is a chance OCCM fails to start in come cases
when fixed_subnet is rendered as name.

Story: 2002652
Task: 28816

Change-Id: Ie70bc00f5617ef94c39c9faea7d39617ee01b07b
2019-10-11 12:49:33 +00:00
Spyros Trigazis 2f72fdfbf6 Pass ssh public key as string
* Fedora CoreOS need the key to be passed as
  a string.
* We can adopt in all drivers so that users in
  the same project can do cluster resize.

story: 2005201
task: 36934

Change-Id: I9a18ce4dcbd74f0dcd23274baed7c8c3d2029d50
Signed-off-by: Spyros Trigazis <spyridon.trigazis@cern.ch>
2019-10-08 07:56:52 +00:00
Theodoros Tsioutsias 5027e0daf8 ng-8: APIs for nodegroup CRUD operations
This adds the changes needed in the API and conductor level to support
creating updating and deleting nodegroups.

Change-Id: I4ad60994ad6b4cb9cac18129557e1e87e61ae98c
2019-09-26 08:45:57 +00:00
Zuul b546f547a7 Merge "Improve dns format validation" 2019-09-20 11:43:26 +00:00
Mohammed Naser cfe2753fd3 [fedora atomic k8s] Add boot from volume support
Support boot from volume for Kubernetes all nodes (master and worker)
so that user can create a big size root volume, which could be more
flexible than using docker_volume_size. And user can specify the
volume type so that user can leverage high performance storage, e.g.
NVMe etc.

And a new label etcd_volme_type is added as well so that user can
set volume type for etcd volume.

If the boot_volume_type or etcd_volume_type are not passed by labels,
Magnum will try to read them from config option
default_boot_volume_type and default_etcd_volume_type. A random
volume type from Cinder will be used if those options are not set.

Task: 30374
Story: 2005386

Co-Authorized-By: Feilong Wang<flwang@catalyst.net.nz>

Change-Id: I39dd456bfa285bf06dd948d11c86867fc03d5afb
2019-09-20 05:00:29 +00:00
Bharat Kunwar e84cc4c975 Convert network UUID to name required for OCCM
Sometimes, the fixed_network value gets rendered as UUID. However OCCM's
internal-network-name requires the network name, it does not support
UUID. This patch introduces a new parameter called fixed_network_name
which converts fixed_network UUID to name if it is UUID-like.

Story: 2005333
Task: 36313

Change-Id: I3453bc0dbea285687d39c9782685cb1f2a3ecd39
2019-08-25 22:16:42 +00:00
Xingchao Yu 893e2cdf60 Improve dns format validation
Currently, if variable dns-nameserver is a list which
contains extra spaces, e.g., '8.8.8.8, 8.8.4.4', then
validate_dns will fail and API will throw 400 Bad request.

This patch strips extra spaces before the dns format validation.

Change-Id: I8d7c94f42e9ea70009157c5de3dce75620ff5fe8
Story: 2006407
Task: 36291
2019-08-15 23:25:06 +00:00