From 2095744672adf604e7a387cdcb181b74caf96062 Mon Sep 17 00:00:00 2001 From: Okan Kocabalkanli Date: Thu, 21 Sep 2023 15:33:44 -0400 Subject: [PATCH] testing/ temp removed cleanup --- .github/workflows/test-build.yml | 2 +- packaging/uniformBuild/aws_utils.go | 23 +++++++++++++++-------- packaging/uniformBuild/commands.go | 2 +- packaging/uniformBuild/uniformBuilder.go | 7 +++---- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index 23dc57005a..c43c2a732c 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -86,7 +86,7 @@ jobs: run: | cd packaging/uniformBuild go build . - ./uniformBuild -r "${{github.repositoryUrl}}" -b "main" -c "${{github.sha}} -a ${{secrets.AWS_TEST_ACCOUNT_ID}}" + ./uniformBuild -r "${{github.repositoryUrl}}" -b "main" -c "${{github.sha}}" -a "${{secrets.AWS_TEST_ACCOUNT_ID}}" # - name: Cache go ^^^ make it not main # # Only skip for integration builds not release builds. diff --git a/packaging/uniformBuild/aws_utils.go b/packaging/uniformBuild/aws_utils.go index 7d98673955..f16f33cae8 100644 --- a/packaging/uniformBuild/aws_utils.go +++ b/packaging/uniformBuild/aws_utils.go @@ -65,7 +65,8 @@ func (imng *InstanceManager) GetAllAMIVersions(accountID string) []types.Image { Filters: filters, }) if err != nil { - panic(err) + fmt.Println(err) + return nil } // Sort the images based on the CreationDate field in descending order sort.Slice(resp.Images, func(i, j int) bool { @@ -86,7 +87,8 @@ func (imng *InstanceManager) GetLatestAMIVersion(accountID string) *types.Image func parseTime(value string) *time.Time { t, err := time.Parse("2006-01-02T15:04:05.999999999Z", value) if err != nil { - panic(err) + fmt.Println(err) + return nil } return &t } @@ -130,6 +132,7 @@ func (imng *InstanceManager) CreateEC2InstancesBlocking() error { fmt.Println(err) return } + time.Sleep(30 * time.Second) }(instance) } wg.Wait() @@ -283,8 +286,8 @@ func RunCmdRemotely(ssmClient *ssm.Client, instance *types.Instance, command str "workingDirectory": {"~"}, "executionTimeout": {strconv.Itoa(int(timeout))}, }, - OutputS3BucketName: aws.String("buildenvtesting"), - OutputS3KeyPrefix: aws.String("buildenvtesting/logs/"), + OutputS3BucketName: aws.String(S3_INTEGRATION_BUCKET), + OutputS3KeyPrefix: aws.String(S3_INTEGRATION_BUCKET + "logs/"), TimeoutSeconds: aws.Int32(timeout), Comment: aws.String(enforceCommentLimit(comment)), @@ -331,7 +334,8 @@ func WaitUntilAgentIsOn(client *ec2.Client, instance *types.Instance) { fmt.Printf("Trying to connect to ec2 instance, try count : %d \n", retryCount) output, err := client.DescribeInstanceStatus(context.Background(), input) if err != nil { - panic(err) + fmt.Println(err) + return } if len(output.InstanceStatuses) == 0 { time.Sleep(1 * time.Minute) @@ -352,7 +356,8 @@ func GetInstanceFromID(client *ec2.Client, instanceID string) *types.Instance { } output, err := client.DescribeInstances(context.Background(), input) if err != nil { - panic(err) + fmt.Println(err) + return nil } // Return instance object if len(output.Reservations) == 0 || len(output.Reservations[0].Instances) == 0 { @@ -365,7 +370,8 @@ func GetCommandsList(ssmClient *ssm.Client) { // List all commands resp, err := ssmClient.ListCommands(context.TODO(), &ssm.ListCommandsInput{}) if err != nil { - panic(err) + fmt.Println(err) + return } // Print the command IDs and statuses for _, command := range resp.Commands { @@ -377,7 +383,8 @@ func GetCommandInfo(ssmClient *ssm.Client, commandID string) ssmtypes.Command { CommandId: &commandID, }) if err != nil { - panic(err) + fmt.Println(err) + return ssmtypes.Command{} } return resp.Commands[0] } diff --git a/packaging/uniformBuild/commands.go b/packaging/uniformBuild/commands.go index 6a14c2c538..a2f9747ae8 100644 --- a/packaging/uniformBuild/commands.go +++ b/packaging/uniformBuild/commands.go @@ -5,7 +5,7 @@ import ( "strings" ) -const S3_INTEGRATION_BUCKET = "buildenvtesting" +const S3_INTEGRATION_BUCKET = "uniform-build-env-test" func mergeCommands(args ...string) string { return strings.Join(args, "&&") diff --git a/packaging/uniformBuild/uniformBuilder.go b/packaging/uniformBuild/uniformBuilder.go index 6946e77fd9..b8216ef211 100644 --- a/packaging/uniformBuild/uniformBuilder.go +++ b/packaging/uniformBuild/uniformBuilder.go @@ -131,18 +131,17 @@ func main() { var branch string var comment string var accountID string - flag.StringVar(&accountID, "a", "", "accountID") - flag.StringVar(&accountID, "account_id", "", "accountID") flag.StringVar(&repo, "r", "", "repository") flag.StringVar(&repo, "repo", "", "repository") flag.StringVar(&branch, "b", "", "branch") flag.StringVar(&branch, "branch", "", "branch") flag.StringVar(&comment, "c", "", "comment") flag.StringVar(&comment, "comment", "", "comment") - + flag.StringVar(&accountID, "a", "", "accountID") + flag.StringVar(&accountID, "account_id", "", "accountID") flag.Parse() rbm := CreateRemoteBuildManager(DEFAULT_INSTANCE_GUIDE, accountID) - defer rbm.Close() + //defer rbm.Close() err := rbm.BuildCWAAgent(repo, branch, comment, "MainBuildEnv") if err != nil { panic(err)