Skip to content
Merged
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ require (
github.com/fluxcd/pkg/cache v0.12.0
github.com/fluxcd/pkg/http/fetch v0.21.0
github.com/fluxcd/pkg/kustomize v1.24.0
github.com/fluxcd/pkg/runtime v0.93.0
github.com/fluxcd/pkg/runtime v0.94.0
github.com/fluxcd/pkg/ssa v0.61.0
github.com/fluxcd/pkg/tar v0.16.0
github.com/fluxcd/pkg/testserver v0.13.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ github.com/fluxcd/pkg/http/fetch v0.21.0 h1:/vHWc+3BIk9q5HFA8khl0NEBb/XFXzZOqpnU
github.com/fluxcd/pkg/http/fetch v0.21.0/go.mod h1:aFUPa2DLpUHE/dXkhIdaHakVIiZ6GVCWvp5tWkDKSEM=
github.com/fluxcd/pkg/kustomize v1.24.0 h1:ckFB7hh9FpJA1Oy3bYl88p9On/zsZZTbwlLBgP6eUkA=
github.com/fluxcd/pkg/kustomize v1.24.0/go.mod h1:cydG0vKpDuUaoP5STpKfxY3zqgzaARv5HsWDOFyt5nA=
github.com/fluxcd/pkg/runtime v0.93.0 h1:fgd1O1xC7RRK5XJjBCocgg6MkDHS56Q73F0h5qCIvVk=
github.com/fluxcd/pkg/runtime v0.93.0/go.mod h1:/E4dT1pdSkidyRTR5ghSzoyHEUcEJw3ipvJt597ArOA=
github.com/fluxcd/pkg/runtime v0.94.0 h1:z33lG+albHTmmcpZgV7DY5VVUZXFFAErnBBATDI2B5I=
github.com/fluxcd/pkg/runtime v0.94.0/go.mod h1:/E4dT1pdSkidyRTR5ghSzoyHEUcEJw3ipvJt597ArOA=
github.com/fluxcd/pkg/sourceignore v0.15.0 h1:tB30fuk4jlB3UGlR7ppJguZ3zaJh1iwuTCEufs91jSM=
github.com/fluxcd/pkg/sourceignore v0.15.0/go.mod h1:mZ9X6gNtNkq9ZsD35LebEYjePc7DRvB2JdowMNoj6IU=
github.com/fluxcd/pkg/ssa v0.61.0 h1:GeueQfZVrjPLEzmEkq6gpFTBr1MDcqUihCQDf6AaIo8=
Expand Down
21 changes: 11 additions & 10 deletions internal/controller/kustomization_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
}

// Configure custom health checks.
statusReaders, err := cel.PollerWithCustomHealthChecks(ctx, obj.Spec.HealthCheckExprs)
statusReader, err := cel.NewStatusReader(obj.Spec.HealthCheckExprs)
if err != nil {
errMsg := fmt.Sprintf("%s: %v", TerminalErrorMessage, err)
conditions.MarkFalse(obj, meta.ReadyCondition, meta.InvalidCELExpressionReason, "%s", errMsg)
Expand Down Expand Up @@ -260,7 +260,7 @@ func (r *KustomizationReconciler) Reconcile(ctx context.Context, req ctrl.Reques
}

// Reconcile the latest revision.
reconcileErr := r.reconcile(ctx, obj, artifactSource, patcher, statusReaders)
reconcileErr := r.reconcile(ctx, obj, artifactSource, patcher, statusReader)

// Requeue at the specified retry interval if the artifact tarball is not found.
if errors.Is(reconcileErr, fetch.ErrFileNotFound) {
Expand Down Expand Up @@ -304,7 +304,7 @@ func (r *KustomizationReconciler) reconcile(
obj *kustomizev1.Kustomization,
src sourcev1.Source,
patcher *patch.SerialPatcher,
statusReaders []func(apimeta.RESTMapper) engine.StatusReader) error {
statusReader func(apimeta.RESTMapper) engine.StatusReader) error {
reconcileStart := time.Now()
log := ctrl.LoggerFrom(ctx)

Expand Down Expand Up @@ -392,9 +392,9 @@ func (r *KustomizationReconciler) reconcile(
impersonatorOpts = append(impersonatorOpts,
runtimeClient.WithKubeConfig(obj.Spec.KubeConfig, r.KubeConfigOpts, obj.GetNamespace(), provider))
}
if r.ClusterReader != nil || len(statusReaders) > 0 {
if r.ClusterReader != nil || len(obj.Spec.HealthCheckExprs) > 0 {
impersonatorOpts = append(impersonatorOpts,
runtimeClient.WithPolling(r.ClusterReader, statusReaders...))
runtimeClient.WithPolling(r.ClusterReader, statusReader))
}
impersonation := runtimeClient.NewImpersonator(r.Client, impersonatorOpts...)

Expand All @@ -404,7 +404,7 @@ func (r *KustomizationReconciler) reconcile(
if mustImpersonate {
kubeClient, statusPoller, err = impersonation.GetClient(ctx)
} else {
kubeClient, statusPoller = r.getClientAndPoller(statusReaders)
kubeClient, statusPoller = r.getClientAndPoller(obj, statusReader)
}
if err != nil {
conditions.MarkFalse(obj, meta.ReadyCondition, meta.ReconciliationFailedReason, "%s", err)
Expand Down Expand Up @@ -1286,13 +1286,14 @@ func (r *KustomizationReconciler) patch(ctx context.Context,
// Should be used for reconciliations that are not configured to use
// ServiceAccount impersonation or kubeconfig.
func (r *KustomizationReconciler) getClientAndPoller(
readerCtors []func(apimeta.RESTMapper) engine.StatusReader,
obj *kustomizev1.Kustomization,
readerCtor func(apimeta.RESTMapper) engine.StatusReader,
) (client.Client, *polling.StatusPoller) {

readers := make([]engine.StatusReader, 0, 1+len(readerCtors))
readers := make([]engine.StatusReader, 0, 1+len(obj.Spec.HealthCheckExprs))
readers = append(readers, statusreaders.NewCustomJobStatusReader(r.Mapper))
for _, ctor := range readerCtors {
readers = append(readers, ctor(r.Mapper))
if len(obj.Spec.HealthCheckExprs) > 0 {
readers = append(readers, readerCtor(r.Mapper))
}

poller := polling.NewStatusPoller(r.Client, r.Mapper, polling.Options{
Expand Down