@@ -17,6 +17,8 @@ limitations under the License.
17
17
package patchnode
18
18
19
19
import (
20
+ "github.com/pkg/errors"
21
+
20
22
"k8s.io/api/core/v1"
21
23
clientset "k8s.io/client-go/kubernetes"
22
24
"k8s.io/klog/v2"
@@ -27,8 +29,7 @@ import (
27
29
28
30
// AnnotateCRISocket annotates the node with the given crisocket
29
31
func AnnotateCRISocket (client clientset.Interface , nodeName string , criSocket string ) error {
30
-
31
- klog .V (1 ).Infof ("[patchnode] Uploading the CRI Socket information %q to the Node API object %q as an annotation\n " , criSocket , nodeName )
32
+ klog .V (1 ).Infof ("[patchnode] Uploading the CRI socket %q to Node %q as an annotation" , criSocket , nodeName )
32
33
33
34
return apiclient .PatchNode (client , nodeName , func (n * v1.Node ) {
34
35
annotateNodeWithCRISocket (n , criSocket )
@@ -41,3 +42,20 @@ func annotateNodeWithCRISocket(n *v1.Node, criSocket string) {
41
42
}
42
43
n .ObjectMeta .Annotations [constants .AnnotationKubeadmCRISocket ] = criSocket
43
44
}
45
+
46
+ // RemoveCRISocketAnnotation removes the crisocket annotation from a node.
47
+ func RemoveCRISocketAnnotation (client clientset.Interface , nodeName string ) error {
48
+ klog .V (1 ).Infof ("[patchnode] Removing the CRI socket annotation from Node %q" , nodeName )
49
+
50
+ if err := apiclient .PatchNode (client , nodeName , removeNodeCRISocketAnnotation ); err != nil {
51
+ return errors .Wrapf (err , "could not remove the CRI socket annotation from Node %q" , nodeName )
52
+ }
53
+ return nil
54
+ }
55
+
56
+ func removeNodeCRISocketAnnotation (n * v1.Node ) {
57
+ if n .ObjectMeta .Annotations == nil {
58
+ return
59
+ }
60
+ delete (n .ObjectMeta .Annotations , constants .AnnotationKubeadmCRISocket )
61
+ }
0 commit comments