-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Remove global single instance of skaffoldOpts
in skaffold error package and use runContext Config
#5537
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5537 +/- ##
==========================================
+ Coverage 70.54% 70.69% +0.14%
==========================================
Files 410 411 +1
Lines 15640 15863 +223
==========================================
+ Hits 11034 11214 +180
- Misses 3793 3823 +30
- Partials 813 826 +13
Continue to review full report at Codecov.
|
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.
The command
→ cmd
is odd?
func suggestDeployFailedAction(runCtx runcontext.RunContext) []*proto.Suggestion { | ||
if isMinikube(runCtx.KubeContext) { | ||
func suggestDeployFailedAction(cfg Config) []*proto.Suggestion { | ||
if isMinikube(cfg.GetKubeContext()) { |
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'm fine with keeping this for now, but IMHO the config should have the cluster, which we can query if it's local, or specifically minikube or kind, etc.
And then we can have the clusters provide a status-check command. The generic one is kubectl describe nodes
and kubectl get events
.
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 think config.ClusterType()
could be a good addition so we don't have to repeat the logic many times.
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.
+1 and we can cache the result too.
if err != nil { | ||
return err | ||
} | ||
|
||
err = action(runner, config) | ||
|
||
return alwaysSucceedWhenCancelled(ctx, err) | ||
return alwaysSucceedWhenCancelled(ctx, runCtx, err) |
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 odd, but I don't see this change here?
yeah maybe a search replace did. i just noticed it. |
2b47821
to
7847eb2
Compare
func suggestDeployFailedAction(runCtx runcontext.RunContext) []*proto.Suggestion { | ||
if isMinikube(runCtx.KubeContext) { | ||
func suggestDeployFailedAction(cfg Config) []*proto.Suggestion { | ||
if isMinikube(cfg.GetKubeContext()) { |
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.
+1 and we can cache the result too.
@briandealwis hold off until i try again removing the error config bleeding into every packages. |
skaffoldOpts
in skaffold error package and use runContext ConfigskaffoldOpts
in skaffold error package and use runContext Config
skaffoldOpts
in skaffold error package and use runContext ConfigskaffoldOpts
in skaffold error package and use runContext Config
f07f367
to
9290bf3
Compare
@briandealwis This is ready for review again! |
ad09c9c
to
2e833c5
Compare
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.
A bunch of suggestions below, but this is a great improvement.
Co-authored-by: Brian de Alwis <bsd@acm.org>
Review Order:
When fixing #5485 , @briandealwis suggested removing the global
skaffoldOpts
in error package hereIn this PR
initErrors
,buildErrors
anddeployErrors
to individual packages.Problem
and allow packages to register problems. The suggestions, will switch theinterface
to respectiveConfig
and suggest suggestions.Suggestions
function to run on any interface and remove singleton use ofrunCtx
orskaffoldOpt
as mentioned by @briandealwis in his review feedback.So the following methods have changed
and
ShowAIError
is now called incmd.withRunner
flow whererunCtx
is available andhandleWellknownErrors
is deleted.creatNewRunner also returns a
RunContext
to pass to error handling.ActionableErr
was called inevent
packages which used global singeltonskaffoldOpts
. We know passrunCtx
duringevent.InitializeState
which is stored in
eventHandler
Mutliple goroutines accessing
handler.cfg
should not cause a data race because this value is not only written once inInitializeState
.See https://notes.shichao.io/gopl/ch9/#avoid-writing-the-variable
ActionableErr
now use this to pass theevent.Config
.