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

fix: Fix standalone pods and deployment health check pending. #7691

Merged
merged 4 commits into from
Jul 28, 2022

Conversation

tejal29
Copy link
Contributor

@tejal29 tejal29 commented Jul 27, 2022

fixes: #7667

After some walkthrough, i feel its safe to remove empty namespace check. I added few tests added and realizes, ConsolidateNamespaces will never add an empty namespace to the return value if no new namespace are found.

Here is the flow of how namespaces are updated in Deploy


func New() {

// first namespace is set to "". 
defaultNamespace := ""
// then preference to kubectl.CurrentContext.Namespace if set. 

// Here cfg.GetNamespace() is opt.Namespace which is set to "" by default. This method collects all 
// namespaces in the pipeline.
namespaces, err := deployutil.GetAllPodNamespaces(cfg.GetNamespace(), cfg.GetPipelines())
}

// If user has not set any namespace on CLI or in the skaffold.yaml config 
// or in kubectl.CurrentConfig, 
// namespaces = []string{""}


func (k Deployer) Deploy(...., manifests ManifestList, ...) {

// CollectNamespace never adds "" namesapce value to namespaces 
// See tests https://github.com/GoogleContainerTools/skaffold/blob/bcbdfe043c2f334f919fa2e6ae06aed4a7578486/pkg/skaffold/kubernetes/manifest/namespace_test.go#L131 
namespaces, err := manifests.CollectNamespaces()

k.trackNamespaces(namespaces)
}


func (k *Deployer) trackNamespaces(namespaces []string) {

 // Consolidate namespaces will delete "" empty namespace if namespaces is non empty.  
// So the only case when empty
// namespace value "" is set to deployer namespace is when 
// *k.namespace already has the value in New and rendered manifest don't have any new manifests.
   *k.namespaces = deployutil.ConsolidateNamespaces(*k.namespaces, namespaces)
}


@conventional-commit-lint-gcf
Copy link

conventional-commit-lint-gcf bot commented Jul 27, 2022

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot
https://conventionalcommits.org/

@tejal29 tejal29 changed the title fix: Remove empty namespace check in diag.NeW fix: Fix standalone pods and deployment health check pending. Jul 27, 2022
@codecov
Copy link

codecov bot commented Jul 27, 2022

Codecov Report

Merging #7691 (edc8254) into main (290280e) will decrease coverage by 3.87%.
The diff coverage is 54.44%.

@@            Coverage Diff             @@
##             main    #7691      +/-   ##
==========================================
- Coverage   70.48%   66.60%   -3.88%     
==========================================
  Files         515      587      +72     
  Lines       23150    28103    +4953     
==========================================
+ Hits        16317    18719    +2402     
- Misses       5776     8029    +2253     
- Partials     1057     1355     +298     
Impacted Files Coverage Δ
cmd/skaffold/app/cmd/credits/export.go 0.00% <0.00%> (ø)
cmd/skaffold/app/cmd/deploy.go 40.90% <0.00%> (-12.94%) ⬇️
cmd/skaffold/app/cmd/test.go 44.44% <0.00%> (ø)
cmd/skaffold/skaffold.go 0.00% <0.00%> (ø)
cmd/skaffold/app/cmd/inspect_tests.go 62.50% <14.28%> (-1.14%) ⬇️
cmd/skaffold/app/cmd/render.go 35.48% <18.18%> (-5.90%) ⬇️
cmd/skaffold/app/cmd/lsp.go 28.12% <28.12%> (ø)
cmd/skaffold/app/cmd/run.go 64.28% <33.33%> (-9.63%) ⬇️
cmd/skaffold/app/cmd/fix.go 55.93% <38.88%> (-20.54%) ⬇️
cmd/skaffold/app/cmd/verify.go 41.17% <41.17%> (ø)
... and 335 more

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@tejal29 tejal29 marked this pull request as ready for review July 27, 2022 06:03
Copy link
Contributor

@aaron-prindle aaron-prindle left a comment

Choose a reason for hiding this comment

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

LGTM!

@aaron-prindle
Copy link
Contributor

nit: perhaps as a followup issues/PR we can add integration tests that can catch these cases where our standalone health checks are pending indefinitely?

@aaron-prindle aaron-prindle merged commit fd7c4bd into GoogleContainerTools:main Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Skaffold V2 seems to hang indefinitely when deploying Pod K8s Objects (most of the time)
2 participants