mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-16 21:38:23 +00:00
Merge pull request #897 from marquiz/devel/drop-incubator
nfd-master: drop cleanup of ancient incubator labels
This commit is contained in:
commit
0abae922fa
2 changed files with 13 additions and 17 deletions
|
@ -533,3 +533,16 @@ func sortJsonPatches(p []apihelper.JsonPatch) []apihelper.JsonPatch {
|
||||||
sort.Slice(p, func(i, j int) bool { return p[i].Path < p[j].Path })
|
sort.Slice(p, func(i, j int) bool { return p[i].Path < p[j].Path })
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove any labels having the given prefix
|
||||||
|
func removeLabelsWithPrefix(n *api.Node, search string) []apihelper.JsonPatch {
|
||||||
|
var p []apihelper.JsonPatch
|
||||||
|
|
||||||
|
for k := range n.Labels {
|
||||||
|
if strings.HasPrefix(k, search) {
|
||||||
|
p = append(p, apihelper.NewJsonPatch("remove", "/metadata/labels", k, ""))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
|
@ -580,10 +580,6 @@ func (m *nfdMaster) updateNodeFeatures(nodeName string, labels Labels, annotatio
|
||||||
patches := createPatches(oldLabels, node.Labels, labels, "/metadata/labels")
|
patches := createPatches(oldLabels, node.Labels, labels, "/metadata/labels")
|
||||||
patches = append(patches, createPatches(nil, node.Annotations, annotations, "/metadata/annotations")...)
|
patches = append(patches, createPatches(nil, node.Annotations, annotations, "/metadata/annotations")...)
|
||||||
|
|
||||||
// Also, remove all labels with the old prefix, and the old version label
|
|
||||||
patches = append(patches, removeLabelsWithPrefix(node, "node.alpha.kubernetes-incubator.io/nfd")...)
|
|
||||||
patches = append(patches, removeLabelsWithPrefix(node, "node.alpha.kubernetes-incubator.io/node-feature-discovery")...)
|
|
||||||
|
|
||||||
// Patch the node object in the apiserver
|
// Patch the node object in the apiserver
|
||||||
err = m.apihelper.PatchNode(cli, node.Name, patches)
|
err = m.apihelper.PatchNode(cli, node.Name, patches)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -612,19 +608,6 @@ func (m *nfdMaster) getKubeconfig() (*restclient.Config, error) {
|
||||||
return m.kubeconfig, err
|
return m.kubeconfig, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove any labels having the given prefix
|
|
||||||
func removeLabelsWithPrefix(n *api.Node, search string) []apihelper.JsonPatch {
|
|
||||||
var p []apihelper.JsonPatch
|
|
||||||
|
|
||||||
for k := range n.Labels {
|
|
||||||
if strings.HasPrefix(k, search) {
|
|
||||||
p = append(p, apihelper.NewJsonPatch("remove", "/metadata/labels", k, ""))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return p
|
|
||||||
}
|
|
||||||
|
|
||||||
// createPatches is a generic helper that returns json patch operations to perform
|
// createPatches is a generic helper that returns json patch operations to perform
|
||||||
func createPatches(removeKeys []string, oldItems map[string]string, newItems map[string]string, jsonPath string) []apihelper.JsonPatch {
|
func createPatches(removeKeys []string, oldItems map[string]string, newItems map[string]string, jsonPath string) []apihelper.JsonPatch {
|
||||||
patches := []apihelper.JsonPatch{}
|
patches := []apihelper.JsonPatch{}
|
||||||
|
|
Loading…
Add table
Reference in a new issue