Skip to content

Commit

Permalink
Merge pull request #19468 from miminar/master
Browse files Browse the repository at this point in the history
image-pruner: prune images in their own jobs
  • Loading branch information
openshift-merge-robot authored Jun 22, 2018
2 parents ba21ba0 + b4dea92 commit dabec00
Show file tree
Hide file tree
Showing 168 changed files with 23,874 additions and 3,421 deletions.
5 changes: 2 additions & 3 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ import:
version: f74b330d45c56584a6ea7a27f5c64ea2900631e9
# cli
- package: github.com/gonum/graph
version: bde6d0fbd9dec5a997e906611fe0364001364c41
version: 50b27dea7ebbfb052dfaf91681afc6fde28d8796
# cli
- package: github.com/gonum/internal
version: e57e4534cf9b3b00ef6c0175f59d8d2d34f60914
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/server/bootstrappolicy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ func GetOpenshiftBootstrapClusterRoles() []rbac.ClusterRole {
rbac.NewRule("get", "list").Groups(appsGroup, extensionsGroup).Resources("replicasets").RuleOrDie(),

rbac.NewRule("delete").Groups(imageGroup, legacyImageGroup).Resources("images").RuleOrDie(),
rbac.NewRule("get", "list").Groups(imageGroup, legacyImageGroup).Resources("images", "imagestreams").RuleOrDie(),
rbac.NewRule("get", "list", "watch").Groups(imageGroup, legacyImageGroup).Resources("images", "imagestreams").RuleOrDie(),
rbac.NewRule("update").Groups(imageGroup, legacyImageGroup).Resources("imagestreams/status").RuleOrDie(),
},
},
Expand Down
40 changes: 38 additions & 2 deletions pkg/oc/admin/prune/imageprune/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import (
"sort"
"strings"

kapi "k8s.io/kubernetes/pkg/apis/core"

"github.com/docker/distribution/registry/api/errcode"
"github.com/golang/glog"

kmeta "k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/runtime"
kerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/kubernetes/pkg/api/legacyscheme"
kapiref "k8s.io/kubernetes/pkg/api/ref"
kapi "k8s.io/kubernetes/pkg/apis/core"

imageapi "github.com/openshift/origin/pkg/image/apis/image"
"github.com/openshift/origin/pkg/util/netutils"
Expand Down Expand Up @@ -265,3 +268,36 @@ func (e *ErrBadReference) String() string {
}
return fmt.Sprintf("%s[%s]: invalid %s reference %q: %s", e.kind, name, targetKind, e.reference, e.reason)
}

func getName(obj runtime.Object) string {
accessor, err := kmeta.Accessor(obj)
if err != nil {
glog.V(4).Infof("Error getting accessor for %#v", obj)
return "<unknown>"
}
ns := accessor.GetNamespace()
if len(ns) == 0 {
return accessor.GetName()
}
return fmt.Sprintf("%s/%s", ns, accessor.GetName())
}

func getKindName(obj *kapi.ObjectReference) string {
if obj == nil {
return "unknown object"
}
name := obj.Name
if len(obj.Namespace) > 0 {
name = obj.Namespace + "/" + name
}
return fmt.Sprintf("%s[%s]", obj.Kind, name)
}

func getRef(obj runtime.Object) *kapi.ObjectReference {
ref, err := kapiref.GetReference(legacyscheme.Scheme, obj)
if err != nil {
glog.Errorf("failed to get reference to object %T: %v", obj, err)
return nil
}
return ref
}
Loading

0 comments on commit dabec00

Please sign in to comment.