Skip to content

Commit df6132c

Browse files
authored
[checks] improve ssm command invocation logging (#15)
There are scenarios where the SSM service is reachable, but, it's commands timeout.
1 parent 1241b01 commit df6132c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

gitpod-network-check/cmd/checks.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -500,17 +500,20 @@ func fetchResultsForInstance(ctx context.Context, svc *ssm.Client, instanceId, c
500500
}
501501

502502
if err != nil {
503+
log.Errorf("❌ Error getting command invocation for instance %s: %v", instanceId, err)
503504
return false, fmt.Errorf("error getting command invocation for instance %s: %v", instanceId, err)
504505
}
505506

506507
if *invocationResult.StatusDetails == "Pending" || *invocationResult.StatusDetails == "InProgress" {
508+
log.Debugf("⏳ Instance %s is %s for command %s", instanceId, *invocationResult.StatusDetails, commandId)
507509
return false, nil
508510
}
509511

510512
if *invocationResult.StatusDetails == "Success" {
511513
log.Debugf("✅ Instance %s command output:\n%s\n", instanceId, *invocationResult.StandardOutputContent)
512514
return true, nil
513515
} else {
516+
log.Errorf("❌ Instance %s command with status %s not successful:\n%s\n", instanceId, *invocationResult.StatusDetails, *invocationResult.StandardErrorContent)
514517
return false, fmt.Errorf("instance %s command failed: %s", instanceId, *invocationResult.StandardErrorContent)
515518
}
516519
})
@@ -524,11 +527,11 @@ func createSecurityGroups(ctx context.Context, svc *ec2.Client, subnetID string)
524527

525528
describeSubnetsOutput, err := svc.DescribeSubnets(ctx, describeSubnetsInput)
526529
if err != nil {
527-
return "", fmt.Errorf("Failed to describe subnet: %v", err)
530+
return "", fmt.Errorf("failed to describe subnet: %v", err)
528531
}
529532

530533
if len(describeSubnetsOutput.Subnets) == 0 {
531-
return "", fmt.Errorf("No subnets found with ID: %s", subnetID)
534+
return "", fmt.Errorf("no subnets found with ID: %s", subnetID)
532535
}
533536

534537
vpcID := describeSubnetsOutput.Subnets[0].VpcId
@@ -655,7 +658,7 @@ func getPreferredInstanceType(ctx context.Context, svc *ec2.Client) (types.Insta
655658
return instanceType, nil
656659
}
657660
}
658-
return "", fmt.Errorf("No preferred instance type available in region: %s", networkConfig.AwsRegion)
661+
return "", fmt.Errorf("no preferred instance type available in region: %s", networkConfig.AwsRegion)
659662
}
660663

661664
func instanceTypeExists(ctx context.Context, svc *ec2.Client, instanceType types.InstanceType) (bool, error) {

0 commit comments

Comments
 (0)