Skip to content

Conversation

@Wwwsylvia
Copy link
Contributor

@Wwwsylvia Wwwsylvia commented Apr 24, 2020

Description

Fix az acr check-health : Error image operating system "linux" cannot be used on this platform
Fix the bug that az acr check-health always throws "DOCKER_PULL_ERROR" on Windows

Before:
image

After:
image

Testing Guide

az acr check-health --name myregistry --ignore-errors --yes

History Notes

[Component Name 1] BREAKING CHANGE: az command a: Make some customer-facing breaking change.
[Component Name 2] az command b: Add some customer-facing feature.


This checklist is used to make sure that common guidelines for a pull request are followed.

@Wwwsylvia
Copy link
Contributor Author

@yugangw-msft Could you help to review?

@Wwwsylvia Wwwsylvia changed the title [ACR] az acr check-health: Fix docker pull bug [ACR] az acr check-health: Fix "DOCKER_PULL_ERROR" for Windows container Apr 24, 2020
@Wwwsylvia Wwwsylvia changed the title [ACR] az acr check-health: Fix "DOCKER_PULL_ERROR" for Windows container [ACR] az acr check-health: Fix "DOCKER_PULL_ERROR" for Windows containers Apr 24, 2020
@Wwwsylvia Wwwsylvia changed the title [ACR] az acr check-health: Fix "DOCKER_PULL_ERROR" for Windows containers [ACR] az acr check-health: Fix "DOCKER_PULL_ERROR" Apr 24, 2020
@Wwwsylvia Wwwsylvia changed the title [ACR] az acr check-health: Fix "DOCKER_PULL_ERROR" [ACR] az acr check-health: Fix "DOCKER_PULL_ERROR" on Windows Apr 24, 2020
@yonzhan yonzhan requested a review from qwordy April 25, 2020 00:36
@yonzhan yonzhan added this to the S169 - For Build milestone Apr 25, 2020
@yonzhan
Copy link
Collaborator

yonzhan commented Apr 25, 2020

add to S169

if stderr:
_handle_error(DOCKER_PULL_ERROR.append_error_message(stderr), ignore_errors)
if DOCKER_PULL_WRONG_PLATFORM in stderr:
print_pass("Docker pull of '{}'".format(IMAGE))
Copy link
Member

Choose a reason for hiding this comment

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

in cli we don't use print but logger, just checked this print_pass is used several places in this file. what scenario it's used for besides normal logger methods, could you pls change to logger.xxx?

Copy link
Member

@fengzhou-msft fengzhou-msft Apr 26, 2020

Choose a reason for hiding this comment

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

Other information like versions is also printed in stderr, how do users use the result of acr check-health command in a script?

Copy link
Contributor Author

@Wwwsylvia Wwwsylvia Apr 27, 2020

Choose a reason for hiding this comment

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

Thanks, I've replaced print() with logger.warning().

Other information like versions is also printed in stderr, how do users use the result of acr check-health command in a script?

az acr check-health is for troubleshooting purpose, usually users would not need the output of this command in script. An exit code is enough to check the status.

@qwordy
Copy link
Member

qwordy commented Apr 26, 2020

How about output error without modification?
This line is not very robust. Usually, we should rely on error code rather than string matching.

if DOCKER_PULL_WRONG_PLATFORM in stderr:

@Wwwsylvia
Copy link
Contributor Author

Wwwsylvia commented Apr 27, 2020

How about output error without modification?

The original error was due to the limitation of mcr (the hello-world image does not support Windows), in this case the user's environment was still "healthy" as long as the image can be pulled. The idea of this PR is to dismiss this error and avoid confusing users.

This line is not very robust. Usually, we should rely on error code rather than string matching.

if DOCKER_PULL_WRONG_PLATFORM in stderr:

We knew string matching is definitely not a good practice, but unfortunately it seems to be the only way to implement this, since currently Docker CLI does not return different exit codes to distinguish different errors types. Hope The Docker team can improve this someday. (I found someone raised this [Proposal] docker pull return code issue in the Docker CLI repo, but it's not resolved yet...)

@Wwwsylvia Wwwsylvia requested a review from yungezz April 27, 2020 06:20
@Wwwsylvia
Copy link
Contributor Author

This PR is ready for review

Copy link
Member

@yungezz yungezz left a comment

Choose a reason for hiding this comment

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

LGTM. will approve after the color/style removed

from colorama import Fore, Style, init
init()
print(str(message) + " : " + Fore.GREEN + "OK" + Style.RESET_ALL, file=sys.stderr)
logger.warning(str(message) + " : " + Fore.GREEN + "OK" + Style.RESET_ALL)
Copy link
Member

Choose a reason for hiding this comment

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

pls be aware of that warning will display to stderr. Some customers who're doing automation don't want warning in stderr to break auto pipeline

Copy link
Member

Choose a reason for hiding this comment

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

and we don't suggest color in output, except it's from CLI underlying framework.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed

@Wwwsylvia
Copy link
Contributor Author

Can anyone help to merge if no more concerns?

@fengzhou-msft fengzhou-msft merged commit 16de64f into Azure:dev Apr 29, 2020
@Wwwsylvia Wwwsylvia deleted the lixlei/fix-check-health branch April 29, 2020 01:41
@ghost ghost added Container Registry az acr and removed ACR labels Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az acr check-health : Error image operating system "linux" cannot be used on this platform

5 participants