diff --git a/cmd/helm/install.go b/cmd/helm/install.go index d987d300f..38c87dba6 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -177,7 +177,7 @@ func addInstallFlags(cmd *cobra.Command, f *pflag.FlagSet, client *action.Instal f.BoolVar(&client.Force, "force", false, "force resource updates through a replacement strategy") f.BoolVar(&client.DisableHooks, "no-hooks", false, "prevent hooks from running during install") f.BoolVar(&client.Replace, "replace", false, "re-use the given name, only if that name is a deleted release which remains in the history. This is unsafe in production") - f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)") + f.DurationVar(&client.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs and CRDs for hooks)") f.BoolVar(&client.Wait, "wait", false, "if set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout") f.BoolVar(&client.WaitForJobs, "wait-for-jobs", false, "if set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout") f.BoolVarP(&client.GenerateName, "generate-name", "g", false, "generate the name (and omit the NAME parameter)") diff --git a/pkg/action/install.go b/pkg/action/install.go index e3538a4f5..f0dac0be6 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -63,6 +63,9 @@ const notesFileSuffix = "NOTES.txt" const defaultDirectoryPermission = 0755 +// Default timeout for CRD +const defaultTimeout = 60 * time.Second + // Install performs an installation operation. type Install struct { cfg *Configuration @@ -173,8 +176,15 @@ func (i *Install) installCRDs(crds []chart.CRD) error { totalItems = append(totalItems, res...) } if len(totalItems) > 0 { + // If the timeout provided is greater than the default timeout + // use the provided timeout as the maximum timeout. + crdMaxTimeout := defaultTimeout + if i.Timeout > defaultTimeout { + crdMaxTimeout = i.Timeout + } + // Give time for the CRD to be recognized. - if err := i.cfg.KubeClient.Wait(totalItems, 60*time.Second); err != nil { + if err := i.cfg.KubeClient.Wait(totalItems, crdMaxTimeout); err != nil { return err }