-
Notifications
You must be signed in to change notification settings - Fork 4
Support replicaset and deployment info #342
Support replicaset and deployment info #342
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! But, I have a few questions.
@@ -6,7 +6,7 @@ image: | |||
pullPolicy: IfNotPresent | |||
sideCartContainerName: kubectl | |||
sideCartContainerArgs: "[ \"proxy\", \"-p\", \"8001\" ]" | |||
sideCartContainerImage: gcr.io/google_containers/kubectl:v0.18.0-350-gfb3305edcf6c1a | |||
sideCartContainerImage: lachlanevenson/k8s-kubectl:v1.9.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this source? Can we just trust it? Nothing more Google official?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The google one has not been updated since january 2017.
This is the source: https://github.com/lachie83/k8s-kubectl
It has most stars on github and most pulls on dockerhub from the images I found
logger.warn('Could not retrive deployment information, verify your RBAC settings'); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not lint complain about this extra empty line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, but I removed it anyways ;)
@@ -54,8 +75,15 @@ class KubernetesClient { | |||
const ip = pod.status.podIP; | |||
const engine = { networks: [{ ip }], labels }; | |||
const key = pod.metadata.uid; | |||
const replicaSet = replicaMap.get(pod.metadata.ownerReferences[0].uid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if it does not exist, does it become undefined
?
There simply is no property in the response, or the key is is there but with value undefined
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No key at all
* pod: | ||
* type: object | ||
* description: Pod information in verbatim format as returned by the Kubernetes API. | ||
* replicaSet: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we document that this key might not exist? Or, will it always exist but with possible value undefined
? Should we clarify this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the key will not exist, but I will verify and add that info in the docummentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified that the key does not exist if the value is undefined.
The values are not marked as required in the swagger spec, so they are not expected to always exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some code coverage branches missed
replicaMap.set(item.metadata.uid, item); | ||
}); | ||
} catch (error) { | ||
logger.warn('Could not retrive replicaset information, verify your RBAC settings'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add unit test that covers this case and verify expected output.
deploymentMap.set(item.metadata.uid, item); | ||
}); | ||
} catch (error) { | ||
logger.warn('Could not retrive deployment information, verify your RBAC settings'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add unit test that covers this case and verify expected output.
@@ -40,6 +40,26 @@ class KubernetesClient { | |||
* @returns {Promise<EngineContainerSpec[]>} A promise to a list of engine container specs. | |||
*/ | |||
static async listEngines() { | |||
const replicaMap = new Map(); | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason why we're doing these sequentially? AFAIK they don't use any data from previous calls and can be parallelized?
E.g.
const replicas = kubeHttpGet('/apis/apps/v1/replicasets');
const deployments = kubeHttpGet('/apis/apps/v1/deployments');
const result = await Promise.all([replicas, deployments]);
// result[0] = replicas, etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No you are right, we should definitely parallelize them :)
replicaMap.set(item.metadata.uid, item); | ||
}); | ||
} catch (error) { | ||
// Do nothing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably log something if this fails, or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried logging if it fails, since this will be the same on every "round" it gets very spammy.
…he replicaset or deployment endpoints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Supporting replicaset and deployment info.
Also changing sidecar container since the one we had before was very old and did not support newer APIs