44 "context"
55 "fmt"
66 "net/http"
7+ "strconv"
78
9+ "github.com/linode/linode-cloud-controller-manager/sentry"
810 "github.com/linode/linodego"
911 v1 "k8s.io/api/core/v1"
1012 "k8s.io/apimachinery/pkg/types"
@@ -31,11 +33,16 @@ func (i *instances) lookupLinode(ctx context.Context, node *v1.Node) (*linodego.
3133 providerID := node .Spec .ProviderID
3234 nodeName := types .NodeName (node .Name )
3335
36+ sentry .SetTag (ctx , "provider_id" , providerID )
37+ sentry .SetTag (ctx , "node_name" , node .Name )
38+
3439 if providerID != "" {
3540 id , err := parseProviderID (providerID )
3641 if err != nil {
42+ sentry .CaptureError (ctx , err )
3743 return nil , err
3844 }
45+ sentry .SetTag (ctx , "linode_id" , strconv .Itoa (id ))
3946
4047 return linodeByID (ctx , i .client , id )
4148 }
@@ -44,19 +51,23 @@ func (i *instances) lookupLinode(ctx context.Context, node *v1.Node) (*linodego.
4451}
4552
4653func (i * instances ) InstanceExists (ctx context.Context , node * v1.Node ) (bool , error ) {
54+ ctx = sentry .SetHubOnContext (ctx )
4755 if _ , err := i .lookupLinode (ctx , node ); err != nil {
4856 if apiError , ok := err .(* linodego.Error ); ok && apiError .Code == http .StatusNotFound {
4957 return false , nil
5058 }
59+ sentry .CaptureError (ctx , err )
5160 return false , err
5261 }
5362
5463 return true , nil
5564}
5665
5766func (i * instances ) InstanceShutdown (ctx context.Context , node * v1.Node ) (bool , error ) {
67+ ctx = sentry .SetHubOnContext (ctx )
5868 instance , err := i .lookupLinode (ctx , node )
5969 if err != nil {
70+ sentry .CaptureError (ctx , err )
6071 return false , err
6172 }
6273
@@ -71,13 +82,17 @@ func (i *instances) InstanceShutdown(ctx context.Context, node *v1.Node) (bool,
7182}
7283
7384func (i * instances ) InstanceMetadata (ctx context.Context , node * v1.Node ) (* cloudprovider.InstanceMetadata , error ) {
85+ ctx = sentry .SetHubOnContext (ctx )
7486 linode , err := i .lookupLinode (ctx , node )
7587 if err != nil {
88+ sentry .CaptureError (ctx , err )
7689 return nil , err
7790 }
7891
7992 if len (linode .IPv4 ) == 0 {
80- return nil , instanceNoIPAddressesError {linode .ID }
93+ err := instanceNoIPAddressesError {linode .ID }
94+ sentry .CaptureError (ctx , err )
95+ return nil , err
8196 }
8297
8398 addresses := []v1.NodeAddress {{Type : v1 .NodeHostName , Address : linode .Label }}
0 commit comments