Skip to content

Commit

Permalink
fix(kubernetes): Use 'kind' constants rather than strings (#1580)
Browse files Browse the repository at this point in the history
This was causing a bug when loading autoscaler details
  • Loading branch information
lwander committed Apr 19, 2017
1 parent 73d40b6 commit 7d1b547
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class KubernetesUtil {
static String SECURITY_GROUP_LABEL_PREFIX = "security-group-"
static String LOAD_BALANCER_LABEL_PREFIX = "load-balancer-"
static String SERVER_GROUP_LABEL = "replication-controller"
static String DEPRECATED_SERVER_GROUP_KIND = "ReplicationController"
static String SERVER_GROUP_KIND = "ReplicaSet"
static String DEPLOYMENT_KIND = "Deployment"
static String JOB_LABEL = "job"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ class KubernetesServerGroupCachingAgent extends KubernetesCachingAgent implement
Map<String, Map<String, Event>> rsEvents = [:].withDefault { _ -> [:] }
try {
namespaces.each { String namespace ->
rcEvents[namespace] = credentials.apiAdaptor.getEvents(namespace, "ReplicationController")
rsEvents[namespace] = credentials.apiAdaptor.getEvents(namespace, "ReplicaSet")
rcEvents[namespace] = credentials.apiAdaptor.getEvents(namespace, KubernetesUtil.DEPRECATED_SERVER_GROUP_KIND)
rsEvents[namespace] = credentials.apiAdaptor.getEvents(namespace, KubernetesUtil.SERVER_GROUP_KIND)
}
} catch (Exception e) {
log.warn "Failure fetching events for all server groups in $namespaces", e
Expand All @@ -292,9 +292,9 @@ class KubernetesServerGroupCachingAgent extends KubernetesCachingAgent implement
Map<String, Map<String, HorizontalPodAutoscaler>> deployAutoscalers = [:].withDefault { _ -> [:] }
try {
namespaces.each { String namespace ->
rcAutoscalers[namespace] = credentials.apiAdaptor.getAutoscalers(namespace, "replicationController")
rsAutoscalers[namespace] = credentials.apiAdaptor.getAutoscalers(namespace, "replicaSet")
deployAutoscalers[namespace] = credentials.apiAdaptor.getAutoscalers(namespace, "deployment")
rcAutoscalers[namespace] = credentials.apiAdaptor.getAutoscalers(namespace, KubernetesUtil.DEPRECATED_SERVER_GROUP_KIND)
rsAutoscalers[namespace] = credentials.apiAdaptor.getAutoscalers(namespace, KubernetesUtil.SERVER_GROUP_KIND)
deployAutoscalers[namespace] = credentials.apiAdaptor.getAutoscalers(namespace, KubernetesUtil.DEPLOYMENT_KIND)
}
} catch (Exception e) {
log.warn "Failure fetching autoscalers for all server groups in $namespaces", e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class KubernetesServerGroupCachingAgentSpec extends Specification {
podMetadataMock.getNamespace() >> NAMESPACE
podMock.getMetadata() >> podMetadataMock
apiMock.getReplicationControllers(NAMESPACE) >> [replicationControllerMock]
apiMock.getEvents(NAMESPACE, "ReplicationController") >> [:].withDefault { _ -> [] }
apiMock.getAutoscalers(NAMESPACE, "replicationController") >> [:]
apiMock.getEvents(NAMESPACE, KubernetesUtil.DEPRECATED_SERVER_GROUP_KIND) >> [:].withDefault { _ -> [] }
apiMock.getAutoscalers(NAMESPACE, KubernetesUtil.DEPRECATED_SERVER_GROUP_KIND) >> [:]
apiMock.getPods(NAMESPACE, selector) >> [podMock]

def providerCacheMock = Mock(ProviderCache)
Expand Down

0 comments on commit 7d1b547

Please sign in to comment.