Skip to content

Commit

Permalink
chore: Don't use sprintf needlessly + clean up old comment
Browse files Browse the repository at this point in the history
  • Loading branch information
TwiN committed Aug 16, 2022
1 parent 1629e1b commit cdfa8a1
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (k *Client) GetNodes() ([]v1.Node, error) {
// GetPodsInNode retrieves all pods from a given node
func (k *Client) GetPodsInNode(node string) ([]v1.Pod, error) {
podList, err := k.client.CoreV1().Pods("").List(context.TODO(), metav1.ListOptions{
FieldSelector: fmt.Sprintf("spec.nodeName=%s", node),
FieldSelector: "spec.nodeName=" + node,
})
if err != nil {
return nil, err
Expand All @@ -82,20 +82,6 @@ func (k *Client) GetPodsInNode(node string) ([]v1.Pod, error) {
// Because we cannot filter by spec.providerID, the entire list of nodes is fetched every time
// this function is called
func (k *Client) GetNodeByAutoScalingInstance(instance *autoscaling.Instance) (*v1.Node, error) {
////For some reason, we can't filter by spec.providerID
//api := k.client.CoreV1().Nodes()
//nodeList, err := api.List(metav1.ListOptions{
// //LabelSelector: fmt.Sprintf("%s=%s", HostNameAnnotationKey, aws.StringValue(instance.InstanceId)),
// FieldSelector: fmt.Sprintf("spec.providerID=aws:///%s/%s", aws.StringValue(instance.AvailabilityZone), aws.StringValue(instance.InstanceId)),
// Limit: 1,
//})
//if err != nil {
// return nil, err
//}
//if len(nodeList.Items) == 0 {
// return nil, fmt.Errorf("nodes with AWS instance id \"%s\" not found", aws.StringValue(instance.InstanceId))
//}
//return &nodeList.Items[0], nil
nodes, err := k.GetNodes()
if err != nil {
return nil, err
Expand Down

0 comments on commit cdfa8a1

Please sign in to comment.