Commit Graph

44 Commits

Author SHA1 Message Date
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
Michal Nasiadka 68c8acba39 Remove execution bit on unnecessary files
Change-Id: Ia41b843fdf20154750b129a8ab5dd42f5c3989fb
2024-02-19 00:30:21 +00:00
Jake Yip 6cdb367cfc Remove send_cluster_metrics
This period job has been deprecated since Change
I3ca0f2e96fe63870406cc5323f08fa018ac6e8be in Rocky/Stein.

As it defaults to disabled, it causes logs like the following to be sent
over and over again.

 Running periodic task MagnumPeriodicTasks._send_cluster_metrics
 Skip sending cluster metrics _send_cluster_metrics

Remove the code totally as it has basically been a noop for a few
cycles.

Change-Id: Ib9142ab17d562b1d7ccf1409a9e0d934585a094d
2023-02-27 02:39:13 +00:00
ricolin 1ed78a4438 Allow update cluster status with admin context
Trust token can be deleted outside of magnum,
But when trust token not found, the periodic update status job will
stay in inprogress unless another cluster action triggered.

Propose to use admin context when trust can not be found in periodic
update status job.

Story: 2010232
Task: 46031

Change-Id: I9cc9a0e654fb26ebec517e3413a592ac6613777c
2022-08-18 05:29:32 +08:00
Feilong Wang 78d1f79b63 Fix health status polling interval
The "spacing" parameter of peirod jobs sync_cluster_status and
sync_cluster_health_status are placed incorrectly. This patch
fixes it.

Task: 41200
Story: 2007683

Change-Id: I9a129241d5f31d84d93da047c654da21604eff66
2021-11-26 09:54:26 +00:00
Feilong Wang 8e9df14d27 [k8s] Support configurable health polling interval
The default 10 seconds health polling interval is too frequent for most of
the cases. Now it has been changed to 60s. A new config
`health_polling_interval` is added to make the interval configurable.
Cloud admin can totally disable the health polling by set a negative value
for the config.

Task: 39795
Story: 2007683

Change-Id: Iad30487b8c119e94ee21d75f53fb86eb23dff365
2020-05-16 12:15:50 +12:00
Emanuel Andrecut e5eade03dc Add information about the cluster in magnum event notifications
Magnum is sending notifications like cluster create but has no
details regarding the cluster, like cluster UUID. Notifications
from other OpenStack projects contain full detailed information
(e.g. instance UUID in Nova instance create notification).
Detailed notifications are important for other OpenStack
projects like Searchlight or third party projects that cache
information regarding OpenStack objects or have custom actions
running on notification. Caching systems can efficiently update
one single object (e.g. cluster), while without notifications
they need to periodically retrieve object list, which is
inefficient.

Change-Id: I820fbe0659222ba31baf43ca09d2bbb0030ed61f
Story: #2006297
Task: 36009
2019-07-29 11:23:42 +03:00
Theodoros Tsioutsias 18c77a288d ng-2: Adapt existing cluster APIs and conductor
This changes the existing cluster APIs and the cluster conductor to
take into consideration nodegroups:

* create: now creates the default nodegroups for the cluster
* update: updates the default nodegroups of the cluster
* delete: deletes also the nodegroups that belong to the cluster
* cluster_resize: takes into account the nodegroup provided by the API

story: 2005266

Change-Id: I5478c83ca316f8f09625607d5ae9d9f3c02eb65a
2019-03-28 10:31:01 +00:00
Feilong Wang c38edc6929 [k8s] Update cluster health status by native API
Calling Kubernetes native API to update the cluster health status
so that it can used for cluster auto healing.

Task: 24593
Story: 2002742

Change-Id: Ia76eeeb2f1734dff38d9660c804d7d2d0f65b9fb
2019-02-18 11:03:10 +13:00
Erik Olof Gunnar Andersson f2fd732ce2 Trivial code cleanups
Cleaning up comments and logging to make sure they properly adhere
to Openstack standards.

* Consistently use """ instead of ''' for comments.
* Always lazy-load logging parameters.
* Fixed bad log line in cert_manager.

Change-Id: I547f5dfa61609a899aef9b1470be8d8a6d8e4b81
2018-10-02 19:41:34 +00:00
Feilong Wang a26c2225b6 Deprecate send_cluster_metrics
Currently, Magnum is running periodic tasks to collect k8s cluster
metrics to message bus. Unfortunately, it's collecting pods info
only from "default" namespace which makes this function useless.
What's more, even Magnum can get all pods from all namespaces, it
doesn't make much sense to keep this function in Magnum. Because
operators only care about the health of cluster nodes. If they
want to know the status of pods, they can use heapster or other
tools to get that.

Task: 22619
Story: 1775116

Change-Id: I3ca0f2e96fe63870406cc5323f08fa018ac6e8be
2018-08-20 10:53:50 +12:00
Kirsten G cf84683940 Add send_cluster_metrics configuration parameter
Added configuration parameter, send_cluster_metrics, to magnum.conf
with default value of True. If set to True, periodic tasks will pull
COE data and send to ceilometer. This parameter can be set to False to
disable periodic collection of data to avoid unnecessary load from the
cluster.

Closes-Bug: #1668330
Related-Bug: #1746510

Change-Id: I9945293e7b2b52731f6e220d0925c1f6ad097caa
2018-02-01 10:34:54 -08:00
coldmoment ba8ad5e37f Add a hacking rule for string interpolation at logging
String interpolation should be delayed to be handled
by the logging code, rather than being done at the point
of the logging call.
See the oslo i18n guideline
* https://docs.openstack.org/oslo.i18n/latest/user/guidelines.html#adding-variables-to-log-messages
and
* https://github.com/openstack-dev/hacking/blob/master/hacking/checks/other.py#L39

Change-Id: I8a4f5f896865aebbff88ee894f0081e58cfce9ef
2017-07-15 14:49:45 +08: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
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
Randall Burt 84a9464957 Move cluster status notifications out of driver
Move cluster status change notifications into the
periodic task so that drivers do not have to have
any knowledge of Magnum notification strategy.

Change-Id: I5c71dd780f7bd6d4b683e491f5b4ce22cecb396c
Partial-Blueprint: bp-driver-consolodation
2016-12-07 15:27:44 +00:00
Randall Burt 759c1b3b2b Move cluster status updates into driver
This is an alternative implementation to:

https://review.openstack.org/#/c/397961

This version implements an earlier proposal from the
spec that adds a driver method for synchronizing
cluster state. This method is optional so that drivers
that do not wish to leverage the existing periodic
synchronization task can do so in whatever manner
they wish and Magnum will not force them to do anything
unnecessarily.

1. add an update_cluster_status method to the driver
   interface
2. implment update_cluster_status for Heat drivers
   using the existing tested logic
3. Remove cluster status updates from the cluster conductor
   in favor of the periodic sync_cluster_status task - this
   should avoid timeouts and race conditions possible in the
   previous implementation
4. Update the periodic sync_cluster_status method to use
   the driver to update cluster status rather than calling
   Heat directly

Change-Id: Iae0ec7af2542343cc51e85f0efd21086d693e540
Partial-Blueprint: bp-driver-consolodation
2016-12-01 19:52:06 -06:00
Hieu LE 1a97476593 Centralize config option: rpc periodic section
Centralize config option of rpc periodic section.
Replace oslo_conf cfg to magnum.conf.

Change-Id: Ic499369d16e7be79449a0e8ed5416b0ab92abc07
Implements: blueprint centralize-config-magnum
2016-09-22 05:57:17 +00:00
Jaycen Grant 729c2d0ab4 Rename Bay DB, Object, and internal usage to Cluster
This is patch 3 of 3 to change the internal usage of the terms
Bay and BayModel.  This patch updates Bay to Cluster in DB and
Object as well as all the usages.  No functionality should be
changed by this patch, just naming and db updates.

Change-Id: Ife04b0f944ded03ca932d70e09e6766d09cf5d9f
Implements: blueprint rename-bay-to-cluster
2016-09-08 13:01:12 -07:00
Cao Xuan Hoang 33bd24252f Clean imports in code
This patch set modifies lines which are importing objects
instead of modules. As per openstack import guide lines, user should
import modules in a file not objects.

http://docs.openstack.org/developer/hacking/#imports

Closes-Bug: #1620161

Change-Id: I7ec9022a6b1cec36c678a2cec2a1856e70a51c68
2016-09-05 09:51:38 +07:00
Jaycen Grant eaddb942fd Rename Bay to Cluster in api
This is the first of several patches to add new Cluster commands
that will replace the Bay terminalogy in Magnum. This patch adds
the new Cluster and ClusterTemplate commands in addition to the
Bay and Baymodel commands.  Additional patches will be created
for client, docs, and additional functional tests.

Change-Id: Ie686281a6f98a1a9931158d2a79eee6ac21ed9a1
Implements: blueprint rename-bay-to-cluster
2016-08-17 22:24:45 +00:00
Jenkins 5372cd92b4 Merge "Rollback bay on update failure" 2016-08-16 04:59:35 +00:00
Wenzhi Yu 63b5c21c8d Rollback bay on update failure
There is a rollback mechanism in heat after the stack
update failed. There should be a rollback mechanism in
magnum after bay update failed.

This patch add new microversion 1.3 to add rollback
support for Magnum bay, user can enable rollback on bay
update failure by specifying microversion 1.3 in header(
{'OpenStack-API-Version': 'container-infra 1.3'}) and
passing 'rollback=True'(http://XXX/v1/bays/XXX/?rollback=True)
when issuing bay update reqeust.

Change-Id: Idd02769f98078702404a11dc9f7a3339ce4e22eb
Partially-Implements: blueprint bay-rollback-on-update-failure
2016-08-15 17:09:23 +08:00
yatin karel fb0057c105 Add i18n translation for Log messages
Added i18n translation to all log messages. Also added
hacking check for this to ensure in future all log
messages are translated.

Change-Id: I77fbb18ffe47b12232125cc1fa7aae97ea9b1214
Closes-Bug: #1603759
2016-08-15 11:44:08 +05:30
Johannes Grassler f895b2bd09 Fix global stack list in periodic task
The periodic task unneccessarily lists Heat stacks in the
global tenant (across all tenants) which the Magnum service
user may lack permission for. Also, the most restrictive way
to let it use global stack-list is chose a Keystone role and
open that operation to any user in any project holding that
role.

This commit substitutes a direct lookup of all bays' stack_id
attributes for this global stack list. This direct lookup will
yield the same net result. In order to get the neccessary
permissions it will use each bay's stored Keystone trust to
act on behalf of the bay's creating user.

Co-Authored-By: Jiri Suchomel <jiri.suchomel@suse.com>
Closes-Bug: #1589955
Change-Id: I67b176c137c463e37e037970cc4e468d51db30c9
2016-07-27 10:11:51 +02:00
PanFengyun f9c662e709 Fix string declaration in periodic.py
The "%(reason)" of periodic.py has losed 's'.
"%(reason)"  -->  "%(reason)s"

Change-Id: I5bd1b723e5bf8615e11b1d182cc8a978c6b01b8b
2016-07-07 21:49:49 +08:00
ting.wang b9aa042293 Replace string format arguments with function parameters
There are files containing string format arguments inside logging
messages. Using logging function parameters should be preferred.

Change-Id: Id558f66de13146f6ae76a7a69f49721b6c3d6257
Closes-Bug: #1321274
2016-02-20 23:39:33 +08:00
Dinesh Bhor e7be462a24 Fix invalid import order
Updated import order as per the OpenStack import standards [1].
Modules under magnum/common/pythonk8sclient are not covered in
this patch because this code is generated via a third party
tool "swagger-codegen" which does not follows openstack
standards yet.

[1] http://docs.openstack.org/developer/hacking/#import-order-template

Change-Id: Ia87f3e797ee627bf3c04d2bae9639fd305b41b0d
2016-02-07 22:54:41 -08:00
Wanlong Gao 6ac4ce2eb1 Python 3 deprecated the logger.warn method in favor of warning
Python 3 deprecated the logger.warn method, see:
https://docs.python.org/3/library/logging.html#logging.warning, so we
prefer to use warning to avoid DeprecationWarning.

Closes-Bug: 1508442
Change-Id: I245d24b30e783f1c6dcec1b425d78d271edff49b
2015-12-29 13:09:04 +08:00
Surojit Pathak d024bc60c4 Decoupling magnum service from periodic task
Liberty tech-debt-bug

Magnum service was initially utilizing periodic task within magnum
conductor. This commit lays out independent periodic framework for
magnum service, by decoupling from periodic task.

Change-Id: Ie0e725b75069309a9fa783f77c1a454f9dae549e
Partial-Bug: 1500998
2015-11-30 18:52:48 +00:00
Surojit Pathak ab5a173e6d Adding dev-notes for try-catch block in periodic task
Not removing existing try-catch block for sync_bay_status and other
periodic tasks. Rather leaving a note with the pointers and explanation
for developers to add new periodic task.

Change-Id: I2560d3961c19d73ab78a8e9812d69742c6bd2117
Closes-Bug:1496094
2015-11-20 01:41:55 +00:00
Tom Cammann d2e05d4e9b Refactor periodic task sync_bay_status
The cyclomatic complexity of sync_bay_status was greater than 10 and
very hard to comprehend. This patch reduces the complexity and makes the
task more open to refactoring and maintence.

Partial-Bug: #1501331
Change-Id: If415aa7710b586b0429ed1bc5077976791b424d1
2015-10-22 09:52:18 +01:00
Hongbin Lu b88085c93c Implement bay monitoring and notifications
* Implement a bay monitoring framework that provides APIs to pull data from
  bay, and compute metrics based on the data.
* Add support for computing memory utilization of a swarm bay.
* Add a periodic task that sends metrics to ceilometer.

Change-Id: I32730e116c59a4e5f9d1ccb466d464c2fc1f6193
Partially-Implements: blueprint autoscale-bay
Partially-Implements: blueprint magnum-notifications
2015-09-29 14:38:03 -04:00
Surojit Pathak 3674ce278d Backend support for magnum service
To support 'magnum service-list' after 'nova service-list', we need to
introduce periodic status update functionality for internal services.

Change-Id: Ia0c09222405c87cb61e5de4a43ba345ae3405b50
Partially-Implements: blueprint magnum-service-list
Closes-bug: #1492501
2015-09-28 17:06:10 +00:00
Jenkins 6c43071d3f Merge "Move 'all_tenants' options to context" 2015-08-31 15:49:04 +00:00
Jenkins b10538847a Merge "Sync bay status reason in periodic task" 2015-08-28 20:29:06 +00:00
mathspanda 235877bebc Sync bay status reason in periodic task
In periodic task, when bay status is found to be different with
corresponding stack, or the corresponding stack cannot be found in
heat, status reason should be synced as well as status. Otherwise,
status reason will be meaningless in some situation.

Change-Id: I27d6a7ecb0c74bd4d4a2bb2bfcd81d7632cd2147
Closes-Bug: #1488709
2015-08-28 08:20:56 +08:00
Hongbin Lu fa5bcee4ab Move 'all_tenants' options to context
In before, bay and x509keypair supported list resources from all
tenants. It is desirable to generalize this capability while reducing
duplicated codes. Therefore, moving 'all_tenants' options to context.

Change-Id: Icfe31a6f2ac2e21fa7f377e244764f10892d25c7
Partially-Implements: blueprint autoscale-bay
2015-08-27 18:22:35 -04:00
Cale Rath e4add16a69 Use oslo.versionedobjects enums instead of status strings
Statuses are currently defined as a StringField when they should
be defined as an Enum object.  This fix changes these objects from
using StringField by extending the Enum object in
oslo.versionedobjects

Change-Id: I12760e1d72f4af9931ee97bbad298f92f785118f
Partial-Bug: #1489136
2015-08-27 15:55:02 +00:00
mathspanda a1ffe63454 Fix wrong usage of filters in periodic task
The filters in method 'sync_bay_status' in periodic.py should be a dict,
instead of a list.

Change-Id: Id12e8768abb17b70bbc92d951b0d95e765d94e38
Closes-Bug: #1487812
2015-08-23 20:22:33 +08:00
Hua Wang e495f81b39 Fix race condition when syncing bay status across conductors
In order to run several magnum-conductor, we should make periodic
tasks can run simultaneously. We should not destroy a bay twice.

Change-Id: Ie3c66442839197196f532734e67d810749ec5052
Partial-Implements: blueprint horizontal-scale
2015-08-11 01:22:57 +00:00
Joe Cropper 16688d42a7 Clean up miscellaneous help strings
This patch makes some general cleanup changes to help strings to tidy
up various areas of the code. No functional impacts result from the
changes within this patch.

Closes-Bug: #1477837
Change-Id: I25a81059e974ac0083bb439f1cd37fb82157b3bb
2015-07-24 00:46:34 -05:00
Eli Qiao fd57cb4372 Add periodic task to sync up bay status
This patch adds periodic task `sync_bay_status` which will be used for syncing
bay's status from heat stack, we will pull bays which status in
[bay_status.CREATE_IN_PROGRESS,
 bay_status.UPDATE_IN_PROGRESS,
 bay_status.DELETE_IN_PROGRESS]
which are all in a temporary status, and try to sync up the status with heat's
stack.

status changes will be like this:

bay_status              stack_status           sync up bay_status to
----------              ------------           ---------------------
CREATE_IN_PROGRESS      CREATE_COMPLETE        CREATE_COMPLETE
UPDATE_IN_PROGRESS      UPDATE_COMPLETE        UPDATE_COMPLETE
DELETE_IN_PROGRESS      DELETE_COMPLETE        DELETE_COMPLETE

CREATE_IN_PROGRESS      CREATE_FAILED          CREATE_FAILED
UPDATE_IN_PROGRESS      UPDATE_FAILED          UPDATE_FAILED
DELETE_IN_PROGRESS      DELETE_FAILED          DELETE_FAILED

CREATE_IN_PROGRESS      Not Found              CREATE_FAILED
UPDATE_IN_PROGRESS      Not Found              UPDATE_FAILED
DELETE_IN_PROGRESS      Not Found              destroy

Partial-Implements: blueprint add-periodic-task
Co-Authored-By: ShaoHe Feng <shaohe.feng@intel.com>
Change-Id: Ie9cc4d3f03c7938a8d988010604da79c9b8a22fd
2015-07-16 08:35:16 +08:00
Eli Qiao fbe5b8065f Add periodic task framework
This patch adds periodic timer to conductor service.
Any new periodic tasks need to be added to magnum/service/periodic.py
We add 2 default configure options to support periodic task:
    'periodic_enable', default=True
    'periodic_interval_max', default=60
These 2 options are for rpc_service.
PS:
We don't need to supervisor timers because timer itself won't have any
exception, and it is not a thread, which means can not be killed.

Partial-Implements: blueprint add-periodic-task
Co-Authored-By: ShaoHe Feng <shaohe.feng@intel.com>
Change-Id: I132d9cc89b26baf249b62b713ccd3776f0078d7d
2015-07-02 17:01:21 +08:00