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

Wait for deployments #2010

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Wait for deployments #2010

wants to merge 7 commits into from

Conversation

skonto
Copy link
Contributor

@skonto skonto commented Mar 6, 2025

Fixes #2009

Proposed Changes

  • Skip applying webhook resources until deployments are available. This makes sure resources can be reconciled properly and any resources depending on webhooks will be deployed after webhooks are up.

Release Note

Proper order is enforced now during manifest installation.

@knative-prow knative-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 6, 2025
Copy link

knative-prow bot commented Mar 6, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: skonto

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot requested review from aliok and houshengbo March 6, 2025 12:14
Copy link

@knative-prow knative-prow bot left a comment

Choose a reason for hiding this comment

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

@skonto: 4 warnings.

In response to this:

Fixes #2009

Proposed Changes

  • Re-enqueue until deployments are available. This make sure resources can be reconciled properly.

Release Note

Proper order is enforced now during manifest installation.

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-sigs/prow repository.

return nil
}

func InstallWebhookConfigs(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
Copy link

Choose a reason for hiding this comment

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

Golint comments: exported function InstallWebhookConfigs should have comment or be unexported. More info.

return nil
}

func InstallWebhookDepResources(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
Copy link

Choose a reason for hiding this comment

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

Golint comments: exported function InstallWebhookDepResources should have comment or be unexported. More info.

return nil
}

func MarkStatusSuccess(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
Copy link

Choose a reason for hiding this comment

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

Golint comments: exported function MarkStatusSuccess should have comment or be unexported. More info.

return nil
}

func SetManifestPaths(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
Copy link

Choose a reason for hiding this comment

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

Golint comments: exported function SetManifestPaths should have comment or be unexported. More info.

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 6, 2025
Copy link

codecov bot commented Mar 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.79%. Comparing base (e9077ba) to head (a6a9921).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2010      +/-   ##
==========================================
+ Coverage   62.76%   62.79%   +0.03%     
==========================================
  Files          49       49              
  Lines        2291     2293       +2     
==========================================
+ Hits         1438     1440       +2     
  Misses        761      761              
  Partials       92       92              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@skonto
Copy link
Contributor Author

skonto commented Mar 6, 2025

Istio cni is not coming up for e2e tests

✘ CNI encountered an error: failed to wait for resource: resources not ready after 5m0s: context deadline exceeded
  Error: failed to install manifests: failed to wait for resource: resources not ready after 5m0s: context deadline exceeded

@skonto
Copy link
Contributor Author

skonto commented Mar 6, 2025

        waiting:
          message: back-off 2m40s restarting failed container=install-cni pod=istio-cni-node-wndwj_kube-system(692908a1-4a41-4cc7-b918-72f8a177f824)
          reason: CrashLoopBackOff

@skonto
Copy link
Contributor Author

skonto commented Mar 6, 2025

image

@skonto
Copy link
Contributor Author

skonto commented Mar 6, 2025

istio/istio#53849

@skonto
Copy link
Contributor Author

skonto commented Mar 6, 2025

verify should be fixed with #2011

@skonto
Copy link
Contributor Author

skonto commented Mar 10, 2025

@houshengbo gentle ping.

@@ -52,7 +55,7 @@ func CheckDeployments(ctx context.Context, manifest *mf.Manifest, instance base.

if len(nonReadyDeployments) > 0 {
status.MarkDeploymentsNotReady(nonReadyDeployments)
return nil
return controller.NewRequeueAfter(1 * time.Second)
Copy link
Member

@pierDipi pierDipi Mar 10, 2025

Choose a reason for hiding this comment

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

Do we need to requeue blindly as this could create a hard loop when there is not actual progress?

The controllers are setting up informers for deployments, so the resource will get requeued anyway when they change (including when they become ready)

deploymentInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
FilterFunc: controller.FilterControllerGVK(v1beta1.SchemeGroupVersion.WithKind("KnativeEventing")),
Handler: controller.HandleAll(impl.EnqueueControllerOf),
})

deploymentInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
FilterFunc: controller.FilterControllerGVK(v1beta1.SchemeGroupVersion.WithKind("KnativeServing")),
Handler: controller.HandleAll(impl.EnqueueControllerOf),
})

Copy link
Member

Choose a reason for hiding this comment

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

and if that's not happening, then the informer handling is where we need to tweak to fix the issue

Copy link
Contributor Author

@skonto skonto Mar 10, 2025

Choose a reason for hiding this comment

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

I am aware of that, I wanted to make sure it happens faster in case something is slow.
The idea is that you cannot progress with an install if your deployments are not up and I wanted to enforce that. So it is not exactly blindly done.

Copy link
Contributor Author

@skonto skonto Mar 10, 2025

Choose a reason for hiding this comment

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

The other thing is that if I dont re-enqueue there and block the logic we still face the problem (an error is printed) as the dependent resources will be deployed e.g. Certificate. We need to interrupt the deployment (returning an error) or block until deployments are up. I have tested both options, here I have the former.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are the stages:

	stages := common.Stages{
		common.AppendTarget,
		ingress.AppendTargetIngress,
		security.AppendTargetSecurity,
		common.AppendAdditionalManifests,
		r.appendExtensionManifests,
		r.transform,
		manifests.Install,
		common.CheckDeployments,  // <- Make sure we are up here otherwise don't progress bellow
		common.InstallWebhookConfigs,
		common.InstallWebhookDependentResources,
		manifests.SetManifestPaths,
		common.MarkStatusSuccess,
		common.DeleteObsoleteResources(ctx, ks, r.installed),
	}

@skonto
Copy link
Contributor Author

skonto commented Mar 10, 2025

@pierDipi I removed the re-enqueue thing and now I just skip the next stages until we are up. If no deployment change happens no reconciliation will happen.

@skonto
Copy link
Contributor Author

skonto commented Mar 11, 2025

@houshengbo gentle ping

@houshengbo
Copy link
Contributor

@skonto I just fixed the CI issue, could you rebase this PR?

@skonto
Copy link
Contributor Author

skonto commented Mar 11, 2025

Sure.

role mf.Predicate = mf.Any(mf.ByKind("ClusterRole"), mf.ByKind("Role"))
rolebinding mf.Predicate = mf.Any(mf.ByKind("ClusterRoleBinding"), mf.ByKind("RoleBinding"))
webhook mf.Predicate = mf.Any(mf.ByKind("MutatingWebhookConfiguration"), mf.ByKind("ValidatingWebhookConfiguration"))
webhookDependentResources mf.Predicate = mf.ByGVK(schema.GroupVersionKind{Group: "networking.internal.knative.dev", Version: "v1alpha1", Kind: "Certificate"})
Copy link
Contributor

@houshengbo houshengbo Mar 12, 2025

Choose a reason for hiding this comment

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

Do we need to specify Version: "v1alpha1" here, as it may change in future? If version is empty, it will just return a GroupKind. It should be fine, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Webhook dependant resources are deployed before the related deployments are available
3 participants