Propagate domain conditions to ingress and gateway objects #719
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.
closes: #217
What
We noted that a common error case is when a free user tries to setup their first ingress object, if they haven't found out about their 1 free reserved domain, they may try to use their own custom host and it will fail to be created because they can't reserve additional domains and need to use their free one instead.
However, no information is expressed on the ingress object. The operator sees this ingress object and creates a Domain CRD that would have status conditions and events saying
Domain "tinyllama-free-account-domain-test.ngrok.app": HTTP 400: Only accounts on paid plans can reserve domains. Your account can't reserve domains. Upgrade to a paid plan at: https://dashboard.ngrok.com/billing/choose-a-plan [ERR_NGROK_401] Operation ID: op_36OOAJkG4M2Iu8OegrXO0FKJ0k3. But you have to know to look for that CRD or to list all events.Instead we would like this information to be more discoverable on the ingress object.
How
Ingress doesn't have conditions on its status, so we can only really use events to relay information.
The below approach is 1 idea. This hooks into the managerdriver ControllerEventHandler functionality that watches other resources. When the status of a domain is updated with a new condition, we can turn that into an event we push to the ingress object. The intention is for this to be extensible to other resources like conditions on the Cloud and Agent endpoints as well (the agent endpoints however require a different way to find what ingress/gateway objects spawned them).
Alternative Approaches
This is getting condition updates and pushing them as events. Alternatively, we could try to make the Domain events work as a multi-event emitter. The events about the errors are emitted by our base controller though https://github.com/ngrok/ngrok-operator/blob/main/internal/controller/base_controller.go#L84 so we would need some abstract way to lookup other resources to event to as well.
Looking for some feedback on this approach before i go too deep.