Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
efbfead4
Commit
efbfead4
authored
Oct 30, 2017
by
Jun Xiang Tee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove created-by annotation
parent
1f53329c
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
11 additions
and
119 deletions
+11
-119
test-cmd-util.sh
hack/make-rules/test-cmd-util.sh
+3
-3
annotation_key_constants.go
pkg/api/annotation_key_constants.go
+0
-6
BUILD
pkg/controller/BUILD
+0
-2
controller_utils.go
pkg/controller/controller_utils.go
+3
-25
utils.go
pkg/controller/cronjob/utils.go
+0
-5
utils_test.go
pkg/controller/cronjob/utils_test.go
+1
-13
annotate_test.go
pkg/kubectl/cmd/annotate_test.go
+2
-2
drain_test.go
pkg/kubectl/cmd/drain_test.go
+0
-38
describe.go
pkg/printers/internalversion/describe.go
+2
-18
annotation_key_constants.go
staging/src/k8s.io/api/core/v1/annotation_key_constants.go
+0
-6
kubectl.go
test/e2e/kubectl/kubectl.go
+0
-1
No files found.
hack/make-rules/test-cmd-util.sh
View file @
efbfead4
...
...
@@ -1253,7 +1253,7 @@ run_kubectl_run_tests() {
# Post-Condition: Job "pi" is created
kube::test::get_object_assert
jobs
"{{range.items}}{{
$id_field
}}:{{end}}"
'pi:'
# Describe command (resource only) should print detailed information
kube::test::describe_resource_assert pods
"Name:"
"Image:"
"Node:"
"Labels:"
"Status:"
"C
reat
ed By"
kube::test::describe_resource_assert pods
"Name:"
"Image:"
"Node:"
"Labels:"
"Status:"
"C
ontroll
ed By"
# Clean up
kubectl delete
jobs
pi
"
${
kube_flags
[@]
}
"
# Post-condition: no pods exist.
...
...
@@ -2746,7 +2746,7 @@ run_deployment_tests() {
# Describe command (resource only) should print detailed information
kube::test::describe_resource_assert rs
"Name:"
"Pod Template:"
"Labels:"
"Selector:"
"Controlled By"
"Replicas:"
"Pods Status:"
"Volumes:"
# Describe command (resource only) should print detailed information
kube::test::describe_resource_assert pods
"Name:"
"Image:"
"Node:"
"Labels:"
"Status:"
"C
reated By"
"C
ontrolled By"
kube::test::describe_resource_assert pods
"Name:"
"Image:"
"Node:"
"Labels:"
"Status:"
"Controlled By"
# Clean up
kubectl delete deployment test-nginx-apps
"
${
kube_flags
[@]
}
"
...
...
@@ -2986,7 +2986,7 @@ run_rs_tests() {
# Describe command should print events information when show-events=true
kube::test::describe_resource_events_assert rs
true
# Describe command (resource only) should print detailed information
kube::test::describe_resource_assert pods
"Name:"
"Image:"
"Node:"
"Labels:"
"Status:"
"C
reated By"
"C
ontrolled By"
kube::test::describe_resource_assert pods
"Name:"
"Image:"
"Node:"
"Labels:"
"Status:"
"Controlled By"
### Scale replica set frontend with current-replicas and replicas
# Pre-condition: 3 replicas
...
...
pkg/api/annotation_key_constants.go
View file @
efbfead4
...
...
@@ -45,12 +45,6 @@ const (
// to one container of a pod.
SeccompContainerAnnotationKeyPrefix
string
=
"container.seccomp.security.alpha.kubernetes.io/"
// CreatedByAnnotation represents the key used to store the spec(json)
// used to create the resource.
// This field is deprecated in favor of ControllerRef (see #44407).
// TODO(#50720): Remove this field in v1.9.
CreatedByAnnotation
=
"kubernetes.io/created-by"
// PreferAvoidPodsAnnotationKey represents the key of preferAvoidPods data (json serialized)
// in the Annotations of a Node.
PreferAvoidPodsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/preferAvoidPods"
...
...
pkg/controller/BUILD
View file @
efbfead4
...
...
@@ -83,13 +83,11 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/watch:go_default_library",
"//vendor/k8s.io/apiserver/pkg/authentication/serviceaccount:go_default_library",
"//vendor/k8s.io/client-go/kubernetes:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/scheme:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/typed/authentication/v1:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/typed/core/v1:go_default_library",
"//vendor/k8s.io/client-go/rest:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
"//vendor/k8s.io/client-go/tools/record:go_default_library",
"//vendor/k8s.io/client-go/tools/reference:go_default_library",
"//vendor/k8s.io/client-go/util/integer:go_default_library",
"//vendor/k8s.io/client-go/util/retry:go_default_library",
],
...
...
pkg/controller/controller_utils.go
View file @
efbfead4
...
...
@@ -38,10 +38,8 @@ import (
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/apimachinery/pkg/util/wait"
clientset
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/record"
ref
"k8s.io/client-go/tools/reference"
"k8s.io/client-go/util/integer"
clientretry
"k8s.io/client-go/util/retry"
_
"k8s.io/kubernetes/pkg/api/install"
...
...
@@ -474,29 +472,12 @@ func getPodsFinalizers(template *v1.PodTemplateSpec) []string {
return
desiredFinalizers
}
func
getPodsAnnotationSet
(
template
*
v1
.
PodTemplateSpec
,
object
runtime
.
Object
)
(
labels
.
Set
,
error
)
{
func
getPodsAnnotationSet
(
template
*
v1
.
PodTemplateSpec
)
labels
.
Set
{
desiredAnnotations
:=
make
(
labels
.
Set
)
for
k
,
v
:=
range
template
.
Annotations
{
desiredAnnotations
[
k
]
=
v
}
createdByRef
,
err
:=
ref
.
GetReference
(
scheme
.
Scheme
,
object
)
if
err
!=
nil
{
return
desiredAnnotations
,
fmt
.
Errorf
(
"unable to get controller reference: %v"
,
err
)
}
// TODO: this code was not safe previously - as soon as new code came along that switched to v2, old clients
// would be broken upon reading it. This is explicitly hardcoded to v1 to guarantee predictable deployment.
// We need to consistently handle this case of annotation versioning.
codec
:=
scheme
.
Codecs
.
LegacyCodec
(
v1
.
SchemeGroupVersion
)
createdByRefJson
,
err
:=
runtime
.
Encode
(
codec
,
&
v1
.
SerializedReference
{
Reference
:
*
createdByRef
,
})
if
err
!=
nil
{
return
desiredAnnotations
,
fmt
.
Errorf
(
"unable to serialize controller reference: %v"
,
err
)
}
desiredAnnotations
[
v1
.
CreatedByAnnotation
]
=
string
(
createdByRefJson
)
return
desiredAnnotations
,
nil
return
desiredAnnotations
}
func
getPodsPrefix
(
controllerName
string
)
string
{
...
...
@@ -553,10 +534,7 @@ func (r RealPodControl) PatchPod(namespace, name string, data []byte) error {
func
GetPodFromTemplate
(
template
*
v1
.
PodTemplateSpec
,
parentObject
runtime
.
Object
,
controllerRef
*
metav1
.
OwnerReference
)
(
*
v1
.
Pod
,
error
)
{
desiredLabels
:=
getPodsLabelSet
(
template
)
desiredFinalizers
:=
getPodsFinalizers
(
template
)
desiredAnnotations
,
err
:=
getPodsAnnotationSet
(
template
,
parentObject
)
if
err
!=
nil
{
return
nil
,
err
}
desiredAnnotations
:=
getPodsAnnotationSet
(
template
)
accessor
,
err
:=
meta
.
Accessor
(
parentObject
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"parentObject does not have ObjectMeta, %v"
,
err
)
...
...
pkg/controller/cronjob/utils.go
View file @
efbfead4
...
...
@@ -176,11 +176,6 @@ func getJobFromTemplate(sj *batchv1beta1.CronJob, scheduledTime time.Time) (*bat
// scheduled-job-name=$SJ_NAME -- for user convenience
labels
:=
copyLabels
(
&
sj
.
Spec
.
JobTemplate
)
annotations
:=
copyAnnotations
(
&
sj
.
Spec
.
JobTemplate
)
createdByRefJson
,
err
:=
makeCreatedByRefJson
(
sj
)
if
err
!=
nil
{
return
nil
,
err
}
annotations
[
v1
.
CreatedByAnnotation
]
=
string
(
createdByRefJson
)
// We want job names for a given nominal start time to have a deterministic name to avoid the same job being created twice
name
:=
fmt
.
Sprintf
(
"%s-%d"
,
sj
.
Name
,
getTimeHash
(
scheduledTime
))
...
...
pkg/controller/cronjob/utils_test.go
View file @
efbfead4
...
...
@@ -83,21 +83,9 @@ func TestGetJobFromTemplate(t *testing.T) {
if
len
(
job
.
ObjectMeta
.
Labels
)
!=
1
{
t
.
Errorf
(
"Wrong number of labels"
)
}
if
len
(
job
.
ObjectMeta
.
Annotations
)
!=
2
{
if
len
(
job
.
ObjectMeta
.
Annotations
)
!=
1
{
t
.
Errorf
(
"Wrong number of annotations"
)
}
v
,
ok
:=
job
.
ObjectMeta
.
Annotations
[
v1
.
CreatedByAnnotation
]
if
!
ok
{
t
.
Errorf
(
"Missing created-by annotation"
)
}
expectedCreatedBy
:=
`{"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"CronJob","namespace":"snazzycats","name":"mycronjob","uid":"1a2b3c","apiVersion":"batch"}}
`
if
len
(
v
)
!=
len
(
expectedCreatedBy
)
{
t
.
Errorf
(
"Wrong length for created-by annotation, expected %v got %v"
,
len
(
expectedCreatedBy
),
len
(
v
))
}
if
v
!=
expectedCreatedBy
{
t
.
Errorf
(
"Wrong value for created-by annotation, expected %v got %v"
,
expectedCreatedBy
,
v
)
}
}
func
TestGetParentUIDFromJob
(
t
*
testing
.
T
)
{
...
...
pkg/kubectl/cmd/annotate_test.go
View file @
efbfead4
...
...
@@ -118,8 +118,8 @@ func TestParseAnnotations(t *testing.T) {
expectErr
:
false
,
},
{
annotations
:
[]
string
{
"url="
+
testURL
,
api
.
CreatedByAnnotation
+
"
="
+
testJSON
},
expected
:
map
[
string
]
string
{
"url"
:
testURL
,
api
.
CreatedByAnnotation
:
testJSON
},
annotations
:
[]
string
{
"url="
+
testURL
,
"fake.kubernetes.io/annotation
="
+
testJSON
},
expected
:
map
[
string
]
string
{
"url"
:
testURL
,
"fake.kubernetes.io/annotation"
:
testJSON
},
expectedRemove
:
[]
string
{},
scenario
:
"add annotations with special characters"
,
expectErr
:
false
,
...
...
pkg/kubectl/cmd/drain_test.go
View file @
efbfead4
...
...
@@ -247,9 +247,6 @@ func TestDrain(t *testing.T) {
},
}
rc_anno
:=
make
(
map
[
string
]
string
)
rc_anno
[
api
.
CreatedByAnnotation
]
=
refJson
(
t
,
&
rc
)
rc_pod
:=
corev1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"bar"
,
...
...
@@ -257,7 +254,6 @@ func TestDrain(t *testing.T) {
CreationTimestamp
:
metav1
.
Time
{
Time
:
time
.
Now
()},
Labels
:
labels
,
SelfLink
:
testapi
.
Default
.
SelfLink
(
"pods"
,
"bar"
),
Annotations
:
rc_anno
,
OwnerReferences
:
[]
metav1
.
OwnerReference
{
{
APIVersion
:
"v1"
,
...
...
@@ -286,9 +282,6 @@ func TestDrain(t *testing.T) {
},
}
ds_anno
:=
make
(
map
[
string
]
string
)
ds_anno
[
api
.
CreatedByAnnotation
]
=
refJson
(
t
,
&
ds
)
ds_pod
:=
corev1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"bar"
,
...
...
@@ -296,7 +289,6 @@ func TestDrain(t *testing.T) {
CreationTimestamp
:
metav1
.
Time
{
Time
:
time
.
Now
()},
Labels
:
labels
,
SelfLink
:
testapi
.
Default
.
SelfLink
(
"pods"
,
"bar"
),
Annotations
:
ds_anno
,
OwnerReferences
:
[]
metav1
.
OwnerReference
{
{
APIVersion
:
"extensions/v1beta1"
,
...
...
@@ -312,21 +304,6 @@ func TestDrain(t *testing.T) {
},
}
missing_ds
:=
extensions
.
DaemonSet
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"missing-ds"
,
Namespace
:
"default"
,
CreationTimestamp
:
metav1
.
Time
{
Time
:
time
.
Now
()},
SelfLink
:
testapi
.
Default
.
SelfLink
(
"daemonsets"
,
"missing-ds"
),
},
Spec
:
extensions
.
DaemonSetSpec
{
Selector
:
&
metav1
.
LabelSelector
{
MatchLabels
:
labels
},
},
}
missing_ds_anno
:=
make
(
map
[
string
]
string
)
missing_ds_anno
[
api
.
CreatedByAnnotation
]
=
refJson
(
t
,
&
missing_ds
)
orphaned_ds_pod
:=
corev1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"bar"
,
...
...
@@ -334,16 +311,6 @@ func TestDrain(t *testing.T) {
CreationTimestamp
:
metav1
.
Time
{
Time
:
time
.
Now
()},
Labels
:
labels
,
SelfLink
:
testapi
.
Default
.
SelfLink
(
"pods"
,
"bar"
),
Annotations
:
missing_ds_anno
,
OwnerReferences
:
[]
metav1
.
OwnerReference
{
{
APIVersion
:
"extensions/v1beta1"
,
Kind
:
"DaemonSet"
,
Name
:
"missing-ds"
,
BlockOwnerDeletion
:
boolptr
(
true
),
Controller
:
boolptr
(
true
),
},
},
},
Spec
:
corev1
.
PodSpec
{
NodeName
:
"node"
,
...
...
@@ -369,7 +336,6 @@ func TestDrain(t *testing.T) {
CreationTimestamp
:
metav1
.
Time
{
Time
:
time
.
Now
()},
Labels
:
labels
,
SelfLink
:
testapi
.
Default
.
SelfLink
(
"pods"
,
"bar"
),
Annotations
:
map
[
string
]
string
{
api
.
CreatedByAnnotation
:
refJson
(
t
,
&
job
)},
OwnerReferences
:
[]
metav1
.
OwnerReference
{
{
APIVersion
:
"v1"
,
...
...
@@ -395,9 +361,6 @@ func TestDrain(t *testing.T) {
},
}
rs_anno
:=
make
(
map
[
string
]
string
)
rs_anno
[
api
.
CreatedByAnnotation
]
=
refJson
(
t
,
&
rs
)
rs_pod
:=
corev1
.
Pod
{
ObjectMeta
:
metav1
.
ObjectMeta
{
Name
:
"bar"
,
...
...
@@ -405,7 +368,6 @@ func TestDrain(t *testing.T) {
CreationTimestamp
:
metav1
.
Time
{
Time
:
time
.
Now
()},
Labels
:
labels
,
SelfLink
:
testapi
.
Default
.
SelfLink
(
"pods"
,
"bar"
),
Annotations
:
rs_anno
,
OwnerReferences
:
[]
metav1
.
OwnerReference
{
{
APIVersion
:
"v1"
,
...
...
pkg/printers/internalversion/describe.go
View file @
efbfead4
...
...
@@ -19,7 +19,6 @@ package internalversion
import
(
"bytes"
"crypto/x509"
"encoding/json"
"fmt"
"io"
"net"
...
...
@@ -647,9 +646,6 @@ func describePod(pod *api.Pod, events *api.EventList) (string, error) {
w
.
Write
(
LEVEL_0
,
"Message:
\t
%s
\n
"
,
pod
.
Status
.
Message
)
}
w
.
Write
(
LEVEL_0
,
"IP:
\t
%s
\n
"
,
pod
.
Status
.
PodIP
)
if
createdBy
:=
printCreator
(
pod
.
Annotations
);
len
(
createdBy
)
>
0
{
w
.
Write
(
LEVEL_0
,
"Created By:
\t
%s
\n
"
,
createdBy
)
}
if
controlledBy
:=
printController
(
pod
);
len
(
controlledBy
)
>
0
{
w
.
Write
(
LEVEL_0
,
"Controlled By:
\t
%s
\n
"
,
controlledBy
)
}
...
...
@@ -688,18 +684,6 @@ func printController(controllee metav1.Object) string {
return
""
}
func
printCreator
(
annotation
map
[
string
]
string
)
string
{
value
,
ok
:=
annotation
[
api
.
CreatedByAnnotation
]
if
ok
{
var
r
api
.
SerializedReference
err
:=
json
.
Unmarshal
([]
byte
(
value
),
&
r
)
if
err
==
nil
{
return
fmt
.
Sprintf
(
"%s/%s"
,
r
.
Reference
.
Kind
,
r
.
Reference
.
Name
)
}
}
return
""
}
func
describeVolumes
(
volumes
[]
api
.
Volume
,
w
PrefixWriter
,
space
string
)
{
if
volumes
==
nil
||
len
(
volumes
)
==
0
{
w
.
Write
(
LEVEL_0
,
"%sVolumes:
\t
<none>
\n
"
,
space
)
...
...
@@ -1686,8 +1670,8 @@ func describeJob(job *batch.Job, events *api.EventList) (string, error) {
w
.
Write
(
LEVEL_0
,
"Selector:
\t
%s
\n
"
,
selector
)
printLabelsMultiline
(
w
,
"Labels"
,
job
.
Labels
)
printAnnotationsMultiline
(
w
,
"Annotations"
,
job
.
Annotations
)
if
c
reatedBy
:=
printCreator
(
job
.
Annotations
);
len
(
creat
edBy
)
>
0
{
w
.
Write
(
LEVEL_0
,
"C
reated By:
\t
%s
\n
"
,
creat
edBy
)
if
c
ontrolledBy
:=
printController
(
job
);
len
(
controll
edBy
)
>
0
{
w
.
Write
(
LEVEL_0
,
"C
ontrolled By:
\t
%s
\n
"
,
controll
edBy
)
}
w
.
Write
(
LEVEL_0
,
"Parallelism:
\t
%d
\n
"
,
*
job
.
Spec
.
Parallelism
)
if
job
.
Spec
.
Completions
!=
nil
{
...
...
staging/src/k8s.io/api/core/v1/annotation_key_constants.go
View file @
efbfead4
...
...
@@ -45,12 +45,6 @@ const (
// to one container of a pod.
SeccompContainerAnnotationKeyPrefix
string
=
"container.seccomp.security.alpha.kubernetes.io/"
// CreatedByAnnotation represents the key used to store the spec(json)
// used to create the resource.
// This field is deprecated in favor of ControllerRef (see #44407).
// TODO(#50720): Remove this field in v1.9.
CreatedByAnnotation
=
"kubernetes.io/created-by"
// PreferAvoidPodsAnnotationKey represents the key of preferAvoidPods data (json serialized)
// in the Annotations of a Node.
PreferAvoidPodsAnnotationKey
string
=
"scheduler.alpha.kubernetes.io/preferAvoidPods"
...
...
test/e2e/kubectl/kubectl.go
View file @
efbfead4
...
...
@@ -857,7 +857,6 @@ metadata:
{
"Annotations:"
},
{
"Status:"
,
"Running"
},
{
"IP:"
},
{
"Created By:"
,
"ReplicationController/redis-master"
},
{
"Controlled By:"
,
"ReplicationController/redis-master"
},
{
"Image:"
,
redisImage
},
{
"State:"
,
"Running"
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment