Skip to content

Commit

Permalink
Image pruner: Determine protocol just once
Browse files Browse the repository at this point in the history
Determine the registry protocol once. Do not change to other protocol
during the run. This will produce nicer output without unrelated
protocol fallback errors.

Do not default to insecure connection when the --registry-url is empty.

Signed-off-by: Michal Minář <[email protected]>
  • Loading branch information
Michal Minář committed Jul 3, 2017
1 parent fc34104 commit 58876ea
Show file tree
Hide file tree
Showing 3 changed files with 566 additions and 295 deletions.
12 changes: 6 additions & 6 deletions pkg/cmd/admin/prune/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (o *PruneImagesOptions) Complete(f *clientcmd.Factory, cmd *cobra.Command,

o.Insecure = o.ForceInsecure
if !o.Insecure && len(o.CABundle) == 0 {
o.Insecure = clientConfig.TLSClientConfig.Insecure || len(o.RegistryUrlOverride) == 0 || netutils.IsPrivateAddress(o.RegistryUrlOverride)
o.Insecure = clientConfig.TLSClientConfig.Insecure || netutils.IsPrivateAddress(o.RegistryUrlOverride)
}
osClient, kClient, registryClient, err := getClients(f, o.CABundle, o.Insecure)
if err != nil {
Expand Down Expand Up @@ -276,7 +276,7 @@ func (o PruneImagesOptions) Run() error {
LimitRanges: limitRangesMap,
DryRun: o.Confirm == false,
RegistryClient: o.RegistryClient,
RegistryURL: o.RegistryUrlOverride,
RegistryHost: o.RegistryUrlOverride,
Insecure: o.Insecure,
}
if o.Namespace != metav1.NamespaceAll {
Expand Down Expand Up @@ -378,7 +378,7 @@ type describingLayerLinkDeleter struct {

var _ prune.LayerLinkDeleter = &describingLayerLinkDeleter{}

func (p *describingLayerLinkDeleter) DeleteLayerLink(registryClient *http.Client, registryURL, repo, name string) error {
func (p *describingLayerLinkDeleter) DeleteLayerLink(registryClient *http.Client, registryURL *url.URL, repo, name string) error {
if !p.headerPrinted {
p.headerPrinted = true
fmt.Fprintln(p.w, "\nDeleting registry repository layer links ...")
Expand Down Expand Up @@ -409,7 +409,7 @@ type describingBlobDeleter struct {

var _ prune.BlobDeleter = &describingBlobDeleter{}

func (p *describingBlobDeleter) DeleteBlob(registryClient *http.Client, registryURL, layer string) error {
func (p *describingBlobDeleter) DeleteBlob(registryClient *http.Client, registryURL *url.URL, layer string) error {
if !p.headerPrinted {
p.headerPrinted = true
fmt.Fprintln(p.w, "\nDeleting registry layer blobs ...")
Expand Down Expand Up @@ -441,7 +441,7 @@ type describingManifestDeleter struct {

var _ prune.ManifestDeleter = &describingManifestDeleter{}

func (p *describingManifestDeleter) DeleteManifest(registryClient *http.Client, registryURL, repo, manifest string) error {
func (p *describingManifestDeleter) DeleteManifest(registryClient *http.Client, registryURL *url.URL, repo, manifest string) error {
if !p.headerPrinted {
p.headerPrinted = true
fmt.Fprintln(p.w, "\nDeleting registry repository manifest data ...")
Expand All @@ -456,7 +456,7 @@ func (p *describingManifestDeleter) DeleteManifest(registryClient *http.Client,

err := p.delegate.DeleteManifest(registryClient, registryURL, repo, manifest)
if err != nil {
fmt.Fprintf(os.Stderr, "error deleting data for repository %s image manifest %s from the registry: %v\n", repo, manifest, err)
fmt.Fprintf(os.Stderr, "error deleting manifest %s from repository %s: %v\n", manifest, repo, err)
}

return err
Expand Down
Loading

0 comments on commit 58876ea

Please sign in to comment.