-
Notifications
You must be signed in to change notification settings - Fork 17
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
fix: istio-pilot's handling of incomplete Gateway Services #263
Open
ca-scribner
wants to merge
3
commits into
main
Choose a base branch
from
fix-istio-loadbalancer-handling
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -235,6 +235,12 @@ def reconcile(self, event): | |||||
except ErrorWithStatus as err: | ||||||
handled_errors.append(err) | ||||||
|
||||||
try: | ||||||
# If Gateway Service is not ready, notify user | ||||||
self._assert_gateway_service_status() | ||||||
except ErrorWithStatus as err: | ||||||
handled_errors.append(err) | ||||||
|
||||||
try: | ||||||
self._send_gateway_info() | ||||||
except ErrorWithStatus as err: | ||||||
|
@@ -360,6 +366,17 @@ def upgrade_charm(self, _): | |||||
self.log.info("Upgrade complete.") | ||||||
self.unit.status = ActiveStatus() | ||||||
|
||||||
def _assert_gateway_service_status(self): | ||||||
"""Checks if the ingress gateway service is up, raising an ErrorWithStatus if it is not.""" | ||||||
if not self._is_gateway_service_up: | ||||||
raise ErrorWithStatus( | ||||||
f"Gateway Service '{self.model.config['gateway-service-name']}" | ||||||
f" in namespace {self.model.name} is missing or does not have an" | ||||||
f" external IP. If this persists, there may be a problem with" | ||||||
f" the Service.", | ||||||
WaitingStatus, | ||||||
) | ||||||
|
||||||
def _check_leader(self): | ||||||
"""Check if this unit is a leader.""" | ||||||
if not self.unit.is_leader(): | ||||||
|
@@ -647,7 +664,7 @@ def _report_handled_errors(self, errors): | |||||
) | ||||||
self._log_and_set_status(status_to_publish) | ||||||
for i, error in enumerate(errors): | ||||||
self.log.info(f"Handled error {i}/{len(errors)}: {error.status}") | ||||||
self.log.info(f"Handled error {i+1}/{len(errors)}: {error.status}") | ||||||
else: | ||||||
self.unit.status = ActiveStatus() | ||||||
|
||||||
|
@@ -822,11 +839,13 @@ def _get_address_from_loadbalancer(svc): | |||||
(str): The hostname or IP address of the LoadBalancer service | ||||||
""" | ||||||
ingresses = svc.status.loadBalancer.ingress | ||||||
|
||||||
# May happen due to the Kubernetes cluster not having a LoadBalancer provider | ||||||
if ingresses is None or len(ingresses) == 0: | ||||||
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. ?
Suggested change
|
||||||
return None | ||||||
|
||||||
if len(ingresses) != 1: | ||||||
if len(ingresses) == 0: | ||||||
return None | ||||||
else: | ||||||
raise ValueError("Unknown situation - LoadBalancer service has more than one ingress") | ||||||
raise ValueError("Unknown situation - LoadBalancer service has more than one ingress") | ||||||
|
||||||
ingress = svc.status.loadBalancer.ingress[0] | ||||||
if getattr(ingress, "hostname", None) is not None: | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 can use
enumerate(errors, start=1)