Skip to content

Commit

Permalink
Merge branch 'main' into requeue-vpc
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Mendoza committed May 1, 2024
2 parents 1c379da + 2f81203 commit 126435a
Show file tree
Hide file tree
Showing 68 changed files with 1,835 additions and 583 deletions.
25 changes: 22 additions & 3 deletions .github/workflows/build_test_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ jobs:
needs: [go-build-test, docker-build]
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2
Expand All @@ -85,6 +88,7 @@ jobs:
api.github.com:443
github.com:443
gcr.io:443
ghcr.io:443
proxy.golang.org:443
sum.golang.org:443
*.githubusercontent.com:443
Expand All @@ -103,6 +107,8 @@ jobs:
cloud.tilt.dev:443
kubernetes-sigs.github.io:443
charts.jetstack.io:443
helm.cilium.io:443
linode.github.io:443
- uses: actions/checkout@v4

Expand All @@ -117,11 +123,24 @@ jobs:
with:
key: docker-${{ runner.os }}-${{ hashFiles('go.sum') }}

- name: E2E test
- name: Complete E2E Test
if: github.ref == 'refs/heads/main'
run: make e2etest
env:
GITHUB_TOKEN: ${{ secrets.github_token }}
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
E2E_FLAGS: '--assert-timeout 15m0s'
INSTALL_K3S_PROVIDER: true
INSTALL_RKE2_PROVIDER: true
LINODE_REGION: us-sea
LINODE_CONTROL_PLANE_MACHINE_TYPE: g6-standard-2
LINODE_MACHINE_TYPE: g6-standard-2
CLUSTERCTL_CONFIG: /home/runner/work/cluster-api-provider-linode/cluster-api-provider-linode/e2e/gha-clusterctl-config.yaml


- name: Quick E2E Test
if: github.ref != 'refs/heads/main'
run: make e2etest
env:
E2E_FLAGS: '--selector quick'

- name: Copy logs
if: ${{ always() }}
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ test: generate fmt vet envtest ## Run tests.
rm cover.out.tmp

.PHONY: e2etest
e2etest: generate local-deploy chainsaw
GIT_REF=$(GIT_REF) $(CHAINSAW) test ./e2e
e2etest: generate local-release local-deploy chainsaw
GIT_REF=$(GIT_REF) $(CHAINSAW) test ./e2e $(E2E_FLAGS)

local-deploy: kind ctlptl tilt kustomize clusterctl
@echo -n "LINODE_TOKEN=$(LINODE_TOKEN)" > config/default/.env.linode
Expand Down
3 changes: 3 additions & 0 deletions cloud/scope/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ type LinodeInstanceClient interface {
// LinodeVPCClient defines the methods that a Linode client must have to interact with Linode's VPC service.
type LinodeVPCClient interface {
GetVPC(ctx context.Context, vpcID int) (*linodego.VPC, error)
ListVPCs(ctx context.Context, opts *linodego.ListOptions) ([]linodego.VPC, error)
CreateVPC(ctx context.Context, opts linodego.VPCCreateOptions) (*linodego.VPC, error)
DeleteVPC(ctx context.Context, vpcID int) error
}

// LinodeNodeBalancerClient defines the methods that a Linode client must have to interact with Linode's Node Balancer service.
Expand Down
7 changes: 3 additions & 4 deletions cloud/scope/vpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"errors"
"fmt"

"github.com/linode/linodego"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

Expand All @@ -30,10 +29,10 @@ import (

// VPCScope defines the basic context for an actuator to operate upon.
type VPCScope struct {
client K8sClient
Client K8sClient

PatchHelper *patch.Helper
LinodeClient *linodego.Client
LinodeClient LinodeVPCClient
LinodeVPC *infrav1alpha1.LinodeVPC
}

Expand Down Expand Up @@ -78,7 +77,7 @@ func NewVPCScope(ctx context.Context, apiKey string, params VPCScopeParams) (*VP
}

return &VPCScope{
client: params.Client,
Client: params.Client,
LinodeClient: linodeClient,
LinodeVPC: params.LinodeVPC,
PatchHelper: helper,
Expand Down
8 changes: 4 additions & 4 deletions controller/linodevpc_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ func (r *LinodeVPCReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return ctrl.Result{}, fmt.Errorf("failed to create VPC scope: %w", err)
}

return r.reconcile(ctx, vpcScope, log)
return r.reconcile(ctx, log, vpcScope)
}

func (r *LinodeVPCReconciler) reconcile(
ctx context.Context,
vpcScope *scope.VPCScope,
logger logr.Logger,
vpcScope *scope.VPCScope,
) (res ctrl.Result, err error) {
res = ctrl.Result{}

Expand Down Expand Up @@ -192,7 +192,7 @@ func (r *LinodeVPCReconciler) reconcile(
// Create
failureReason = infrav1alpha1.CreateVPCError

err = r.reconcileCreate(ctx, vpcScope, logger)
err = r.reconcileCreate(ctx, logger, vpcScope)
if err != nil && vpcScope.LinodeVPC.ObjectMeta.CreationTimestamp.Add(reconciler.DefaultVPCControllerReconcileTimeout).After(time.Now()) {
logger.Info("re-queuing VPC creation")

Expand All @@ -203,7 +203,7 @@ func (r *LinodeVPCReconciler) reconcile(
return
}

func (r *LinodeVPCReconciler) reconcileCreate(ctx context.Context, vpcScope *scope.VPCScope, logger logr.Logger) error {
func (r *LinodeVPCReconciler) reconcileCreate(ctx context.Context, logger logr.Logger, vpcScope *scope.VPCScope) error {
logger.Info("creating vpc")

if err := r.reconcileVPC(ctx, vpcScope, logger); err != nil {
Expand Down
Loading

0 comments on commit 126435a

Please sign in to comment.