Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eksctl: simplify binary build #207468

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

alexandear
Copy link
Contributor

  • Have you followed the guidelines for contributing?
  • Have you ensured that your commits follow the commit style guide?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing HOMEBREW_NO_INSTALL_FROM_API=1 brew install --build-from-source <formula>)? If this is a new formula, does it pass brew audit --new <formula>?

This PR resolves building eksctl with Go 1.24, see #201070:

eksctl: build failure: internal error: package "fmt" without types was imported from "github.com/aws/aws-sdk-go/aws/client"

Explanation

Short

The problem lies in generating test mocks using mockery. However, these mocks are already checked out in the repo, and we don't need them for the eksctl binary. We can just call make binary that will produce our binary.

Error Details

Running locally with Go 1.24 gives us an error when executing mockery:

❯ make generate-always
go generate ./pkg/apis/eksctl.io/v1alpha5/generate.go
Writing docs schema to assets/schema.json
go generate ./pkg/nodebootstrap
Writing `FakeBootstrapper` to `fakes/fake_bootstrapper.go`... Done
go generate ./pkg/addons
go generate ./pkg/authconfigmap
go generate ./pkg/awsapi/...
+ '[' 2 -eq 2 ']'
+ SERVICE_NAME=autoscaling
+ INTERFACE_NAME=ASG
+ PACKAGE_NAME=github.com/aws/aws-sdk-go-v2/service/autoscaling
+ go get github.com/aws/aws-sdk-go-v2/service/autoscaling
++ go list -m -f '{{.Dir}}' github.com/aws/aws-sdk-go-v2/service/autoscaling
+ AWS_SDK_DIR=/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]
+ /Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/bin/ifacemaker -f '/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/*.go' -s Client -i ASG -p awsapi -y 'ASG provides an interface to the AWS ASG service.' -c 'Code generated by ifacemaker; DO NOT EDIT.' -m github.com/aws/aws-sdk-go-v2/service/autoscaling
+ '[' 2 -eq 2 ']'
+ SERVICE_NAME=cloudwatchlogs
+ INTERFACE_NAME=CloudWatchLogs
+ PACKAGE_NAME=github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs
+ go get github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs
++ go list -m -f '{{.Dir}}' github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs
+ AWS_SDK_DIR=/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]
+ /Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/bin/ifacemaker -f '/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/*.go' -s Client -i CloudWatchLogs -p awsapi -y 'CloudWatchLogs provides an interface to the AWS CloudWatchLogs service.' -c 'Code generated by ifacemaker; DO NOT EDIT.' -m github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs
+ '[' 2 -eq 2 ']'
+ SERVICE_NAME=cloudformation
+ INTERFACE_NAME=CloudFormation
+ PACKAGE_NAME=github.com/aws/aws-sdk-go-v2/service/cloudformation
+ go get github.com/aws/aws-sdk-go-v2/service/cloudformation
++ go list -m -f '{{.Dir}}' github.com/aws/aws-sdk-go-v2/service/cloudformation
+ AWS_SDK_DIR=/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]
+ /Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/bin/ifacemaker -f '/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/*.go' -s Client -i CloudFormation -p awsapi -y 'CloudFormation provides an interface to the AWS CloudFormation service.' -c 'Code generated by ifacemaker; DO NOT EDIT.' -m github.com/aws/aws-sdk-go-v2/service/cloudformation
+ '[' 2 -eq 2 ']'
+ SERVICE_NAME=cloudtrail
+ INTERFACE_NAME=CloudTrail
+ PACKAGE_NAME=github.com/aws/aws-sdk-go-v2/service/cloudtrail
+ go get github.com/aws/aws-sdk-go-v2/service/cloudtrail
++ go list -m -f '{{.Dir}}' github.com/aws/aws-sdk-go-v2/service/cloudtrail
+ AWS_SDK_DIR=/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]
+ /Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/bin/ifacemaker -f '/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/*.go' -s Client -i CloudTrail -p awsapi -y 'CloudTrail provides an interface to the AWS CloudTrail service.' -c 'Code generated by ifacemaker; DO NOT EDIT.' -m github.com/aws/aws-sdk-go-v2/service/cloudtrail
+ '[' 2 -eq 2 ']'
+ SERVICE_NAME=elasticloadbalancing
+ INTERFACE_NAME=ELB
+ PACKAGE_NAME=github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing
+ go get github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing
++ go list -m -f '{{.Dir}}' github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing
+ AWS_SDK_DIR=/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]
+ /Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/bin/ifacemaker -f '/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/*.go' -s Client -i ELB -p awsapi -y 'ELB provides an interface to the AWS ELB service.' -c 'Code generated by ifacemaker; DO NOT EDIT.' -m github.com/aws/aws-sdk-go-v2/service/elasticloadbalancing
+ '[' 2 -eq 2 ']'
+ SERVICE_NAME=elasticloadbalancingv2
+ INTERFACE_NAME=ELBV2
+ PACKAGE_NAME=github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2
+ go get github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2
++ go list -m -f '{{.Dir}}' github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2
+ AWS_SDK_DIR=/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]
+ /Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/bin/ifacemaker -f '/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/*.go' -s Client -i ELBV2 -p awsapi -y 'ELBV2 provides an interface to the AWS ELBV2 service.' -c 'Code generated by ifacemaker; DO NOT EDIT.' -m github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2
+ '[' 2 -eq 2 ']'
+ SERVICE_NAME=ssm
+ INTERFACE_NAME=SSM
+ PACKAGE_NAME=github.com/aws/aws-sdk-go-v2/service/ssm
+ go get github.com/aws/aws-sdk-go-v2/service/ssm
++ go list -m -f '{{.Dir}}' github.com/aws/aws-sdk-go-v2/service/ssm
+ AWS_SDK_DIR=/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]
+ /Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/bin/ifacemaker -f '/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/*.go' -s Client -i SSM -p awsapi -y 'SSM provides an interface to the AWS SSM service.' -c 'Code generated by ifacemaker; DO NOT EDIT.' -m github.com/aws/aws-sdk-go-v2/service/ssm
+ '[' 2 -eq 2 ']'
+ SERVICE_NAME=iam
+ INTERFACE_NAME=IAM
+ PACKAGE_NAME=github.com/aws/aws-sdk-go-v2/service/iam
+ go get github.com/aws/aws-sdk-go-v2/service/iam
++ go list -m -f '{{.Dir}}' github.com/aws/aws-sdk-go-v2/service/iam
+ AWS_SDK_DIR=/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]
+ /Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/bin/ifacemaker -f '/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/*.go' -s Client -i IAM -p awsapi -y 'IAM provides an interface to the AWS IAM service.' -c 'Code generated by ifacemaker; DO NOT EDIT.' -m github.com/aws/aws-sdk-go-v2/service/iam
+ '[' 2 -eq 2 ']'
+ SERVICE_NAME=eks
+ INTERFACE_NAME=EKS
+ PACKAGE_NAME=github.com/aws/aws-sdk-go-v2/service/eks
+ go get github.com/aws/aws-sdk-go-v2/service/eks
++ go list -m -f '{{.Dir}}' github.com/aws/aws-sdk-go-v2/service/eks
+ AWS_SDK_DIR=/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]
+ /Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/bin/ifacemaker -f '/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/*.go' -s Client -i EKS -p awsapi -y 'EKS provides an interface to the AWS EKS service.' -c 'Code generated by ifacemaker; DO NOT EDIT.' -m github.com/aws/aws-sdk-go-v2/service/eks
+ '[' 2 -eq 2 ']'
+ SERVICE_NAME=outposts
+ INTERFACE_NAME=Outposts
+ PACKAGE_NAME=github.com/aws/aws-sdk-go-v2/service/outposts
+ go get github.com/aws/aws-sdk-go-v2/service/outposts
++ go list -m -f '{{.Dir}}' github.com/aws/aws-sdk-go-v2/service/outposts
+ AWS_SDK_DIR=/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]
+ /Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/bin/ifacemaker -f '/Users/Oleksandr_Redko/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/[email protected]/*.go' -s Client -i Outposts -p awsapi -y 'Outposts provides an interface to the AWS Outposts service.' -c 'Code generated by ifacemaker; DO NOT EDIT.' -m github.com/aws/aws-sdk-go-v2/service/outposts
go generate ./pkg/eks

WARNING: Invoking counterfeiter multiple times from "go generate" is slow.
Consider using counterfeiter:generate directives to speed things up.
See https://github.com/maxbrunsfeld/counterfeiter#step-2b---add-counterfeitergenerate-directives for more information.
Set the "COUNTERFEITER_NO_GENERATE_WARNING" environment variable to suppress this message.

Writing `FakeKubeProvider` to `fakes/fake_kube_provider.go`... Done
Writing `FakeAWSConfigurationLoader` to `fakes/fake_configuration_loader.go`... Done
Writing `FakeFargateClient` to `fakes/fargate_client.go`... Done
Writing `FakeInstanceSelector` to `fakes/fake_instance_selector.go`... Done
Writing `FakeClusterVersionsManagerInterface` to `fakes/fake_cluster_versions_manager.go`... Done
Writing `FakeAWSConfigurationLoader` to `fakes/fake_configuration_loader.go`... Done
Writing `FakeFargateClient` to `fakes/fargate_client.go`... Done
Writing `FakeInstanceSelector` to `fakes/fake_instance_selector.go`... Done
Writing `FakeClusterVersionsManagerInterface` to `fakes/fake_cluster_versions_manager.go`... Done
/Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/bin/mockery
12 Feb 25 22:47 EET INF Starting mockery dry-run=false version=v2.38.0
12 Feb 25 22:47 EET INF Using config: /Users/Oleksandr_Redko/src/github.com/eksctl-io/eksctl/.mockery.yaml dry-run=false version=v2.38.0
2025/02/12 22:47:33 internal error: package "fmt" without types was imported from "github.com/aws/aws-sdk-go/aws/client"
make: *** [Makefile:149: generate-always] Error 1

Long

make build calls the generate-always and binary targets.

make generate-always generates documentation, test doubles, fakes, interfaces, mocks, etc. All of this is already checked out into the repo and is usually generated during development. generate-always for code generation uses the counterfeiter, ifacemaker, and mockery tools which are defined by this formula. go-bindata is not used and was removed by eksctl-io/eksctl#4370.

make binary is our target that builds the binary. Since generated files are already in the repo, we don't need to re-generate them again.

@github-actions github-actions bot added the go Go use is a significant feature of the PR or issue label Feb 12, 2025
@stefanb
Copy link
Member

stefanb commented Feb 12, 2025

If this should fix compatibility with Go 1.24 we should wait for merging

Then rebase this and see if it still works.

If it won't work we can still use

@stefanb
Copy link
Member

stefanb commented Feb 12, 2025

In any case, if generated files are in git it makes no sense to regenerate them, unless they would be intentionally generated differently.

@alexandear
Copy link
Contributor Author

If this should fix compatibility with Go 1.24 we should wait for merging

Actually, this PR simplifies and speeds up the build for Go 1.23 as well.

@stefanb stefanb force-pushed the eksctl-simplify-build branch from a83b440 to 2285d2a Compare February 13, 2025 05:10
@stefanb stefanb added the ready to merge PR can be merged once CI is green label Feb 13, 2025
Copy link
Contributor

🤖 An automated task has requested bottles to be published to this PR.

@github-actions github-actions bot added the CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. label Feb 13, 2025
@BrewTestBot BrewTestBot added this pull request to the merge queue Feb 13, 2025
Merged via the queue into Homebrew:master with commit 5625a82 Feb 13, 2025
15 checks passed
@alexandear alexandear deleted the eksctl-simplify-build branch February 13, 2025 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI-published-bottle-commits The commits for the built bottles have been pushed to the PR branch. go Go use is a significant feature of the PR or issue ready to merge PR can be merged once CI is green
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants