-
Notifications
You must be signed in to change notification settings - Fork 1
Revision improvements #113
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
Changes from 3 commits
e40aa03
f1372d8
85546bf
57d23f5
c5797aa
643915b
5c184a8
2694586
a41e56e
3c2190c
fc76232
3ade071
c190466
5549933
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -857,6 +857,19 @@ def _update_revision_weights(containerapp_def, list_weights): | |
| return old_weight_sum | ||
|
|
||
|
|
||
| def _validate_revision_name(cmd, revision, resource_group_name, name): | ||
| if revision.lower() == "latest": | ||
| return | ||
| revision_def = None | ||
| try: | ||
| revision_def = ContainerAppClient.show_revision(cmd, resource_group_name, name, revision) | ||
| except: # pylint: disable=bare-except | ||
| pass | ||
|
|
||
| if not revision_def: | ||
| raise ValidationError(f"Revision '{revision}' is not a valid revision name.") | ||
|
|
||
|
|
||
| def _append_label_weights(containerapp_def, label_weights, revision_weights): | ||
| if "traffic" not in containerapp_def["properties"]["configuration"]["ingress"]: | ||
| containerapp_def["properties"]["configuration"]["ingress"]["traffic"] = [] | ||
|
|
@@ -893,7 +906,6 @@ def _update_weights(containerapp_def, revision_weights, old_weight_sum): | |
| new_weight_sum = sum([int(w.split('=', 1)[1]) for w in revision_weights]) | ||
| revision_weight_names = [w.split('=', 1)[0].lower() for w in revision_weights] | ||
| divisor = sum([int(w["weight"]) for w in containerapp_def["properties"]["configuration"]["ingress"]["traffic"]]) - new_weight_sum | ||
| round_up = True | ||
| # if there is no change to be made, don't even try (also can't divide by zero) | ||
| if divisor == 0: | ||
| return | ||
|
|
@@ -903,9 +915,17 @@ def _update_weights(containerapp_def, revision_weights, old_weight_sum): | |
| for existing_weight in containerapp_def["properties"]["configuration"]["ingress"]["traffic"]: | ||
| if "latestRevision" in existing_weight and existing_weight["latestRevision"]: | ||
| if "latest" not in revision_weight_names: | ||
| existing_weight["weight"], round_up = _round(scale_factor * existing_weight["weight"], round_up) | ||
| existing_weight["weight"] = round(scale_factor * existing_weight["weight"]) | ||
| elif "revisionName" in existing_weight and existing_weight["revisionName"].lower() not in revision_weight_names: | ||
| existing_weight["weight"], round_up = _round(scale_factor * existing_weight["weight"], round_up) | ||
| existing_weight["weight"] = round(scale_factor * existing_weight["weight"]) | ||
|
|
||
| total_sum = sum([int(w["weight"]) for w in containerapp_def["properties"]["configuration"]["ingress"]["traffic"]]) | ||
| index = 0 | ||
| while total_sum < 100: | ||
| weight = containerapp_def["properties"]["configuration"]["ingress"]["traffic"][index % len(containerapp_def["properties"]["configuration"]["ingress"]["traffic"])] | ||
| index += 1 | ||
| total_sum += 1 | ||
| weight["weight"] += 1 | ||
|
Comment on lines
+926
to
+932
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what the purpose of this logic is but I'll test it (incl w the edge case you found)
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I assume it's related to the arithmetic error we were getting) |
||
|
|
||
|
|
||
| # required because what if .5, .5? We need sum to be 100, so can't round up or down both times | ||
runefa marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.