Commit Graph

33 Commits

Author SHA1 Message Date
Michal Nasiadka 68c8acba39 Remove execution bit on unnecessary files
Change-Id: Ia41b843fdf20154750b129a8ab5dd42f5c3989fb
2024-02-19 00:30: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
Mohammed Naser 6eb907cc89 Drop Kubernetes Python client dependency
We depend on the Kubernetes Python client for several things such as
health checks & metrics polling.  Those are both run inside periodic
jobs which spawn in greenthreads.

The Kubernetes API uses it's own thread pools which seem to use
native pools and cause several different deadlocks when it comes to
logging.  Since we don't make extensive use of the Kubernetes API
and we want something that doesn't use any threadpools, we can
simply use a simple wrapper using Requests.

This patch takes care of dropping the dependency and refactoring
all the code to use this simple mechansim instead, which should
reduce the overall dependency list as well as avoid any deadlock
issues which are present in the upstream client.

Change-Id: If0b7c96cb77bba0c79a678c9885622f1fe0f7ebc
2022-01-20 16:02:21 +00:00
Jake Yip d866fb6184 Fix async reserved word in python3.7
kubernetes-client has patched this [1]. To retain backwards
compatibility, we can use **kwargs to handle async/async_req arguments

[1]: b10c7b6a17

Change-Id: I8e738b4f99091786dd76e081bffa36ef5ab70085
2019-02-22 16:33:21 +11: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
yatin 553316e40f Fix: functional CI Jobs
After [1] jobs are return false(SUCCESS) status due
to wrong EXIT_CODE.
After [2] kubernetes client is updated to v4.0.0 and
no longer contains ConfiugrationObject so we need create
instance of Configuration class.

Also don't use local to create variable as local
 can only be used in a function.

[1] https://review.openstack.org/#/c/526618/
[2] https://review.openstack.org/#/c/528406

Change-Id: Ida5aac40b234a358b2a13b2e51a41d0242031ebb
2018-01-11 12:50:25 +00: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
Davanum Srinivas e634b55637 Switch to kubernetes upstream python client
For a really long time, we generated and maintained our very own python
client generated from kubernetes swagger json files. Now in Kubernetes
Community there is a concerted effort to organize an official python
client (also generated from swagger) for everyone to use. So let us
please switch over from our python-k8sclient and use the community
driven python client. I have ported all of our end-to-end tests and got
them working in kubernetes client-python project upstream so we should
be protected from regressions.

Implements: blueprint replace-k8sclient-with-upstream-kubernetes-client

Depends-On: I72359f2b811392008eb5267812bf343797b1553a
Change-Id: Ib81a69cfdc25198e259e3b3d4081c92c01fd1bc5
2017-02-13 14:48:08 -05: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
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
yuyafei 85a2fdd70b Correct reraising of exception
When an exception was caught and rethrown, it should call 'raise'
without any arguments because it shows the place where an exception
occured initially instead of place where the exception re-raised.

Change-Id: If180215bda5592c0cba92cb2c9b3a61c13d62ccf
2016-07-08 12:25:23 +08:00
Madhuri Kumari 5f193f2e0e Add x509keypair_cert_manager to store certs in DB
x509keypair_cert_manager stores certs in Magnum DB.

Change-Id: Id8106d7bd5c270679bc189fc0dc17bcbde367d73
Implements: blueprint  blueprint barbican-alternative-store
2016-06-23 09:08:52 +05:30
Madhuri Kumari e280b0339a Code refactoring in conductor/k8s_api.py
This patch removes redundant method create_certificate_files defined in
magnum/conductor/k8s_api.py and uses the one defined in
magnum/conductor/handlers/common/cert_manager.py

Change-Id: I509fd24b3a6febd1b621321c380f38afdfaccec2
Closes-bug: #1505085
2016-05-18 01:55:20 +05:30
Davanum Srinivas a6650650f0 Use k8sclient library
In Ia400b5b6919753d6241233a6666a2c30c7618bc9, we are
adding a new library to global requirements. This
python-k8sclient library essentially has the same
code that was in Magnum so it's a straight replace.

Change-Id: Ib85bcf532e4163d5c1ac95ef701a1ec3133b69eb
2016-04-17 03:35:39 +00:00
Eli Qiao b0ce382cf1 Use bay to init K8sAPI instead of bay_uuid
This patch aimed to reduce db call count when we invode k8sAPI.

For those user using bay name to do pod/rc/service operations, we
can saving a db call.

Change-Id: I1488d0526e1d444cb681b408f8a13ce25b4aee6f
2016-03-22 06:30:08 +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
Vilobh Meshram fee4b609c0 Make kubernetes API client generic
Make kubernetes API client generic. Right now each k8s object has
a way to create k8s API client. This was needed to make sure the
tests passed. Now since all the objects-from-bay patches are merged
in its better to make the client creation logic generic.

Change-Id: Ic2a9b16bbd4c13794c7ef95309bd260366ec872e
Closes-Bug: #1502367
2015-12-21 15:25:21 -08:00
OTSUKA, Yuanying d92812bdc0 Avoid to use common.cert_manager directly
Conductor has a utility to manage bay specific certificates.
This patch changes to use it.
And also this patch fixes temporary place holder classes related
to bp:objects-from-bay.

Change-Id: I55d7fe33d7a910b9ba76bcbb4c39353fe7fac2f4
Closes-Bug: #1523843
2015-12-09 14:54:32 +09:00
Vilobh Meshram 44122d08f8 Objects from Bay - Pods
Currently k8s objects (pod/rc/service) are read from the
database. In order for native clients to work, they must
be read from the ReST bay endpoint. To execute native
clients, we must have one truth of the state of the
system, not two as we do now. This patch proposes the
change to the Pod object.

Also, please refer to the related-bug as to the temporary changes
done to make the test work for other objects namely rc,
service. These changes will be removed when the object from bay
patches for all the k8s objects are merged as part of a seperate
patch.

Partially-Implements: bp objects-from-bay
Related-Bug: #1502367
Related-Bug: #1504379

Change-Id: Id5be7fba2eb8622fcfeb48068728e440a0af3f5e
2015-12-02 12:13:57 -08:00
Vilobh Meshram 067b38391c Objects from Bay - Services
Currently k8s objects (pod/rc/service) are read from the
database. In order for native clients to work, they must
be read from the ReST bay endpoint. To execute native
clients, we must have one truth of the state of the
system, not two as we do now. This patch proposes the
change to the Service object.

Also, please refer to the related-bug as to the temporary changes
done to make the test work for other objects namely pod, rc. These
changes will be removed when the object from bay patches for
all the k8s objects are merged as part of a seperate patch.

Partially-Implements: bp objects-from-bay
Related-Bug: #1502367
Related-Bug: #1504379

Change-Id: I05177944a693710c70a22cae57f521b0fe738e9e
2015-11-30 11:20:39 -08:00
Vilobh Meshram 3b1c0b28cb Objects from Bay - Replication Controller
Currently objects (pod/rc/service) are read from the
database. In order for native clients to work, they
must be read from the ReST bay endpoint. To execute
native clients, we must have one truth of the state
of the system, not two as we do now. This patch adds
changes for Replication Controller.

Also, please refer to the related-bug as to the temporary changes
done to make the test work for other objects namely pod,
service. These changes will be removed when the object from bay
patches for all the k8s objects are merged as part of a seperate
patch.

Partially-Implements: bp objects-from-bay
Related-Bug: #1502367
Related-Bug: #1504379

Change-Id: I7905af9e22f47b16d92043cc1fdcb1cdf72ebc48
2015-11-16 12:06:28 -08:00
Vilobh Meshram f231a60942 Fix the failure to scale-down k8s cluster
Fix the failure to scale-down k8s cluster. We were getting this
failure because as part of scaling, Bay needs to be retrieved for
the respective k8s obj. But if the object passed is a Bay itself
we need not retrieve the Bay. At present even for Bay object the
code proceeds ahead to retrieve bay and cannot find bay_uuid
attribute. This patch fixes this problem.

We might need to backport this fix to stable/liberty as well.

Change-Id: I7ed03af8bdbb8647851751bb550d9529d96b5cb4
Closes-Bug: #1509439
2015-10-23 13:29:49 -07:00
Hongbin Lu 18b61bce51 Fix incorrect usage of CertManager in k8s_api
This should fix a 400 error on getting certificates from Barbican.

Change-Id: I5cd934ba0df41fe34e74ae7c90febeccc821f758
Closes-Bug: #1506906
2015-10-16 16:49:08 -04:00
Surojit Pathak ec2cd88a05 Make Kubernetes API call secure
This patch makes API call to Kubernetes secure using the certificate
and key.

Co-Authored-By: Madhuri Kumari<madhuri.kumari@intel.com>
Co-Authored-By: OTSUKA, Yuanying<yuanying@fraction.jp>
Depends-On: I76b0f91f0c44f9880980e35c6b8856ea48ed3ce1
Change-Id: Id4dceb83f67b80f5b39e3047011f9e34e840359d
Partially-Implements: blueprint secure-kubernetes
2015-10-08 16:41:38 +09:00
OTSUKA, Yuanying 30b3d99d5c Add TLS support in heat kubernetes
This patch modifies template to generate certificates and configure TLS
settings for kube-apiserver/kubelet/kube-proxy.

Co-Authored-By: Andrew Melton <andrew.melton@rackspace.com>
Partially-Implements: bp secure-kubernetes
Change-Id: I76b0f91f0c44f9880980e35c6b8856ea48ed3ce1
2015-10-08 15:05:42 +09:00
wenchma a3a43ef225 Sync the description with Kubernetes Release 1 version
Closes-bug: #1498385

Change-Id: Iafe5529a8c060d0ea704eea738e696427c09c25c
2015-09-22 17:34:25 +08:00
Ton Ngo 4bfed61fe3 Migrate to Kubernetes Release 1
Kubernetes Release 1.0 was announced at OSCON

A new Fedora Atomic image has been built with version 1.0.4 and
this series of patches will update the templates, scripts, documents
to work with the new image.

The api has also been changed from v1beta3 to v1 and the beta
api is no longer available, so the interface between Magnum and
Kubernetes master are updated as well in this series of patches.

This particular patch will bring up a V1 cluster with the
bay-create command.  Because the switch to the V1 API requires
all the code changes to be applied at once, this patch pulls
in portion of 3 patches together.  The changes include:

1. devstack plugin downloads the new image.

2. k8s conductor and other code calls the new V1 client and
k8s methods.

3. Configuration for k8s services and docker updated with
new parameters.

4. Minion registration and example code updated to V1.

5. Functional tests updated to V1.

6. Gate test setup points to the new image.

Co-Authored-By: Hongbin Lu <hongbin.lu@huawei.com>

Change-Id: I046931ad491e8b7ee45943852901eac5c3df913e
Partially-Implements: blueprint kubernetes-v1
2015-09-21 15:02:58 +08:00
lei-zhang-99cloud d14382d997 Add port type on port option
According to http://docs.openstack.org/developer/oslo.config/cfg.html
oslo.config can use portType to support the ability to set valid range
on port option values

Closes-Bug: #1488861

Change-Id: Ic4310532f4155ade1706f0bca8df9466665aea97
2015-08-27 09:52:39 +08:00
Hongbin Lu bccd681de7 Make k8sclient use the load balancer address
Currently, our python k8sclient uses the IP address of the master node
as the API endpoint. As we are going to have multiple master nodes,
we need to use IP address of the load balancer instead.

Change-Id: I4da0a80f489f634afc154e8b3626b8c12cc50e86
Partially-Implements: blueprint make-master-ha
2015-07-27 14:13:46 -04:00
Lin Yang 03450e5907 Rename "k8s_master_url" to a better name
As k8s ha masters have been refined in [1], rename "k8s_master_url" to
a better name "k8s_api_endpoint".

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

Change-Id: Iecdfda410b6c82a5ae4fa575eeb222f91f21ef5a
Closes-Bug: #1477301
2015-07-23 14:34:56 +08:00
Hongbin Lu 8d9649bc1f Move conductor common implementations into module
This allows common implementations to be reused later. Below is
the list of methods that were moved and renamed:
* handlers.k8s_conductor._retrieve_bay -> utils.retrieve_bay
* handlers.bay_conductor._get_baymodel -> utils.retrieve_bay
* handlers.k8s_conductor._retrieve_baymodel -> utils.retrieve_baymodel
* handlers.k8s_conductor._object_has_stack -> utils.object_has_stack
* handlers.k8s_conductor._retrieve_k8s_master_url ->
                                      k8s_api._retrieve_k8s_master_url
* handlers.k8s_conductor.Handler.k8s_api -> k8s_api.create_k8s_api

Change-Id: Ia10625f35667fd9309dc3627e2f2d31455dd19be
Partially-Implements: blueprint magnum-smart-bay-scale-down
2015-07-02 10:10:11 -04:00