@@ -26,11 +26,11 @@ import (
26
26
"github.com/deckhouse/module-sdk/pkg"
27
27
"github.com/deckhouse/module-sdk/pkg/app"
28
28
"github.com/deckhouse/module-sdk/pkg/registry"
29
- "k8s.io/utils/ptr"
30
29
31
30
"hooks/pkg/common"
32
31
33
32
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
33
+ "k8s.io/utils/ptr"
34
34
)
35
35
36
36
const (
@@ -49,9 +49,9 @@ type NodeInfo struct {
49
49
Labels map [string ]string `json:"labels"`
50
50
}
51
51
52
- var _ = registry .RegisterFunc (configDiscoveryService , handleCleanUpNodeLabels )
52
+ var _ = registry .RegisterFunc (configVirtHandlerNodeCleanUp , handleCleanUpNodeLabels )
53
53
54
- var configDiscoveryService = & pkg.HookConfig {
54
+ var configVirtHandlerNodeCleanUp = & pkg.HookConfig {
55
55
OnAfterDeleteHelm : & pkg.OrderedConfig {Order : 5 },
56
56
Kubernetes : []pkg.KubernetesConfig {
57
57
{
@@ -68,7 +68,7 @@ var configDiscoveryService = &pkg.HookConfig{
68
68
},
69
69
},
70
70
ExecuteHookOnSynchronization : ptr .To (false ),
71
- ExecuteHookOnEvents : ptr .To (false ),
71
+ // ExecuteHookOnEvents: ptr.To(false),
72
72
},
73
73
},
74
74
@@ -83,32 +83,32 @@ func handleCleanUpNodeLabels(_ context.Context, input *pkg.HookInput) error {
83
83
return nil
84
84
}
85
85
86
- for _ , node := range nodes {
87
- nodeInfo := & NodeInfo {}
88
- if err := node .UnmarshalTo (nodeInfo ); err != nil {
89
- input .Logger .Error (fmt .Sprintf ("Failed to unmarshal node metadata %v" , err ))
90
- continue
91
- }
92
-
93
- patches := make ([]map [string ]string , 0 )
94
-
95
- for key , _ := range nodeInfo .Labels {
96
- if strings .Contains (key , labelPattern ) {
97
- patches = append (patches , map [string ]string {
98
- "op" : "remove" ,
99
- "path" : fmt .Sprintf ("/metadata/labels/%s" , jsonPatchEscape (key )),
100
- })
101
- }
102
- }
103
-
104
- if len (patches ) == 0 {
105
- continue
106
- } else {
107
- input .Logger .Info (fmt .Sprintf (logMessageTemplate , len (patches ), labelPattern , nodeInfo .Name ))
108
- }
109
-
110
- input .PatchCollector .PatchWithJSON (patches , "v1" , "Node" , "" , nodeInfo .Name )
111
- }
86
+ // for _, node := range nodes {
87
+ // nodeInfo := &NodeInfo{}
88
+ // if err := node.UnmarshalTo(nodeInfo); err != nil {
89
+ // input.Logger.Error(fmt.Sprintf("Failed to unmarshal node metadata %v", err))
90
+ // continue
91
+ // }
92
+
93
+ // patches := make([]map[string]string, 0)
94
+
95
+ // for key, _ := range nodeInfo.Labels {
96
+ // if strings.Contains(key, labelPattern) {
97
+ // patches = append(patches, map[string]string{
98
+ // "op": "remove",
99
+ // "path": fmt.Sprintf("/metadata/labels/%s", jsonPatchEscape(key)),
100
+ // })
101
+ // }
102
+ // }
103
+
104
+ // if len(patches) == 0 {
105
+ // continue
106
+ // } else {
107
+ // input.Logger.Info(fmt.Sprintf(logMessageTemplate, len(patches), labelPattern, nodeInfo.Name))
108
+ // }
109
+
110
+ // input.PatchCollector.PatchWithJSON(patches, "v1", "Node", "", nodeInfo.Name)
111
+ // }
112
112
return nil
113
113
}
114
114
0 commit comments