fix: server can be return as nil when not found causing panics #4934
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.
FIXES: #4931 where a panic was causes when mlserver was deleted while it had a model. The envoy logic was getting the server for this model but there was none.
We were return no error when a server was not found but just a nil server. Having checked all the uses I think returning an error is best and no functionality will change.
In future we could return a typed error for no server found if we think clients need to check for this type of error but this does not seem to be needed right now.
Have tested the use case in #4931 and the model is reloaded ok after the mlserver pod comes back.
The PR also cleans up the Envoy update to not do unnecessary calls when an error state has been hit. The control flow still needs to reach the end of the
modelUpdate
call to do batch updates.