diff --git a/pkg/action/sequencing.go b/pkg/action/sequencing.go index 102e30649..d290d0fd2 100644 --- a/pkg/action/sequencing.go +++ b/pkg/action/sequencing.go @@ -223,6 +223,11 @@ func warnIfIsolatedGroups(logger *slog.Logger, result releaseutil.ResourceGroupR } } +// batchHasCustomReadiness reports whether at least one resource in the batch has +// BOTH the success and failure readiness annotations set. Resources with only +// one annotation are treated as misconfigured (warnIfPartialReadinessAnnotations +// emits a warning) and fall back to kstatus, so they should not trigger the +// custom-readiness status reader for the whole batch. func batchHasCustomReadiness(manifests []releaseutil.Manifest) bool { for _, manifest := range manifests { if manifest.Head == nil || manifest.Head.Metadata == nil { @@ -232,7 +237,7 @@ func batchHasCustomReadiness(manifests []releaseutil.Manifest) bool { if annotations == nil { continue } - if annotations[kube.AnnotationReadinessSuccess] != "" || annotations[kube.AnnotationReadinessFailure] != "" { + if annotations[kube.AnnotationReadinessSuccess] != "" && annotations[kube.AnnotationReadinessFailure] != "" { return true } } diff --git a/pkg/cmd/template.go b/pkg/cmd/template.go index ca9dd69fa..5e7086b4e 100644 --- a/pkg/cmd/template.go +++ b/pkg/cmd/template.go @@ -124,19 +124,26 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { // We ignore a potential error here because, when the --debug flag was specified, // we always want to print the YAML, even if it is not valid. The error is still returned afterwards. if rel != nil { + orderedRendered := false if orderedTemplateOutput { - if err := renderOrderedTemplate(rel.Chart, strings.TrimSpace(rel.Manifest), out); err != nil { - return err - } - if !client.DisableHooks { - for _, m := range rel.Hooks { - if skipTests && isTestHook(m) { - continue + if renderErr := renderOrderedTemplate(rel.Chart, strings.TrimSpace(rel.Manifest), out); renderErr != nil { + // Honor the --debug contract: always print the manifests, even if + // ordered rendering fails (e.g., a document fails YAML structural + // parsing). Fall back to the flat path with a stderr warning. + fmt.Fprintf(os.Stderr, "WARNING: ordered template rendering failed (%v); falling back to flat output\n", renderErr) + } else { + orderedRendered = true + if !client.DisableHooks { + for _, m := range rel.Hooks { + if skipTests && isTestHook(m) { + continue + } + fmt.Fprintf(out, "---\n# Source: %s\n%s\n", m.Path, m.Manifest) } - fmt.Fprintf(out, "---\n# Source: %s\n%s\n", m.Path, m.Manifest) } } - } else { + } + if !orderedRendered { var manifests bytes.Buffer fmt.Fprintln(&manifests, strings.TrimSpace(rel.Manifest)) if !client.DisableHooks {