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

{Monitor}Bug fix for stop iteration #12800

Merged
merged 3 commits into from
Mar 31, 2020

Conversation

mmyyrroonn
Copy link
Contributor

Fix #12191

Description of PR (Mandatory)
(Why this PR? What is changed? What is the effect? etc. A high-quality description can accelerate the review process)

Testing Guide
(Example commands with explanations)

History Notes:
(Fill in the following template if multiple notes are needed, otherwise PR title will be used for history note.)

[Component Name 1] (BREAKING CHANGE:) (az command:) make some customer-facing change.
[Component Name 2] (BREAKING CHANGE:) (az command:) make some customer-facing change.


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

@mmyyrroonn
Copy link
Contributor Author

@Juliehzl @arrownj @haroldrandom Is there any better way to fix it? I mean more native in python.

profile_names = [x.name for x in autoscale_settings.profiles]
if not profile_name in profile_names:
from knack.util import CLIError
raise CLIError('Profile name is invalid. Please check the existence of the profile.')
profile = next(x for x in autoscale_settings.profiles if x.name == profile_name)
Copy link
Contributor

@haroldrandom haroldrandom Mar 31, 2020

Choose a reason for hiding this comment

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

Another alternative is to use try...except sinppet to catch StopIteration error, then raise CLIError.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well. So next cannot handle such scenario and we need extra logic. Right? Compared to try..except, I prefer current one.

Copy link
Contributor

Choose a reason for hiding this comment

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

using try..except is the same what you did now.

@mmyyrroonn mmyyrroonn force-pushed the fix-12191-sutoscale-rules branch from 62f81ca to 82400f4 Compare March 31, 2020 06:35
@mmyyrroonn mmyyrroonn merged commit f6dbd25 into Azure:dev Mar 31, 2020
@mmyyrroonn mmyyrroonn deleted the fix-12191-sutoscale-rules branch March 31, 2020 06:52
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.

Unexpected error while list autoscale rules
3 participants