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
2db3728f
Commit
2db3728f
authored
Sep 22, 2017
by
wackxu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use patch PodStatus to avoid overwriting potential pending status updates
parent
ac33bfd5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
BUILD
plugin/pkg/scheduler/factory/BUILD
+1
-0
factory.go
plugin/pkg/scheduler/factory/factory.go
+10
-3
No files found.
plugin/pkg/scheduler/factory/BUILD
View file @
2db3728f
...
@@ -29,6 +29,7 @@ go_library(
...
@@ -29,6 +29,7 @@ go_library(
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
...
...
plugin/pkg/scheduler/factory/factory.go
View file @
2db3728f
...
@@ -26,6 +26,7 @@ import (
...
@@ -26,6 +26,7 @@ import (
"k8s.io/api/core/v1"
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/runtime/schema"
...
@@ -52,6 +53,7 @@ import (
...
@@ -52,6 +53,7 @@ import (
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
"k8s.io/kubernetes/plugin/pkg/scheduler/schedulercache"
"k8s.io/kubernetes/plugin/pkg/scheduler/util"
"k8s.io/kubernetes/plugin/pkg/scheduler/util"
"encoding/json"
"github.com/golang/glog"
"github.com/golang/glog"
)
)
...
@@ -1001,7 +1003,6 @@ func (p *podPreemptor) DeletePod(pod *v1.Pod) error {
...
@@ -1001,7 +1003,6 @@ func (p *podPreemptor) DeletePod(pod *v1.Pod) error {
return
p
.
Client
.
CoreV1
()
.
Pods
(
pod
.
Namespace
)
.
Delete
(
pod
.
Name
,
&
metav1
.
DeleteOptions
{})
return
p
.
Client
.
CoreV1
()
.
Pods
(
pod
.
Namespace
)
.
Delete
(
pod
.
Name
,
&
metav1
.
DeleteOptions
{})
}
}
//TODO(bsalamat): change this to patch PodStatus to avoid overwriting potential pending status updates.
func
(
p
*
podPreemptor
)
UpdatePodAnnotations
(
pod
*
v1
.
Pod
,
annotations
map
[
string
]
string
)
error
{
func
(
p
*
podPreemptor
)
UpdatePodAnnotations
(
pod
*
v1
.
Pod
,
annotations
map
[
string
]
string
)
error
{
podCopy
:=
pod
.
DeepCopy
()
podCopy
:=
pod
.
DeepCopy
()
if
podCopy
.
Annotations
==
nil
{
if
podCopy
.
Annotations
==
nil
{
...
@@ -1010,6 +1011,12 @@ func (p *podPreemptor) UpdatePodAnnotations(pod *v1.Pod, annotations map[string]
...
@@ -1010,6 +1011,12 @@ func (p *podPreemptor) UpdatePodAnnotations(pod *v1.Pod, annotations map[string]
for
k
,
v
:=
range
annotations
{
for
k
,
v
:=
range
annotations
{
podCopy
.
Annotations
[
k
]
=
v
podCopy
.
Annotations
[
k
]
=
v
}
}
_
,
err
:=
p
.
Client
.
CoreV1
()
.
Pods
(
podCopy
.
Namespace
)
.
UpdateStatus
(
podCopy
)
ret
:=
&
unstructured
.
Unstructured
{}
return
err
ret
.
SetAnnotations
(
podCopy
.
Annotations
)
patchData
,
err
:=
json
.
Marshal
(
ret
)
if
err
!=
nil
{
return
err
}
_
,
error
:=
p
.
Client
.
CoreV1
()
.
Pods
(
podCopy
.
Namespace
)
.
Patch
(
podCopy
.
Name
,
types
.
MergePatchType
,
patchData
)
return
error
}
}
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