-
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
Add StatusCheck field to skaffold.yaml (#4904) #5706
Add StatusCheck field to skaffold.yaml (#4904) #5706
Conversation
From the linked issue:
Can we change the type of |
@maggieneterval @gsquared94 there's a newly introduced skaffold/cmd/skaffold/app/cmd/flags.go Lines 37 to 42 in bf8685a
You can see an example implementation on the skaffold/pkg/skaffold/config/types.go Lines 23 to 29 in bf8685a
|
Thanks for the comments, @gsquared94 and @marlon-gamez! In the spirit of small PRs, I will open a separate PR to make the status-check flag implement |
1b98fe4
to
a6414f9
Compare
Hi @marlon-gamez & @gsquared94, this should nearly be ready for review as I've rebased it off #5712. Just need to resolve an integration test error: |
Hey @maggieneterval, I think this issue is caused by this function not having a case for handling bools. skaffold/pkg/skaffold/schema/profiles.go Lines 311 to 348 in f280aa8
I'm actually curious about how this wasn't caught before with other bool fields. I'm asking the team about why this is and I'll get back to you |
It seems like we'll need to update this function to handle bool values as well. Trying locally, it seems that just adding case reflect.Bool:
if v.Interface() == reflect.Zero(v.Type()).Interface() {
return config
}
return v.Interface() should be good |
pkg/skaffold/schema/latest/config.go
Outdated
@@ -497,6 +497,9 @@ type TestCase struct { | |||
type DeployConfig struct { | |||
DeployType `yaml:",inline"` | |||
|
|||
// StatusCheck *beta* enables waiting for deployments to stabilize. | |||
StatusCheck bool `yaml:"statusCheck,omitempty"` |
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 omitempty
only works if this is *bool
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.
also, this needs to be *bool
anyways. Otherwise it'll get a value of false
by default and you can't distinguish if that value was set by the user or not (same problem as with the status-check
flag that you just fixed).
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.
👍 Updated! (My initial implementation had skaffold fix
automatically add a StatusCheck: true
stanza to the skaffold.yaml to preserve the existing enabled-by-default behavior, so I also removed that logic.)
scOpts := rc.Opts.StatusCheck.Value() | ||
scPipelines := rc.Pipelines.StatusCheck() | ||
if scOpts == nil { | ||
return scPipelines | ||
} | ||
return *sc | ||
return *scOpts |
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 logic breaks current behavior?
eg: If I don't define statusCheck
in my skaffold.yaml
it'll be set to false. Since I don't set the flag either, it'll skip status check (line 164).
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 should rather be:
scOpts := rc.Opts.StatusCheck.Value()
scConfig := rc.Pipelines.StatusCheck()
switch {
case scOpts != nil:
return *scOpts
case scConfig != nil:
return *scConfig
default:
return true
}
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.
👍 Updated! (My initial implementation had skaffold fix
automatically add a StatusCheck: true
stanza to the skaffold.yaml in order to not break the enabled-by-default behavior, but changing its type to *bool
instead to distinguish false from unspecified is much better, thanks!)
Codecov Report
@@ Coverage Diff @@
## master #5706 +/- ##
==========================================
- Coverage 70.68% 70.65% -0.03%
==========================================
Files 423 428 +5
Lines 16168 16193 +25
==========================================
+ Hits 11428 11441 +13
- Misses 3900 3908 +8
- Partials 840 844 +4
Continue to review full report at Codecov.
|
func (ps Pipelines) StatusCheck() *bool { | ||
var sc *bool | ||
// set the group status check to disabled if any pipeline has StatusCheck | ||
// set to false. |
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 was not sure what would be reasonable here; how/why would a user set only a single pipeline's StatusCheck
value to false? (Not 100% clear on the relationship between a skaffold.yaml file, a profile, and a pipeline, to be honest...)
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 not completely sure the reason a user would disable it in one, @gsquared94 might know a situation tho.
a skaffold.yaml can contain one or more skaffod configs. A config defines a pipeline so that skaffold knows how to build, test, deploy, and do statuscheck for a project. A config can also define profiles that replace parts of main config when the user activates a profile
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 skaffold.yaml can contain one or more skaffod configs. A config defines a pipeline
Ah, that makes sense. Thank you for clarifying! Let me know if it would be more reasonable to (1) disable healthcheck if any pipeline has StatusCheck set to false, or (2) enable healthcheck unless all pipelines have StatusCheck set to false. Thanks again for all your help with this!
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.
had a small discussion on this out of band, but this is probably a new scenario where we want to have values set on a per-config basis. there are surely situations where users want to enable health check for a single module, but leave it disabled for others (e.g. if one module is deploying something long running background task, health checks aren't useful), so it seems strange to disable it altogether if one particular module wants it off.
looking at how we have the code structured around the RunContext
right now, this isn't a trivial change, so in interest of not completely blocking this implementation I think we can do this in a follow up PR. in the meantime, we should do two things here:
- disable the health check if any pipelines explicitly disable it, since the alternative would be enabling it for long-running deployments that could cause frustrating UX
- error out if users are explicitly setting status check configuration in one pipeline, and explicitly disabling it in any other. this will prevent surprising behavior, and at least give users a thread they can follow to get things to work in a less confusing way (we should probably point to docs)
@maggieneterval would you mind also creating an issue to track the follow up work here, and tie it back to this PR? something like "Support configuring status check independently between modules"
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.
sorry I was out for a few days, but @nkubala's point above is exactly what I wanted to say.
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.
Thank you both so much for your help with this. I opened #5746 to document this follow-up work.
63dc3ba
to
7b40a1a
Compare
hey @maggieneterval, we just did a release and we need to generate a new schema version. Once #5748 goes in you'll just need to rebase on it and I think this PR should pretty much be good to merge after that! |
7b40a1a
to
f7627f8
Compare
This should be ready for a final look. Thank you! 😃 |
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.
Just a small nit, you can short circuit the enabled && disabled
check and return early if both are set in the for loop.
257d6e8
to
75ace97
Compare
CI is now failing with the following error:
Is this a known issue? I can try re-triggering the CI on Monday. |
I will try retrying now. But yes this has been happening a lot lately and @nkubala did some digging into it. |
Fixes: #4904
Merge before/after: Requires rebase after #5700, #5712, #5748 are merged.
Description
Add
StatusCheck
field to skaffold.yaml.User facing changes
Before:
After: