-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated image size calculation in docker v2 task #10352
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.
We should have tests
} | ||
} | ||
|
||
return imageSize.toString() + "B"; |
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.
should we use the formula to show B, KB or M kind of thing?
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.
Created bug on myself for handling the pending review comments. https://dev.azure.com/mseng/AzureDevOps/_workitems/edit/1529319
const sizeStringValue = size.match(matchPatternForSize); | ||
if (sizeStringValue && sizeStringValue.length > 0) { | ||
const sizeIntValue = parseFloat(sizeStringValue[0]); | ||
const sizeUnit = size.substring(sizeIntValue.toString().length); |
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.
you are not using "sizeStringValue[0]" for sizeIntValue.toString() because the "sizeIntValue.toString()" can have comma in it? if no reason, i would suggest to use "sizeStringValue[0]"
const sizeIntValue = parseFloat(sizeStringValue[0]); | ||
const sizeUnit = size.substring(sizeIntValue.toString().length); | ||
switch (sizeUnit.toLowerCase()) { | ||
case "b": return sizeIntValue; |
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 would recommend them like, 1K = 1024, 1m like 1k*1024 something like that a const
size = imageMatch[3]; | ||
} | ||
if (imageMatch && imageMatch.length >= 1) { | ||
digest = imageMatch[1]; |
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.
imageMatch[1] will be null, are you okay?
if not length check to be >=2
describe("DockerV2 Suite", function () { | ||
this.timeout(10000); | ||
|
||
if (!tl.osType().match(/^Win/)) { |
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.
why do you want to run on windows only?
console.log("\n"); | ||
|
||
const bitSize = "24.01B"; | ||
const kbSize = "8.999KB"; |
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 like 10240KB
We were extracting image size from docker push output, which is not correct as it is the image manifest size and does not always represent the exact image size. (Reference doc link)
Added changes to compute the image size as sum of the its' layers' size.
Also removed the RequestedFor label from the default image labels, as we don't want to expose user name in UI
Pod for testing- http://nidabas-desk/DefaultCollection/p1/_serviceEndpoints/ed2bc004-c695-4955-b8b5-b4488b89cad8/kubernetesSummary?namespace=default