Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

ref(scheduler): split up the scheduler code into individual resources and to be modular#1016

Merged
helgi merged 1 commit intodeis:masterfrom
helgi:rewrite_client
Aug 26, 2016
Merged

ref(scheduler): split up the scheduler code into individual resources and to be modular#1016
helgi merged 1 commit intodeis:masterfrom
helgi:rewrite_client

Conversation

@helgi
Copy link
Copy Markdown
Contributor

@helgi helgi commented Aug 26, 2016

This adds a resources package which contains all Kubernetes resources as their own individual classes.
Each resource is self registering via the ResourceRegistry metaclass, this allows the base Resource class to know what resources are available and expose that up into KubeHTTPClient

Each resource can specify their own api prefix and version, which allows us to support resources moving between API endpoints (see HPA, a new resource).
To make it easy for resource to interact with one another each resource and the KubeHTTPClient can access other resources via self.hpa.create() or self.pod.get(), the short form (if a resource supports that) works, singular and plural also work via some intelligent mapping

Additionally get() and gets() have been merged together into one get() per Resource

version() was added to let Resources find out what Kubernetes version they are dealing with.

Closes #875

@helgi helgi added this to the v2.5 milestone Aug 26, 2016
@helgi helgi self-assigned this Aug 26, 2016
@deis-bot
Copy link
Copy Markdown

@kmala, @bacongobbler and @mboersma are potential reviewers of this pull request based on my analysis of git blame information. Thanks @helgi!

@codecov-io
Copy link
Copy Markdown

codecov-io commented Aug 26, 2016

Current coverage is 87.09% (diff: 77.18%)

Merging #1016 into master will increase coverage by 0.53%

@@             master      #1016   diff @@
==========================================
  Files            29         41    +12   
  Lines          3289       3464   +175   
  Methods           0          0          
  Messages          0          0          
  Branches        557        578    +21   
==========================================
+ Hits           2847       3017   +170   
- Misses          291        292     +1   
- Partials        151        155     +4   

Powered by Codecov. Last update 899e008...56b32d4

@helgi helgi force-pushed the rewrite_client branch 2 times, most recently from 8db6143 to 02f9505 Compare August 26, 2016 19:10
@helgi
Copy link
Copy Markdown
Contributor Author

helgi commented Aug 26, 2016

There was a successful e2e run but CI didn't update GH - https://ci.deis.io/job/workflow-test-pr/5904/console

@kmala kmala added the LGTM1 label Aug 26, 2016
Comment thread rootfs/scheduler/__init__.py Outdated

@staticmethod
def unhealthy(status_code):
if not 200 <= status_code <= 299:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function could be simplified:

def unhealthy(status_code):
    return 200 <= status_code <= 299

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure could, but it was just a copy of what we had there originally but brought into the class

@mboersma
Copy link
Copy Markdown
Member

My comments are all minor and can be ignored. Nice refactor! :lgtm:

… and to be modular

This adds a resources package which contains all Kubernetes resources as their own individual classes.
Each resource is self registering via the ResourceRegistry metaclass, this allows the base Resource class to know what resources are available and expose that up into KubeHTTPClient

Each resource can specify their own api prefix and version, which allows us to support resources moving between API endpoints (see HPA, a new resource).
To make it easy for resource to interact with one another each resource and the KubeHTTPClient can access other resources via `self.hpa.create()` or `self.pod.get()`, the short form (if a resource supports that) works, singular and plural also work via some intelligent mapping

`version()` was added to let Resources find out what Kubernetes version they are dealing with.

Closes deis#875
@helgi
Copy link
Copy Markdown
Contributor Author

helgi commented Aug 26, 2016

@helgi helgi merged commit 7306202 into deis:master Aug 26, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

_api in the scheduler needs to handle non-v1 URLs better

5 participants