This repository has been archived by the owner on May 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle cases with namespace quotas limits sets (#1182)
* feat(resourcequota): Handle cases with namespace quotas limits sets Handle 2 cases: * User did not set quota for applications or set it incorrectly * User tries to scale the application when limits are already exceeded (overuse) * Don't raise RuntimeError if no events in namespace * Add test for _handle_not_ready_pors function * Fix indents required by flake8 * Use replicaset events for handle quota exceed cases * Don't try to wait for pods started if we have failed events in ReplicaSet
- Loading branch information
Showing
5 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from scheduler.exceptions import KubeHTTPException | ||
from scheduler.resources import Resource | ||
from datetime import datetime | ||
import uuid | ||
|
||
DATETIME_FORMAT = '%Y-%m-%dT%H:%M:%SZ' | ||
|
||
|
||
class Events(Resource): | ||
""" | ||
Events resource. | ||
Warning! Used ONLY for testing purposes | ||
""" | ||
short_name = 'ev' | ||
|
||
def create(self, namespace, name, message, **kwargs): | ||
url = self.api('/namespaces/{}/events'.format(namespace)) | ||
data = { | ||
'kind': 'Event', | ||
'apiVersion': 'v1', | ||
'count': kwargs.get('count', 1), | ||
'metadata': { | ||
'creationTimestamp': datetime.now().strftime(DATETIME_FORMAT), | ||
'namespace': namespace, | ||
'name': name, | ||
'resourceVersion': kwargs.get('resourceVersion', ''), | ||
'uid': str(uuid.uuid4()), | ||
}, | ||
'message': message, | ||
'type': kwargs.get('type', 'Normal'), | ||
'firstTimestamp': datetime.now().strftime(DATETIME_FORMAT), | ||
'lastTimestamp': datetime.now().strftime(DATETIME_FORMAT), | ||
'reason': kwargs.get('reason', ''), | ||
'source': { | ||
'component': kwargs.get('component', ''), | ||
}, | ||
'involvedObject': kwargs.get('involvedObject', {}) | ||
} | ||
|
||
response = self.http_post(url, json=data) | ||
if not response.status_code == 201: | ||
raise KubeHTTPException(response, 'create Event for namespace {}'.format(namespace)) # noqa | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters