// Destroy a build cache.
163591
func (s *Service) BuildDeleteCache(ctx context.Context, appIdentity string) (*Build, error) {
	var build Build
	return &build, s.Delete(ctx, &build, fmt.Sprintf("/apps/%v/build-cache", appIdentity))
}
121383
func (b *Backend) PruneCache(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) {
	eg, ctx := errgroup.WithContext(ctx)

	var fsCacheSize uint64
	eg.Go(func() error {
		var err error
		fsCacheSize, err = b.fsCache.Prune(ctx)
		if err != nil {
			return errors.Wrap(err, "failed to prune fscache")
		}
		return nil
	})

	var buildCacheSize int64
	var cacheIDs []string
	eg.Go(func() error {
		var err error
		buildCacheSize, cacheIDs, err = b.buildkit.Prune(ctx, opts)
		if err != nil {
			return errors.Wrap(err, "failed to prune build cache")
		}
		return nil
	})

	if err := eg.Wait(); err != nil {
		return nil, err
	}

	return &types.BuildCachePruneReport{SpaceReclaimed: fsCacheSize + uint64(buildCacheSize), CachesDeleted: cacheIDs}, nil
}
53791
func (bc *BuildController) cancelBuild(build *buildv1.Build) (*buildUpdate, error) {
	klog.V(4).Infof("Cancelling build %s", buildDesc(build))

	podName := buildapihelpers.GetBuildPodName(build)
	err := bc.podClient.Pods(build.Namespace).Delete(podName, &metav1.DeleteOptions{})
	if err != nil && !errors.IsNotFound(err) {
		return nil, fmt.Errorf("could not delete build pod %s/%s to cancel build %s: %v", build.Namespace, podName, buildDesc(build), err)
	}

	return transitionToPhase(buildv1.BuildPhaseCancelled, buildv1.StatusReasonCancelledBuild, buildutil.StatusMessageCancelledBuild), nil
}
809907
func (opts *FlushOptions) Destroy() {
	C.rocksdb_flushoptions_destroy(opts.c)
	opts.c = nil
}
782222
func (c Caches) Prune() (int, error) {
	counter := 0
	for k, cache := range c {
		err := afero.Walk(cache.Fs, "", func(name string, info os.FileInfo, err error) error {
			if info == nil {
				return nil
			}

			name = cleanID(name)

			if info.IsDir() {
				f, err := cache.Fs.Open(name)
				if err != nil {
					// This cache dir may not exist.
					return nil
				}
				defer f.Close()
				_, err = f.Readdirnames(1)
				if err == io.EOF {
					// Empty dir.
					return cache.Fs.Remove(name)
				}

				return nil
			}

			shouldRemove := cache.isExpired(info.ModTime())

			if !shouldRemove && len(cache.nlocker.seen) > 0 {
				// Remove it if it's not been touched/used in the last build.
				_, seen := cache.nlocker.seen[name]
				shouldRemove = !seen
			}

			if shouldRemove {
				err := cache.Fs.Remove(name)
				if err == nil {
					counter++
				}
				return err
			}

			return nil
		})

		if err != nil {
			return counter, errors.Wrapf(err, "failed to prune cache %q", k)
		}

	}

	return counter, nil
}
749869
func (env *Env) Destroy() {
	C.rocksdb_env_destroy(env.c)
	env.c = nil
}
80602
func (q *BuildQueue) Remove(b Buildable) {
	uuid := b.GetUUID()
	q.mutex.Lock()
	if status, ok := q.buildStatus[uuid]; ok {
		// Only remove the builder UUID from the buildStatus if no
		// build is currently running. If a build is running, the
		// buildStatus continue to be in place until the build has
		// completed.
		if status.currentBuild == nil {
			delete(q.buildStatus, uuid)
		}

		if status.nextBuild != nil {
			num := status.nextBuild.cancelScheduled(q)
			defer status.builder.BuildsDequeued(num, true)
		}
	}
	q.mutex.Unlock()
}
1047600
func Destroy(w http.ResponseWriter, r *http.Request) {
	Default.Destroy(w, r)
}
316051
func (site *Site) Destroy() (*Response, error) {
	resp, err := site.client.Request("DELETE", site.apiPath(), nil, nil)
	if resp != nil && resp.Body != nil {
		resp.Body.Close()
	}
	return resp, err
}
50088
func (c ClientBuildClient) DeleteBuild(build *buildv1.Build) error {
	return c.Client.BuildV1().Builds(build.Namespace).Delete(build.Name, &metav1.DeleteOptions{})
}
284657
func (s *StreamFramer) Destroy() {
	s.l.Lock()

	wasShutdown := s.shutdown
	s.shutdown = true

	if !wasShutdown {
		close(s.shutdownCh)
	}

	s.heartbeat.Stop()
	s.flusher.Stop()
	running := s.running
	s.l.Unlock()

	// Ensure things were flushed
	if running {
		<-s.exitCh
	}

	// Close out chan only after exitCh has exited
	if !wasShutdown {
		close(s.out)
	}
}
539429
func (a *Artifact) Destroy() error {
	// Create a new parameter struct.
	p := a.client.Template.NewDeleteTemplateParams(a.template.Id)

	// Destroy the template.
	log.Printf("Destroying template: %s", a.template.Name)
	_, err := a.client.Template.DeleteTemplate(p)
	if err != nil {
		// This is a very poor way to be told the ID does no longer exist :(
		if strings.Contains(err.Error(), fmt.Sprintf(
			"Invalid parameter id value=%s due to incorrect long value format, "+
				"or entity does not exist", a.template.Id)) {
			return nil
		}

		return fmt.Errorf("Error destroying template %s: %s", a.template.Name, err)
	}

	return nil
}
235589
func (ctx *CUContext) Destroy() error {
	err := result(C.cuCtxDestroy(ctx.ctx))
	*ctx = CUContext{}
	return err
}
933259
func (a *Artifact) Destroy() error {
	log.Printf("Destroying image: %s", a.image.Name)
	errCh := a.driver.DeleteImage(a.image.Name)
	return <-errCh
}
1218315
func (m *cgroupManagerImpl) Destroy(cgroupConfig *CgroupConfig) error {
	start := time.Now()
	defer func() {
		metrics.CgroupManagerDuration.WithLabelValues("destroy").Observe(metrics.SinceInSeconds(start))
		metrics.DeprecatedCgroupManagerLatency.WithLabelValues("destroy").Observe(metrics.SinceInMicroseconds(start))
	}()

	cgroupPaths := m.buildCgroupPaths(cgroupConfig.Name)

	libcontainerCgroupConfig := &libcontainerconfigs.Cgroup{}
	// libcontainer consumes a different field and expects a different syntax
	// depending on the cgroup driver in use, so we need this conditional here.
	if m.adapter.cgroupManagerType == libcontainerSystemd {
		updateSystemdCgroupInfo(libcontainerCgroupConfig, cgroupConfig.Name)
	} else {
		libcontainerCgroupConfig.Path = cgroupConfig.Name.ToCgroupfs()
	}

	manager, err := m.adapter.newManager(libcontainerCgroupConfig, cgroupPaths)
	if err != nil {
		return err
	}

	// Delete cgroups using libcontainers Managers Destroy() method
	if err = manager.Destroy(); err != nil {
		return fmt.Errorf("Unable to destroy cgroup paths for cgroup %v : %v", cgroupConfig.Name, err)
	}

	return nil
}
680118
func (s *Session) Destroy(w http.ResponseWriter) {
	s.store.Destroy(w, s.name)
}
450193
func (vm *VM) Destroy() error {
	if vm.MockDestroy != nil {
		return vm.MockDestroy()
	}
	return lvm.ErrNotImplemented
}