-
Notifications
You must be signed in to change notification settings - Fork 69
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
*: Refactor codebase with linters/formatters and upstream patterns #1253
Conversation
Skipping CI for Draft Pull Request. |
b16d92c
to
200e76d
Compare
/test test-unit |
@saswatamcode: The
Use In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/test test-unit |
/retest |
worker, err := forwarder.New(*cfg) | ||
if err != nil { | ||
return fmt.Errorf("failed to configure metrics collector: %v", err) | ||
return errors.Wrap(err, "failed to configure metrics collector") |
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.
any particular reason we would choose to import this package to handle errors in favour of stdlib?
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.
It's what we use for thanos upstream (or aiming to, promql-engine already uses it). This returns the stacktrace which is super useful at times. github.com/pkg/errors did similar I think, but is no longer maintained.
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.
I also prefer using the stdlib with fmt.Errorf("%w")
. Regarding the stack trace, I don't see why we would need it. I mean, if so, it is a symptom of bad error handling that is not descriptive enough in the stack.
I don't like depending on those small libs while the stdlib does the job. But it's me 😉
curl -L https://github.com/operator-framework/operator-sdk/releases/download/${_OPERATOR_SDK_VERSION}/operator-sdk_linux_amd64 -o operator-sdk | ||
elif [[ $OSTYPE == "darwin"* ]]; then | ||
curl -L https://github.com/operator-framework/operator-sdk/releases/download/${_OPERATOR_SDK_VERSION}/operator-sdk_darwin_amd64 -o operator-sdk | ||
fi |
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.
could probably make this a one liner with some uname command as a subshell?
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.
Yup! Just fyi, these shellscript changes are from formatting, not explicit changes
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.
yep, i get that, just flagging as I go but will pause on that and we can tackle bash maybe in isolation in a follow up
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.
Future note: we need to parameterize the architecture here too. Not everyone is running amd64
. Me and all other darwin
users in the team are running arm64
.
type RuleMatcher interface { | ||
MatchRules() []string | ||
} | ||
|
||
func init() { |
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.
👍
Name: "federate_filtered_samples", | ||
Help: "Tracks the number of samples filtered per federation", | ||
}), | ||
gaugeFederateErrors: promauto.With(cfg.Registry).NewGauge(prometheus.GaugeOpts{ |
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.
should we add a metric to calc total also?
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.
Yup, will add. I think there is also something else here that causes tests to fail, will take a look.
@@ -1,101 +0,0 @@ | |||
package http |
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.
was this unused?
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.
Yeah, builds without it!
# this package has a binary, so: | ||
command -v kubectl | ||
if [ $? -ne 0 ]; then | ||
echo "=====Setup kubectl=====" |
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.
maybe we could take some inspiration from https://github.com/rhobs/configuration/blob/main/Makefile#L216-L218 around handling this? seems cleaner?
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.
Yeah, haven't gone through all the shellscripts yet. I might clean them up explicitly in another follow-up!
# kubectl are now installed in current dir | ||
echo -n "kubectl version" && kubectl version | ||
echo "=====Setup kubectl=====" | ||
# kubectl required for kind |
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.
this all looks repeated? maybe we can simplify
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.
Yup!
echo "Current directory" | ||
echo $(pwd) | ||
cd ${WORKDIR}/.. | ||
git clone https://github.com/coreos/kube-prometheus.git |
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.
url is outdated and will cause a redirect
echo $(pwd) | ||
cd ${WORKDIR}/.. | ||
git clone https://github.com/coreos/kube-prometheus.git | ||
echo "Replace namespace with openshift-monitoring" |
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.
im trying to understnad whats happening here? on KinD cluster, why do we need to use openshift-monitoring namespace with prom operator? 🤔
I reviewed the PR commit by commit. Thanks for having them well organised! |
Errors
I understand the reason of not wanting to depend on small package, but there are a few reasons, why I think it is generally better than the combination of stdlib
And if anything, we maintain Bingo
Curious about this, why do we want to avoid bingo? Is it the extra files or something else you noticed @thibaultmg? LoggingAlso, I have an outstanding question apart from errors, which is logging. Seems like this repo uses |
c635ee9
to
81c6df5
Compare
/retest |
On error handling, I heavily agree with @thibaultmg's point.
On Bingo, I also agree with @thibaultmg's point.
Overall, my opinion is: I like to stick with the standard library whenever possible. We should all be very familiar with it. When not possible, let's look for tools that are "de-facto" standards in the community. There are many good reasons for this, including but not limited to:
|
Hey,
I think it is more of a matter of what tools you are used to. Because for me, it is this
I admit it brings useful things to the table. But I don't think we need it enough to not use
I don't have strong opinions on this. In my personal projects I use zerolog which I like. With go 1.21 I would give a shot to Overall I totally agree with @douglascamata remarks about the benefits of using the standard lib as much as possible. This is what I strive for in my projects. But again, It is not a blocker if the majority of the team enjoys these tools 😉 |
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! 🚀
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.
LGTM 🚀
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: douglascamata, saswatamcode, thibaultmg The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
…h github.com/efficientgo/core/errors Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
Signed-off-by: Saswata Mukherjee <[email protected]>
c5feb91
to
a64109d
Compare
New changes are detected. LGTM label has been removed. |
/retest |
SonarCloud Quality Gate failed. 0 Bugs 41.3% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
@saswatamcode: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Lots of TODOs still pending (that will be done in separate PRs), but this does the following.
github.com/efficientgo/core/errors