Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ require (
knative.dev/eventing-kafka-broker v0.37.0
knative.dev/hack v0.0.0-20250220110655-b5e4ff820460
knative.dev/networking v0.0.0-20241022012959-60e29ff520dc
knative.dev/operator v0.43.3-0.20250312021337-6b0f076ba7ae
knative.dev/pkg v0.0.0-20241021183759-9b9d535af5ad
knative.dev/serving v0.43.2
knative.dev/operator v0.43.4-0.20250319095719-ca447a0e689f
knative.dev/pkg v0.0.0-20250306143800-fff4f701c7af
knative.dev/serving v0.43.3
sigs.k8s.io/controller-runtime v0.19.0
sigs.k8s.io/yaml v1.4.0
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2593,8 +2593,8 @@ knative.dev/hack v0.0.0-20250117112405-6cb0feb3ac46 h1:UWX4qXgehoigmCH/db5ZldJ9V
knative.dev/hack v0.0.0-20250117112405-6cb0feb3ac46/go.mod h1:R0ritgYtjLDO9527h5vb5X6gfvt5LCrJ55BNbVDsWiY=
knative.dev/networking v0.0.0-20241022012959-60e29ff520dc h1:0d9XXRLlyuHfINZLlYqo/BYe/+chqqNBMLKJldjTbtw=
knative.dev/networking v0.0.0-20241022012959-60e29ff520dc/go.mod h1:G56j6VCLzfaN9yZ4IqfNyN4c3U1czvhUmKeZX4UjQ8Q=
knative.dev/operator v0.43.3-0.20250312021337-6b0f076ba7ae h1:GtHRzhWCPbBq51FLPpKcTnmK7dxR1ZmHN9jIcXFtEao=
knative.dev/operator v0.43.3-0.20250312021337-6b0f076ba7ae/go.mod h1:0WF/rDMqu7koe4ODC2vyjLd80Kw5NqIYoLwi+S+YERk=
knative.dev/operator v0.43.4-0.20250319095719-ca447a0e689f h1:Z3NUuUs/8IHsztmdjxLUvJGmcFE3Tu3CVkj/CbmgWVE=
knative.dev/operator v0.43.4-0.20250319095719-ca447a0e689f/go.mod h1:GeV1TTAOMD2RAt9EV6IjHEcUJYD8ejPp33QShe+BFsQ=
knative.dev/pkg v0.0.0-20241021183759-9b9d535af5ad h1:Nrjtr2H168rJeamH4QdyLMV1lEKHejNhaj1ymgQMfLk=
knative.dev/pkg v0.0.0-20241021183759-9b9d535af5ad/go.mod h1:StJI72GWcm/iErmk4RqFJiOo8RLbVqPbHxUqeVwAzeo=
knative.dev/reconciler-test v0.0.0-20241015093232-09111f0f1364 h1:DIc+vbaFKOSGktPXJ1MaXIXoDjlmUIXQkHiZaPcYGbQ=
Expand Down
2 changes: 1 addition & 1 deletion hack/patches/020-backstage_plugins_eventmesh_backend.patch
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ index f0d4c777d..f622a4bce 100644
+ r.handleBackstageResources,
manifests.Install,
common.CheckDeployments,
common.DeleteObsoleteResources(ctx, ke, r.installed),
common.InstallWebhookConfigs,
22 changes: 19 additions & 3 deletions vendor/knative.dev/operator/pkg/reconciler/common/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,31 @@ package common

import (
"context"
"errors"

mf "github.com/manifestival/manifestival"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/client-go/kubernetes/scheme"

"knative.dev/operator/pkg/apis/operator/base"
)

type deploymentsNotReadyError struct{}

var _ error = deploymentsNotReadyError{}

// Error implements the Error() interface of error.
func (err deploymentsNotReadyError) Error() string {
return "deployments not ready"
}

// IsDeploymentsNotReadyError returns true if the given error is a deploymentsNotReadyError.
func IsDeploymentsNotReadyError(err error) bool {
return errors.Is(err, deploymentsNotReadyError{})
}

// CheckDeployments checks all deployments in the given manifest and updates the given
// status with the status of the deployments.
func CheckDeployments(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
Expand All @@ -36,7 +52,7 @@ func CheckDeployments(ctx context.Context, manifest *mf.Manifest, instance base.
resource, err := manifest.Client.Get(&u)
if err != nil {
status.MarkDeploymentsNotReady([]string{"all"})
if errors.IsNotFound(err) {
if apierrors.IsNotFound(err) {
return nil
}
return err
Expand All @@ -52,7 +68,7 @@ func CheckDeployments(ctx context.Context, manifest *mf.Manifest, instance base.

if len(nonReadyDeployments) > 0 {
status.MarkDeploymentsNotReady(nonReadyDeployments)
return nil
return deploymentsNotReadyError{}
}

status.MarkDeploymentsAvailable()
Expand Down
43 changes: 37 additions & 6 deletions vendor/knative.dev/operator/pkg/reconciler/common/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@ import (
"strings"

mf "github.com/manifestival/manifestival"
"knative.dev/pkg/logging"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"

"knative.dev/operator/pkg/apis/operator/base"
"knative.dev/operator/pkg/apis/operator/v1beta1"
"knative.dev/pkg/logging"
)

var (
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"))
gatewayNotMatch = "no matches for kind \"Gateway\""
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 = byGV(schema.GroupKind{Group: "networking.internal.knative.dev", Kind: "Certificate"})
gatewayNotMatch = "no matches for kind \"Gateway\""
)

// Install applies the manifest resources for the given version and updates the given
Expand All @@ -52,7 +55,7 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen
status.MarkInstallFailed(err.Error())
return fmt.Errorf("failed to apply (cluster)rolebindings: %w", err)
}
if err := manifest.Filter(mf.Not(mf.Any(role, rolebinding, webhook))).Apply(); err != nil {
if err := manifest.Filter(mf.Not(mf.Any(role, rolebinding, webhook, webhookDependentResources))).Apply(); err != nil {
status.MarkInstallFailed(err.Error())
if ks, ok := instance.(*v1beta1.KnativeServing); ok && strings.Contains(err.Error(), gatewayNotMatch) &&
(ks.Spec.Ingress == nil || ks.Spec.Ingress.Istio.Enabled) {
Expand All @@ -63,10 +66,32 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen

return fmt.Errorf("failed to apply non rbac manifest: %w", err)
}
return nil
}

// InstallWebhookConfigs applies the Webhook manifest resources and updates the given status accordingly.
func InstallWebhookConfigs(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
status := instance.GetStatus()
if err := manifest.Filter(webhook).Apply(); err != nil {
status.MarkInstallFailed(err.Error())
return fmt.Errorf("failed to apply webhooks: %w", err)
}
return nil
}

// InstallWebhookDependentResources applies the Webhook dependent resources updates the given status accordingly.
func InstallWebhookDependentResources(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
status := instance.GetStatus()
if err := manifest.Filter(webhookDependentResources).Apply(); err != nil {
status.MarkInstallFailed(err.Error())
return fmt.Errorf("failed to apply webhooks: %w", err)
}
return nil
}

// MarkStatusSuccess updates the component status to success.
func MarkStatusSuccess(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
status := instance.GetStatus()
status.MarkInstallSucceeded()
status.SetVersion(TargetVersion(instance))
return nil
Expand All @@ -83,3 +108,9 @@ func Uninstall(manifest *mf.Manifest) error {
}
return nil
}

func byGV(gk schema.GroupKind) mf.Predicate {
return func(u *unstructured.Unstructured) bool {
return u.GroupVersionKind().GroupKind() == gk
}
}
3 changes: 3 additions & 0 deletions vendor/knative.dev/operator/pkg/reconciler/common/stages.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ type Stages []Stage
func (stages Stages) Execute(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
for _, stage := range stages {
if err := stage(ctx, manifest, instance); err != nil {
if IsDeploymentsNotReadyError(err) {
break
}
return err
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ke *v1beta1.KnativeEvent
r.handleBackstageResources,
manifests.Install,
common.CheckDeployments,
common.InstallWebhookConfigs,
manifests.SetManifestPaths,
common.MarkStatusSuccess,
common.DeleteObsoleteResources(ctx, ke, r.installed),
}
manifest := r.manifest.Append()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, ks *v1beta1.KnativeServi
r.transform,
manifests.Install,
common.CheckDeployments,
common.InstallWebhookConfigs,
common.InstallWebhookDependentResources,
manifests.SetManifestPaths,
common.MarkStatusSuccess,
common.DeleteObsoleteResources(ctx, ks, r.installed),
}
manifest := r.manifest.Append()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ func Install(ctx context.Context, manifest *mf.Manifest, instance base.KComponen
if err != nil {
return err
}
return nil
}

// SetManifestPaths set the manifest paths in the status of the component
func SetManifestPaths(ctx context.Context, manifest *mf.Manifest, instance base.KComponent) error {
status := instance.GetStatus()
path := common.TargetManifestPathArray(instance)
version := common.TargetVersion(instance)
Expand Down
6 changes: 3 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,7 @@ knative.dev/networking/pkg/http/proxy
knative.dev/networking/pkg/http/stats
knative.dev/networking/pkg/ingress
knative.dev/networking/pkg/k8s
# knative.dev/operator v0.43.3-0.20250312021337-6b0f076ba7ae
# knative.dev/operator v0.43.4-0.20250319095719-ca447a0e689f
## explicit; go 1.22.0
knative.dev/operator/pkg/apis/operator
knative.dev/operator/pkg/apis/operator/base
Expand Down Expand Up @@ -1587,7 +1587,7 @@ knative.dev/operator/pkg/reconciler/knativeserving/common
knative.dev/operator/pkg/reconciler/knativeserving/ingress
knative.dev/operator/pkg/reconciler/knativeserving/security
knative.dev/operator/pkg/reconciler/manifests
# knative.dev/pkg v0.0.0-20241021183759-9b9d535af5ad => knative.dev/pkg v0.0.0-20241021183759-9b9d535af5ad
# knative.dev/pkg v0.0.0-20250306143800-fff4f701c7af => knative.dev/pkg v0.0.0-20241021183759-9b9d535af5ad
## explicit; go 1.22.0
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
Expand Down Expand Up @@ -1707,7 +1707,7 @@ knative.dev/reconciler-test/pkg/resources/serviceaccount
knative.dev/reconciler-test/pkg/state
knative.dev/reconciler-test/resources/certificate
knative.dev/reconciler-test/resources/svc
# knative.dev/serving v0.43.2 => github.com/openshift-knative/serving v0.10.1-0.20250207125854-cf4e630711c9
# knative.dev/serving v0.43.3 => github.com/openshift-knative/serving v0.10.1-0.20250207125854-cf4e630711c9
## explicit; go 1.22.0
knative.dev/serving/pkg/apis/autoscaling
knative.dev/serving/pkg/apis/autoscaling/v1alpha1
Expand Down
Loading