Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

kubecfg can't delete clusterrole from jsonnet #65

Closed
jjo opened this issue Jul 25, 2017 · 1 comment · Fixed by #62
Closed

kubecfg can't delete clusterrole from jsonnet #65

jjo opened this issue Jul 25, 2017 · 1 comment · Fixed by #62
Assignees
Labels

Comments

@jjo
Copy link
Contributor

jjo commented Jul 25, 2017

With below jsonnet for a simple clusterrole:

$ cat kubecfg-clusterrole-foo.jsonnet
local k = import "ksonnet.beta.1/k.libsonnet";
local objectMeta = k.core.v1.objectMeta;

local controller_roles = [{
  apiGroups: ['core'],
  resources: ['pods'],
  verbs: ['list'],
}];

local clusterRole(name, rules) = {
    apiVersion: "rbac.authorization.k8s.io/v1beta1",
    kind: "ClusterRole",
    metadata: objectMeta.name(name),
    rules: rules,
};

local controllerClusterRole = clusterRole("foo", controller_roles);

{
  controllerClusterRole: controllerClusterRole,
}

, doing update+delete fails with:

$ kubecfg -v=1 update kubecfg-clusterrole-foo.jsonnet 
INFO  Updating ClusterRole/foo
INFO  Creating non-existent ClusterRole/foo
$ kubecfg -v=1 delete kubecfg-clusterrole-foo.jsonnet 
INFO  Deleting ClusterRole/foo
FATAL Error deleting ClusterRole/foo:  "" is invalid: []: Invalid value: v1.DeleteOptions{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, GracePeriodSeconds:(*int64)(nil), Preconditions:(*v1.Preconditions)(nil), OrphanDependents:(*bool)(0xc426cd5aee), PropagationPolicy:(*v1.DeletionPropagation)(0xc426cd5af0)}: OrphanDependents and DeletionPropagation cannot be both set

# while kubectl CLI works ok:
$ kubectl delete clusterrole foo 
clusterrole "foo" deleted

FYI relevant versions (kubecfg built from HEAD as now, 2017-07-25 19:30 UTC):

$ kubecfg version
kubecfg version: (dev build)
jsonnet version: v0.9.4

$ kubectl version 
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"clean", BuildDate:"2017-05-19T18:44:27Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.4", GitCommit:"d6f433224538d4f9ca2f7ae19b252e6fcb66a3ae", GitTreeState:"dirty", BuildDate:"2017-06-22T04:31:09Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}

$ kubectl api-versions 
apps/v1beta1
authentication.k8s.io/v1
authentication.k8s.io/v1beta1
authorization.k8s.io/v1
authorization.k8s.io/v1beta1
autoscaling/v1
autoscaling/v2alpha1
batch/v1
batch/v2alpha1
certificates.k8s.io/v1beta1
extensions/v1beta1
k8s.io/v1
policy/v1beta1
rbac.authorization.k8s.io/v1alpha1
rbac.authorization.k8s.io/v1beta1
settings.k8s.io/v1alpha1
storage.k8s.io/v1
storage.k8s.io/v1beta1
v1

FYI -v=3 run:

$ kubecfg -v=3 delete kubecfg-clusterrole-foo.jsonnet 
DEBUG Adding jsonnet search path /home/jjo/work/src/github.com/ksonnet/ksonnet-lib
DEBUG jsonnet result is: {
   "controllerClusterRole": {
      "apiVersion": "rbac.authorization.k8s.io/v1beta1",
      "kind": "ClusterRole",
      "metadata": {
         "name": "foo"
      },
      "rules": [
         {
            "apiGroups": [
               "core"
            ],
            "resources": [
               "pods"
            ],
            "verbs": [
               "list"
            ]
         }
      ]
   }
}
INFO  Deleting ClusterRole/foo
DEBUG Chose API 'clusterroles' for rbac.authorization.k8s.io/v1beta1, Kind=ClusterRole
DEBUG Fetching client for &APIResource{Name:clusterroles,Namespaced:false,Kind:ClusterRole,Verbs:[create delete deletecollection get list patch update watch],ShortNames:[],} namespace=default
FATAL Error deleting ClusterRole/foo:  "" is invalid: []: Invalid value: v1.DeleteOptions{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, GracePeriodSeconds:(*int64)(nil), Preconditions:(*v1.Preconditions)(nil), OrphanDependents:(*bool)(0xc42d1b13ee), PropagationPolicy:(*v1.DeletionPropagation)(0xc42d1b13f0)}: OrphanDependents and DeletionPropagation cannot be both set
@jjo jjo changed the title can't kubecfg delete a clusterrole with rbac.authorization.k8s.io/v1beta1 can't kubecfg delete clusterrole Jul 25, 2017
@jjo
Copy link
Contributor Author

jjo commented Jul 25, 2017

Forgot to add: using kubecfg 0.9.4 release does ok:

$ kubecfg -v=1 update kubecfg-clusterrole-foo.jsonnet 
INFO  Updating ClusterRole/foo
INFO  Creating non-existent ClusterRole/foo
$ kubecfg -v=1 delete kubecfg-clusterrole-foo.jsonnet 
INFO  Deleting ClusterRole/foo
$ kubecfg version
kubecfg version: v0.3.0
jsonnet version: v0.9.4

@jjo jjo changed the title can't kubecfg delete clusterrole kubecfg can't delete clusterrole from jsonnet Jul 25, 2017
@anguslees anguslees added the bug label Jul 26, 2017
@anguslees anguslees self-assigned this Jul 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants