Add Annotations from the deviceplugin to the runtime

This commit is contained in:
Renaud Gaubert
2018-01-11 22:15:10 +01:00
parent eb5035b08d
commit db537e5954
8 changed files with 57 additions and 11 deletions

View File

@@ -156,6 +156,11 @@ func TestContainerAnnotations(t *testing.T) {
restartCount := 5
deletionGracePeriod := int64(10)
terminationGracePeriod := int64(10)
opts := &kubecontainer.RunContainerOptions{
Annotations: []kubecontainer.Annotation{
{Name: "Foo", Value: "bar"},
},
}
lifecycle := &v1.Lifecycle{
// Left PostStart as nil
PreStop: &v1.Handler{
@@ -216,11 +221,14 @@ func TestContainerAnnotations(t *testing.T) {
}
// Test whether we can get right information from label
annotations := newContainerAnnotations(container, pod, restartCount)
annotations := newContainerAnnotations(container, pod, restartCount, opts)
containerInfo := getContainerInfoFromAnnotations(annotations)
if !reflect.DeepEqual(containerInfo, expected) {
t.Errorf("expected %v, got %v", expected, containerInfo)
}
if v, ok := annotations[opts.Annotations[0].Name]; !ok || v != opts.Annotations[0].Value {
t.Errorf("expected annotation %s to exist got %v, %v", opts.Annotations[0].Name, ok, v)
}
// Test when DeletionGracePeriodSeconds, TerminationGracePeriodSeconds and Lifecycle are nil,
// the information got from annotations should also be nil
@@ -232,11 +240,14 @@ func TestContainerAnnotations(t *testing.T) {
expected.PreStopHandler = nil
// Because container is changed, the Hash should be updated
expected.Hash = kubecontainer.HashContainer(container)
annotations = newContainerAnnotations(container, pod, restartCount)
annotations = newContainerAnnotations(container, pod, restartCount, opts)
containerInfo = getContainerInfoFromAnnotations(annotations)
if !reflect.DeepEqual(containerInfo, expected) {
t.Errorf("expected %v, got %v", expected, containerInfo)
}
if v, ok := annotations[opts.Annotations[0].Name]; !ok || v != opts.Annotations[0].Value {
t.Errorf("expected annotation %s to exist got %v, %v", opts.Annotations[0].Name, ok, v)
}
}
func TestPodLabels(t *testing.T) {