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

Resource client patch for apply status #517

Merged
merged 42 commits into from
Sep 14, 2022
Merged

Conversation

kdorosh
Copy link
Contributor

@kdorosh kdorosh commented Sep 9, 2022

lowers the number of api calls made to k8s apiserver; helps with status scalability for gloo as a client not getting rate limited talking to the k8s apiserver.

only marked with WIP label for now to prevent merges until solo-io/gloo#7133 passes ci; in the meantime this is ready for review gloo ci is passing

@solo-changelog-bot
Copy link

Issues linked to changelog:
solo-io/gloo#7076

@kdorosh
Copy link
Contributor Author

kdorosh commented Sep 9, 2022

@kdorosh kdorosh marked this pull request as ready for review September 13, 2022 20:41
@kdorosh kdorosh requested a review from elcasteel September 13, 2022 21:11
Comment on lines +277 to 283
if errors.IsNotExist(writeErr) {
logger.Debugf("did not write report for %v : %v because resource was not found", resourceToWrite.GetMetadata().Ref(), status)
delete(resourceErrs, resource)
continue
}

if writeErr != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is different about the 2 if statements here? I am unfamiliar with errors.IsNotExist(writeErr).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that error is for the scenario when we try to patch a resource that no longer exists (e.g. a user deleted it). rather than report an error in the logs, we just remove it from our in memory report and swallow the non-error. for any other error type we will report the error


buf := &bytes.Buffer{}
var marshaller jsonpb.Marshaler
marshaller.EnumsAsInts = false // prefer jsonpb over encoding/json marshaller since it renders enum as string not int (i.e., state is human-readable)
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently we write out ints for the states. If we want to switch to writing strings we should call it out in the changelog. I assume that this change won't affect any tooling around statuses because the unmarshaller will handle it the same regardless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

happy to call that out in the changelog. yeah we currently use the jsonpb to unmarshal so it can handle either format, so im just opting for better readability

if apierrors.IsNotFound(err) {
return nil, errors.NewNotExistErr(namespace, name, err)
}
return nil, errors.Wrapf(err, "patching secret from kubernetes")
Copy link
Contributor

Choose a reason for hiding this comment

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

Clarify in this message that we're patching the status on the secret. Users tend to zero in on log messages that have things like "secret" in them so it's good to be as clear as possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Might as well include "status" in the other error messages well though.

@kdorosh
Copy link
Contributor Author

kdorosh commented Sep 14, 2022

@soloio-bulldozer soloio-bulldozer bot merged commit 618b1c9 into master Sep 14, 2022
@soloio-bulldozer soloio-bulldozer bot deleted the resource_client_patch branch September 14, 2022 16:03
jackstine added a commit that referenced this pull request Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants