Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image-pruner: prune images in their own jobs #19468

Merged
merged 3 commits into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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