mirror of https://github.com/helm/helm.git
get rid of ext interface
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
This commit is contained in:
parent
e6c6a40fe0
commit
8ce1876192
|
|
@ -22,7 +22,6 @@ import (
|
|||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"helm.sh/helm/v4/pkg/kube"
|
||||
"helm.sh/helm/v4/pkg/release"
|
||||
helmtime "helm.sh/helm/v4/pkg/time"
|
||||
)
|
||||
|
|
@ -138,11 +137,8 @@ func (cfg *Configuration) deleteHookByPolicy(h *release.Hook, policy release.Hoo
|
|||
return errors.New(joinErrors(errs))
|
||||
}
|
||||
|
||||
//wait for resources until they are deleted to avoid conflicts
|
||||
if kubeClient, ok := cfg.KubeClient.(kube.InterfaceExt); ok {
|
||||
if err := kubeClient.WaitForDelete(resources, timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := cfg.KubeClient.WaitForDelete(resources, timeout); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -131,10 +131,8 @@ func (u *Uninstall) Run(name string) (*release.UninstallReleaseResponse, error)
|
|||
res.Info = kept
|
||||
|
||||
if u.Wait {
|
||||
if kubeClient, ok := u.cfg.KubeClient.(kube.InterfaceExt); ok {
|
||||
if err := kubeClient.WaitForDelete(deletedResources, u.Timeout); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if err := u.cfg.KubeClient.WaitForDelete(deletedResources, u.Timeout); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -331,15 +331,6 @@ func getResource(info *resource.Info) (runtime.Object, error) {
|
|||
return obj, nil
|
||||
}
|
||||
|
||||
// WaitForDelete wait up to the given timeout for the specified resources to be deleted.
|
||||
func (c *Client) WaitForDelete(resources ResourceList, timeout time.Duration) error {
|
||||
w := HelmWaiter{
|
||||
log: c.Log,
|
||||
timeout: timeout,
|
||||
}
|
||||
return w.waitForDeletedResources(resources)
|
||||
}
|
||||
|
||||
func (c *Client) namespace() string {
|
||||
if c.Namespace != "" {
|
||||
return c.Namespace
|
||||
|
|
|
|||
|
|
@ -67,12 +67,7 @@ type Waiter interface {
|
|||
|
||||
// WaitWithJobs wait up to the given timeout for the specified resources to be ready, including jobs.
|
||||
WaitWithJobs(resources ResourceList, timeout time.Duration) error
|
||||
}
|
||||
|
||||
// InterfaceExt is introduced to avoid breaking backwards compatibility for Interface implementers.
|
||||
//
|
||||
// TODO Helm 4: Remove InterfaceExt and integrate its method(s) into the Interface.
|
||||
type InterfaceExt interface {
|
||||
// WaitForDelete wait up to the given timeout for the specified resources to be deleted.
|
||||
WaitForDelete(resources ResourceList, timeout time.Duration) error
|
||||
}
|
||||
|
|
@ -108,6 +103,5 @@ type InterfaceResources interface {
|
|||
}
|
||||
|
||||
var _ Interface = (*Client)(nil)
|
||||
var _ InterfaceExt = (*Client)(nil)
|
||||
var _ InterfaceDeletionPropagation = (*Client)(nil)
|
||||
var _ InterfaceResources = (*Client)(nil)
|
||||
|
|
|
|||
|
|
@ -50,6 +50,12 @@ func (w *statusWaiter) WaitWithJobs(resourceList ResourceList, timeout time.Dura
|
|||
return w.wait(ctx, resourceList, true)
|
||||
}
|
||||
|
||||
func (w *statusWaiter) WaitForDelete(resourceList ResourceList, timeout time.Duration) error {
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), timeout)
|
||||
defer cancel()
|
||||
return w.waitForDelete(ctx, resourceList)
|
||||
}
|
||||
|
||||
func (w *statusWaiter) waitForDelete(ctx context.Context, resourceList ResourceList) error {
|
||||
deadline, _ := ctx.Deadline()
|
||||
w.log("beginning wait for %d resources to be deleted with timeout of %v", len(resourceList), time.Until(deadline))
|
||||
|
|
|
|||
|
|
@ -153,8 +153,6 @@ func TestStatusWaitForDelete(t *testing.T) {
|
|||
sw: statusWatcher,
|
||||
log: t.Logf,
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
createdObjs := []runtime.Object{}
|
||||
for _, objYaml := range tt.objToCreate {
|
||||
m := make(map[string]interface{})
|
||||
|
|
@ -184,7 +182,7 @@ func TestStatusWaitForDelete(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
resourceList = append(resourceList, list...)
|
||||
}
|
||||
err := statusWaiter.waitForDelete(ctx, resourceList)
|
||||
err := statusWaiter.WaitForDelete(resourceList, timeout)
|
||||
if tt.expectErrs != nil {
|
||||
assert.EqualError(t, err, errors.Join(tt.expectErrs...).Error())
|
||||
return
|
||||
|
|
|
|||
|
|
@ -43,29 +43,26 @@ import (
|
|||
// Helm 4 now uses the StatusWaiter interface instead
|
||||
type HelmWaiter struct {
|
||||
c ReadyChecker
|
||||
timeout time.Duration
|
||||
log func(string, ...interface{})
|
||||
kubeClient *kubernetes.Clientset
|
||||
}
|
||||
|
||||
func (w *HelmWaiter) Wait(resources ResourceList, timeout time.Duration) error {
|
||||
w.c = NewReadyChecker(w.kubeClient, w.log, PausedAsReady(true))
|
||||
w.timeout = timeout
|
||||
return w.waitForResources(resources)
|
||||
return w.waitForResources(resources, timeout)
|
||||
}
|
||||
|
||||
func (w *HelmWaiter) WaitWithJobs(resources ResourceList, timeout time.Duration) error {
|
||||
w.c = NewReadyChecker(w.kubeClient, w.log, PausedAsReady(true), CheckJobs(true))
|
||||
w.timeout = timeout
|
||||
return w.waitForResources(resources)
|
||||
return w.waitForResources(resources, timeout)
|
||||
}
|
||||
|
||||
// waitForResources polls to get the current status of all pods, PVCs, Services and
|
||||
// Jobs(optional) until all are ready or a timeout is reached
|
||||
func (w *HelmWaiter) waitForResources(created ResourceList) error {
|
||||
w.log("beginning wait for %d resources with timeout of %v", len(created), w.timeout)
|
||||
func (w *HelmWaiter) waitForResources(created ResourceList, timeout time.Duration) error {
|
||||
w.log("beginning wait for %d resources with timeout of %v", len(created), timeout)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), w.timeout)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
numberOfErrors := make([]int, len(created))
|
||||
|
|
@ -116,10 +113,10 @@ func (w *HelmWaiter) isRetryableHTTPStatusCode(httpStatusCode int32) bool {
|
|||
}
|
||||
|
||||
// waitForDeletedResources polls to check if all the resources are deleted or a timeout is reached
|
||||
func (w *HelmWaiter) waitForDeletedResources(deleted ResourceList) error {
|
||||
w.log("beginning wait for %d resources to be deleted with timeout of %v", len(deleted), w.timeout)
|
||||
func (w *HelmWaiter) WaitForDelete(deleted ResourceList, timeout time.Duration) error {
|
||||
w.log("beginning wait for %d resources to be deleted with timeout of %v", len(deleted), timeout)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), w.timeout)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
return wait.PollUntilContextCancel(ctx, 2*time.Second, true, func(_ context.Context) (bool, error) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue