Skip to content
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

Merged
merged 3 commits into from
May 10, 2019

Conversation

dabasnidhi
Copy link
Contributor

@dabasnidhi dabasnidhi commented May 10, 2019

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
image

Copy link
Contributor

@bansalaseem bansalaseem left a 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";
Copy link
Member

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?

Copy link
Contributor Author

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);
Copy link
Member

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;
Copy link
Member

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];
Copy link
Member

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/)) {
Copy link
Member

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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add like 10240KB

@dabasnidhi dabasnidhi merged commit 4b540f0 into master May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants