Skip to content

Commit

Permalink
Merge pull request #199 from Mirantis/cluster-timeout
Browse files Browse the repository at this point in the history
finish cluster timeout
  • Loading branch information
tomkukral authored Jan 15, 2018
2 parents da438e3 + 6102e07 commit 71ebae9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ python:
- '3.6'
service:
- docker
notifications:
slack:
secure: imXU/zt9IjKk5OvjZkTICTmxOTKGaZIej2kf7m5iSAKrdM7Lsjhj1m464qOViH3AMjMMZeprC1SL/jFF5azu2DNkQe5j1UlUu1ZxQpwnpmXJaLyTznDZSa76LPoY/R4sqJYozZLzfMQivnIUe6NGTP5vDX8CXpndaOgfAulDzks6xXDTw8q1dyKTtqFx8aPbAFAYRPagaNpy62j09aeNXDY8OVUSJsx8xylRmbHY+t1AH5AMkDPY5AeI0D/CJH1Hnbq88MmvdgUn8OqjvWMgiXsrDFAPZ4WdZCgJZuP2D4jrDuAsnchrOrVi6wKJWA9rNqJD8TqqF8Q8JhdeVAJ098GXAyhkJlDtfeEbh8TYIkLNgpW7e/auh5rzHk5MvH7kTVzyZjGMb7Vo+7c7nypFoWeom1m8Pg5rCT7vx7+0NhQjg1moMQ2kPWzaZkITDdblxuf6rpraEx2ydqPh6pAAto+VWXRrdbJJTGSTVIfPFDHYeqkCq+QVGfdCi2BucnnQVZJLUqEdGxnn86ICwhjJ5uC4Ah7Czd/pZOrdgFMWTT6DS9fjRiIHOnAAp1wKYzAoRBKQkhltDFMrayDxN5dp+IXDnnlQWPm14mwAyNd/zt8pWCue5hT2oK7oeuQsNfSemSPg92DCZRZNZ684UbJGKn0RJlSpXLyQRjja0IjA+Kk=
on_success: change
on_failure: always
on_pull_requests: false
stages:
- name: test
- name: build
Expand Down
7 changes: 6 additions & 1 deletion kqueen/engines/gce.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,12 @@ def cluster_get(self):
First we try to get cluster by external_id, because its much more efficient in this
implementation. If its not possible yet, we return from the slower method
"""
request = self.client.projects().zones().clusters().get(projectId=self.project, zone=self.zone, clusterId=self.cluster_id)
request = self.client.projects().zones().clusters().get(
projectId=self.project,
zone=self.zone,
clusterId=self.cluster_id
)

try:
response = request.execute()
except Exception as e:
Expand Down
15 changes: 9 additions & 6 deletions kqueen/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from datetime import datetime
from datetime import timedelta
from importlib import import_module
from kqueen.config import current_config
from kqueen.kubeapi import KubernetesAPI
Expand All @@ -11,7 +13,6 @@
from kqueen.storages.etcd import RelationField
from kqueen.storages.etcd import StringField
from tempfile import mkstemp
from datetime import datetime, timedelta

import logging
import os
Expand All @@ -38,15 +39,16 @@ class Cluster(Model, metaclass=ModelMeta):

def get_state(self):
try:
cluster = self.engine.cluster_get()
remote_cluster = self.engine.cluster_get()
except Exception as e:
logger.error('Unable to get data from backend for cluster {}'.format(self.name))
cluster = {}
remote_cluster = {}

if 'state' in cluster:
if cluster['state'] == self.state:
if 'state' in remote_cluster:
if remote_cluster['state'] == self.state:
return self.state
self.state = cluster['state']

self.state = remote_cluster['state']
self.save()
else:
self.state = config.get('CLUSTER_UNKNOWN_STATE')
Expand All @@ -56,6 +58,7 @@ def get_state(self):
max_age = timedelta(seconds=config.get('PROVISIONER_TIMEOUT'))
if self.state == config.get('CLUSTER_PROVISIONING_STATE') and datetime.utcnow() - self.created_at > max_age:
self.state = config.get('CLUSTER_ERROR_STATE')
self.save()

return self.state

Expand Down

0 comments on commit 71ebae9

Please sign in to comment.