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

🐛 Update packngo calls #377

Merged
merged 5 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ E2E_DIR ?= $(REPO_ROOT)/test/e2e
KUBETEST_CONF_PATH ?= $(abspath $(E2E_DIR)/data/kubetest/conformance.yaml)
E2E_CONF_FILE_SOURCE ?= $(E2E_DIR)/config/packet-ci.yaml
E2E_CONF_FILE ?= $(E2E_DIR)/config/packet-ci-envsubst.yaml
E2E_LD_FLAGS ?= "-X 'sigs.k8s.io/cluster-api-provider-packet/pkg/cloud/packet.clientName=capp-e2e' -X 'sigs.k8s.io/cluster-api-provider-packet/pkg/cloud/packet.clientUAFormat=capp-e2e/%s %s'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could use GINKGO_ADDITIONAL_ARGS for this.


.PHONY: $(E2E_CONF_FILE)
$(E2E_CONF_FILE): $(ENVSUBST) $(E2E_CONF_FILE_SOURCE)
Expand All @@ -159,6 +160,7 @@ run-e2e-tests: $(KUBECTL) $(KUSTOMIZE) $(KIND) $(GINKGO) $(E2E_CONF_FILE) e2e-te
$(MAKE) set-manifest-image MANIFEST_IMG=$(REGISTRY)/$(IMAGE_NAME) MANIFEST_TAG=$(TAG)
$(MAKE) set-manifest-pull-policy PULL_POLICY=IfNotPresent
cd test/e2e; time $(GINKGO) -v -trace -progress -v -tags=e2e \
-ldflags $(E2E_LD_FLAGS) \
--randomizeAllSpecs -race $(GINKGO_ADDITIONAL_ARGS) \
-focus=$(GINKGO_FOCUS) -skip=$(GINKGO_SKIP) \
-nodes=$(GINKGO_NODES) --noColor=$(GINKGO_NOCOLOR) \
Expand Down
4 changes: 2 additions & 2 deletions pkg/cloud/packet/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ import (

const (
apiTokenVarName = "PACKET_API_KEY" //nolint:gosec
clientName = "CAPP-v1beta1"
clientUAFormat = "cluster-api-provider-packet/%s %s"
ipxeOS = "custom_ipxe"
envVarLocalASN = "METAL_LOCAL_ASN"
envVarBGPPass = "METAL_BGP_PASS" //nolint:gosec
DefaultLocalASN = 65000
)

var (
clientName = "CAPP-v1beta1"
clientUAFormat = "cluster-api-provider-packet/%s %s"
ErrControlPlanEndpointNotFound = errors.New("control plane not found")
ErrElasticIPQuotaExceeded = errors.New("could not create an Elastic IP due to quota limits on the account, please contact Equinix Metal support")
ErrInvalidIP = errors.New("invalid IP")
Expand Down
8 changes: 3 additions & 5 deletions test/e2e/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
"sigs.k8s.io/cluster-api-provider-packet/pkg/cloud/packet"
"sigs.k8s.io/cluster-api-provider-packet/version"
clusterv1old "sigs.k8s.io/cluster-api/api/v1alpha3"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/test/framework"
Expand Down Expand Up @@ -210,8 +209,7 @@ func (w *wrappedClusterProxy) Dispose(ctx context.Context) {
metalAuthToken := os.Getenv(AuthTokenEnvVar)
metalProjectID := os.Getenv(ProjectIDEnvVar)
if metalAuthToken != "" && metalProjectID != "" {
metal := packet.NewClientWithAuth(clientName, metalAuthToken)
metal.UserAgent = fmt.Sprintf("capp-e2e/%s %s", version.Version, metalClient.UserAgent)
metalClient := packet.NewClient(metalAuthToken)

Eventually(func(g Gomega) {
clusterNames := w.clusterNames.UnsortedList()
Expand All @@ -222,7 +220,7 @@ func (w *wrappedClusterProxy) Dispose(ctx context.Context) {

g.Eventually(func(g Gomega) {
var err error
ip, err = metal.GetIPByClusterIdentifier("", clusterName, metalProjectID)
ip, err = metalClient.GetIPByClusterIdentifier("", clusterName, metalProjectID)
g.Expect(err).To(SatisfyAny(Not(HaveOccurred()), MatchError(packet.ErrControlPlanEndpointNotFound)))
}, "5m", "10s").Should(Succeed())

Expand All @@ -231,7 +229,7 @@ func (w *wrappedClusterProxy) Dispose(ctx context.Context) {
logf("Deleting EIP with ID: %s, for cluster: %s", ip.ID, clusterName)

g.Eventually(func(g Gomega) {
_, err := metal.ProjectIPs.Remove(ip.ID)
_, err := metalClient.ProjectIPs.Remove(ip.ID)
Expect(err).NotTo(HaveOccurred())
}, "5m", "10s").Should(Succeed())

Expand Down
8 changes: 3 additions & 5 deletions test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import (
"sigs.k8s.io/cluster-api/util"

"sigs.k8s.io/cluster-api-provider-packet/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-packet/version"
"sigs.k8s.io/cluster-api-provider-packet/pkg/cloud/packet"
)

const (
Expand Down Expand Up @@ -179,8 +179,7 @@ var _ = SynchronizedAfterSuite(func() {
metalAuthToken := os.Getenv(AuthTokenEnvVar)
if metalAuthToken != "" && sshKeyID != "" {
By("Cleaning up the generated SSH Key")
metalClient := packngo.NewClientWithAuth("capp-e2e", metalAuthToken, nil)
metalClient.UserAgent = fmt.Sprintf("capp-e2e/%s %s", version.Version, metalClient.UserAgent)
metalClient := packet.NewClient(metalAuthToken)
_, err := metalClient.SSHKeys.Delete(sshKeyID)
Expect(err).NotTo(HaveOccurred())
}
Expand Down Expand Up @@ -288,8 +287,7 @@ func generateSSHKey() (string, string) {
pub, err := ssh.NewPublicKey(&privateKey.PublicKey)
Expect(err).NotTo(HaveOccurred())

metalClient := packngo.NewClientWithAuth("capp-e2e", metalAuthToken, nil)
metalClient.UserAgent = fmt.Sprintf("capp-e2e/%s %s", version.Version, metalClient.UserAgent)
metalClient := packet.NewClient(metalAuthToken)
res, _, err := metalClient.SSHKeys.Create(
&packngo.SSHKeyCreateRequest{
Label: fmt.Sprintf("capp-e2e-%s", util.RandomString(6)),
Expand Down
12 changes: 6 additions & 6 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
)

var (
gitMajor string // major version, always numeric
gitMinor string // minor version, numeric possibly followed by "+"
gitVersion string // semantic version, derived by build scripts
gitCommit string // sha1 from git, output of $(git rev-parse HEAD)
gitTreeState string // state of git tree, either "clean" or "dirty"
buildDate string // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
gitMajor string // major version, always numeric
gitMinor string // minor version, numeric possibly followed by "+"
gitVersion = "dev" // semantic version, derived by build scripts
gitCommit string // sha1 from git, output of $(git rev-parse HEAD)
gitTreeState string // state of git tree, either "clean" or "dirty"
buildDate string // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
)

// Info contains all version-related information.
Expand Down