-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Added log message for API call failures #7792
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
Conversation
Thanks for opening your first Pull Request here! Please check out our Contributing guidelines and confirm that you Signed off. |
a6bc2e5
to
1ed9fa9
Compare
@prady0t, please show in the Proof section what this log message looks like when generated and how we can test your code to see it for ourselves. Also, please use correct closing keywords; "solves" will not automatically link to an issue. Please follow and complete the PR template as requested. |
@chipzoller Sorry for the incomplete PR. I'll make required changes. I'm having some query regarding cli output which I asked earlier on slack. Can you please help me with that? |
@prady0t - the changes break the builds, can you fix it? |
@realshuting It fails because of this: |
Codecov Report
@@ Coverage Diff @@
## main #7792 +/- ##
==========================================
- Coverage 32.97% 32.87% -0.11%
==========================================
Files 234 239 +5
Lines 22426 22515 +89
==========================================
+ Hits 7396 7402 +6
- Misses 14272 14354 +82
- Partials 758 759 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Suspected to close #4774 |
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.
Please fix the linter issue.
@@ -85,30 +85,30 @@ func (l *contextLoader) newLoader( | |||
if entry.ConfigMap != nil { | |||
if l.cmResolver != nil { | |||
l := loaders.NewConfigMapLoader(ctx, l.logger, entry, l.cmResolver, jsonContext) | |||
return enginecontext.NewDeferredLoader(entry.Name, l) | |||
return enginecontext.NewDeferredLoader(entry.Name, l, logr.Logger{}) |
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.
There's a logger built in l
, you should re-use it.
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.
To use l.logger
which is builtin, I would have to rename l
here:
l := loaders.NewConfigMapLoader(ctx, l.logger, entry, l.cmResolver, jsonContext) |
Otherwise it creates conflicts here while giving
l.logger
as a parameter: return enginecontext.NewDeferredLoader(entry.Name, l) |
Should I rename it to something like
lm
everywhere?
I'm sorry but I can't see the linter issue anymore. Can you please approve linter workflow so that I can see why it's failing? Or maybe you can suggest how to fix. |
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.
Looks good! A few minor comments.
pkg/engine/context/deferred.go
Outdated
@@ -34,7 +37,11 @@ func (dl *deferredLoader) HasLoaded() bool { | |||
} | |||
|
|||
func (dl *deferredLoader) LoadData() error { | |||
return dl.loader.LoadData() | |||
if err := dl.loader.LoadData(); err != nil { | |||
dl.logger.Error(err, "Failed to load data: ") |
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.
Please start log messages with a lower case. It would also be helpful to add the name.
dl.logger.Errorf(err, "failed to load data for %s", dl.name)
@@ -85,30 +85,30 @@ func (l *contextLoader) newLoader( | |||
if entry.ConfigMap != nil { | |||
if l.cmResolver != nil { | |||
l := loaders.NewConfigMapLoader(ctx, l.logger, entry, l.cmResolver, jsonContext) | |||
return enginecontext.NewDeferredLoader(entry.Name, l) | |||
return enginecontext.NewDeferredLoader(entry.Name, l, logr.Logger{}) | |||
} else { | |||
l.logger.Info("disabled loading of ConfigMap context entry %s", entry.Name) | |||
return nil, nil | |||
} | |||
} else if entry.APICall != nil { | |||
if client != nil { | |||
l := loaders.NewAPILoader(ctx, l.logger, entry, jsonContext, jp, client) |
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 rename the l
in l := loaders.NewAPILoader(...
to something like ldr
.
Sorry for similar commits. DCO test keeps on failing even with the signed-off message |
All commits need to be signed - so if you only sign the latest one, it won't work. I would recommend that you squash the commits in this PR and sign the single commit then. |
@MarcelMue I think i messed up somewhere as I'm unable to do that (maybe because I keep merging |
What have you tried? I feel like solution like this should "just work": Just make sure you sign the commit in step two described on stackoverflow. |
Ah! this is what I was looking for. Thanks for the help |
@MarcelMue The above method was not working so I read DCO docs and did this instead : |
I've made another PR with same changes. Please review. #7834 |
Signed-off-by: Pradyot Ranjan rickprimeranjan@gmail.com
Explanation
There were no log messages for API call failures.
dl.logger.Error(err, "Failed to load data: ")
now prints the error along with log message.Related issue
Closes #7734
Closes #4774
Milestone of this PR
/milestone 1.10.2
What type of PR is this
Proposed Changes
Proof Manifests
Checklist
Further Comments