Skip to content

Commit

Permalink
Merge pull request #823 from negz/release-0.18-rt-0.13.1
Browse files Browse the repository at this point in the history
[release-0.18] Bump crossplane-runtime to v0.13.1
  • Loading branch information
negz committed Sep 8, 2021
2 parents ffdde1d + 33a3f79 commit bdc9d0f
Show file tree
Hide file tree
Showing 48 changed files with 73 additions and 187 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ PROJECT_NAME := provider-aws
PROJECT_REPO := github.com/crossplane/$(PROJECT_NAME)

PLATFORMS ?= linux_amd64 linux_arm64

# kind-related versions
KIND_VERSION ?= v0.11.1
KIND_NODE_IMAGE_TAG ?= v1.19.11

# -include will silently skip missing files, which allows us
# to load those files with a target in the Makefile. If only
# "include" was used, the make command would fail and refuse
Expand Down Expand Up @@ -94,7 +99,7 @@ e2e.run: test-integration
# Run integration tests.
test-integration: $(KIND) $(KUBECTL) $(HELM3)
@$(INFO) running integration tests using kind $(KIND_VERSION)
@$(ROOT_DIR)/cluster/local/integration_tests.sh || $(FAIL)
@KIND_NODE_IMAGE_TAG=${KIND_NODE_IMAGE_TAG} $(ROOT_DIR)/cluster/local/integration_tests.sh || $(FAIL)
@$(OK) integration tests passed

# Update the submodules, such as the common build scripts.
Expand Down
155 changes: 18 additions & 137 deletions cluster/local/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,103 +32,6 @@ echo_error(){
exit 1
}

# k8s watchers

wait_for_pods_in_namespace(){
local timeout=$1
shift
namespace=$1
shift
arr=("$@")
local counter=0
for i in "${arr[@]}";
do
echo -n "waiting for pod $i in namespace $namespace..." >&2
while ! ("${KUBECTL}" -n $namespace get pod $i) &>/dev/null; do
if [ "$counter" -ge "$timeout" ]; then echo "TIMEOUT"; exit -1; else (( counter+=5 )); fi
echo -n "." >&2
sleep 5
done
echo "FOUND POD!" >&2
done
}

check_deployments(){
for name in $1; do
echo_sub_step "inspecting deployment '${name}'"
local dep_stat=$("${KUBECTL}" -n "$2" get deployments/"${name}")

echo_info "check if is deployed"
if $(echo "$dep_stat" | grep -iq 'No resources found'); then
echo "is not deployed"
exit -1
else
echo_step_completed
fi

echo_info "check if is ready"
IFS='/' read -ra ready_status_parts <<< "$(echo "$dep_stat" | awk ' FNR > 1 {print $2}')"
if (("${ready_status_parts[0]}" < "${ready_status_parts[1]}")); then
echo "is not Ready"
exit -1
else
echo_step_completed
fi
echo
done
}

check_pods(){
pods=$("${KUBECTL}" -n "${CROSSPLANE_NAMESPACE}" get pods)
count=$(echo "$pods" | wc -l)
if (("${count}"-1 != "${1}")); then
sleep 10
"${KUBECTL}" get events -A
sleep 20
echo_error "unexpected number of pods"
exit -1
fi
echo "$pods"
while read -r pod_stat; do
name=$(echo "$pod_stat" | awk '{print $1}')
echo_sub_step "inspecting pod '${name}'"

if $(echo "$pod_stat" | awk '{print $3}' | grep -ivq 'Completed'); then
echo_info "is not completed, continuing with further checks"
else
echo_info "is completed, foregoing further checks"
echo_step_completed
continue
fi

echo_info "check if is ready"
IFS='/' read -ra ready_status_parts <<< "$(echo "$pod_stat" | awk '{print $2}')"
if (("${ready_status_parts[0]}" < "${ready_status_parts[1]}")); then
echo_error "is not ready"
exit -1
else
echo_step_completed
fi

echo_info "check if is running"
if $(echo "$pod_stat" | awk '{print $3}' | grep -ivq 'Running'); then
echo_error "is not running"
exit -1
else
echo_step_completed
fi

echo_info "check if has restarts"
if (( $(echo "$pod_stat" | awk '{print $4}') > 0 )); then
echo_error "has restarts"
exit -1
else
echo_step_completed
fi
echo
done <<< "$(echo "$pods" | awk 'FNR>1')"
}

# ------------------------------
projectdir="$( cd "$( dirname "${BASH_SOURCE[0]}")"/../.. && pwd )"

Expand Down Expand Up @@ -168,7 +71,8 @@ echo "created cache dir at ${CACHE_PATH}"
docker save "${BUILD_IMAGE}" -o "${CACHE_PATH}/${PACKAGE_NAME}.xpkg" && chmod 644 "${CACHE_PATH}/${PACKAGE_NAME}.xpkg"

# create kind cluster with extra mounts
echo_step "creating k8s cluster using kind"
KIND_NODE_IMAGE="kindest/node:${KIND_NODE_IMAGE_TAG}"
echo_step "creating k8s cluster using kind ${KIND_VERSION} and node image ${KIND_NODE_IMAGE}"
KIND_CONFIG="$( cat <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
Expand All @@ -179,17 +83,12 @@ nodes:
containerPath: /cache
EOF
)"
echo "${KIND_CONFIG}" | "${KIND}" create cluster --name="${K8S_CLUSTER}" --config=-
echo "${KIND_CONFIG}" | "${KIND}" create cluster --name="${K8S_CLUSTER}" --wait=5m --image="${KIND_NODE_IMAGE}" --config=-

# tag controller image and load it into kind cluster
docker tag "${CONTROLLER_IMAGE}" "${PACKAGE_CONTROLLER_IMAGE}"
"${KIND}" load docker-image "${PACKAGE_CONTROLLER_IMAGE}" --name="${K8S_CLUSTER}"

# wait for kind pods
echo_step "wait for kind pods"
kindpods=("kube-apiserver-${BUILD_REGISTRY}-inttests-control-plane" "kube-controller-manager-${BUILD_REGISTRY}-inttests-control-plane" "kube-scheduler-${BUILD_REGISTRY}-inttests-control-plane")
wait_for_pods_in_namespace 120 "kube-system" "${kindpods[@]}"

# files are not synced properly from host to kind node container on Jenkins, so
# we must manually copy image from host to node
echo_step "pre-cache package by copying to kind node"
Expand Down Expand Up @@ -244,28 +143,10 @@ echo_info "using crossplane version ${chart_version}"
echo
# we replace empty dir with our PVC so that the /cache dir in the kind node
# container is exposed to the crossplane pod
"${HELM3}" install crossplane --namespace crossplane-system crossplane-master/crossplane --version ${chart_version} --devel --set packageCache.pvc=package-cache

echo_step "waiting for deployment crossplane rollout to finish"
"${KUBECTL}" -n "${CROSSPLANE_NAMESPACE}" rollout status "deploy/crossplane" --timeout=2m

echo_step "wait until the pods are up and running"
"${KUBECTL}" -n "${CROSSPLANE_NAMESPACE}" wait --for=condition=Ready pods --all --timeout=1m
"${HELM3}" install crossplane --namespace crossplane-system crossplane-master/crossplane --version ${chart_version} --devel --wait --set packageCache.pvc=package-cache

# ----------- integration tests
echo_step "--- INTEGRATION TESTS ---"
echo
echo_step "check for necessary deployment statuses"
echo
echo -------- deployments
"${KUBECTL}" -n "${CROSSPLANE_NAMESPACE}" get deployments

check_deployments "crossplane" "${CROSSPLANE_NAMESPACE}"

echo_step "check for crossplane pods statuses"
echo
echo "--- pods ---"
check_pods 2

# install package
echo_step "installing ${PROJECT_NAME} into \"${CROSSPLANE_NAMESPACE}\" namespace"
Expand All @@ -283,29 +164,29 @@ EOF

echo "${INSTALL_YAML}" | "${KUBECTL}" apply -f -

"${KUBECTL}" -n "${CROSSPLANE_NAMESPACE}" get deployments

# this is to let package manager unpack pods and start the controller.
sleep 20

# printing the cache dir contents can be useful for troubleshooting failures
echo_step "check kind node cache dir contents"
docker exec "${K8S_CLUSTER}-control-plane" ls -la /cache

echo_step "check for package pod statuses"
echo
echo "--- pods ---"
check_pods 3
echo_step "waiting for provider to be installed"

kubectl wait "provider.pkg.crossplane.io/${PACKAGE_NAME}" --for=condition=healthy --timeout=60s

echo_step "uninstalling ${PROJECT_NAME}"

echo "${INSTALL_YAML}" | "${KUBECTL}" delete -f -

# check pods deleted
sleep 60
echo_step "check only crossplane pods remain"
echo "--- pods ---"
"${KUBECTL}" -n "${CROSSPLANE_NAMESPACE}" get pods
check_pods 2
timeout=60
current=0
step=3
while [[ $(kubectl get providerrevision.pkg.crossplane.io -o name | wc -l) != "0" ]]; do
echo "waiting for provider to be deleted for another $step seconds"
current=$current+$step
if ! [[ $timeout > $current ]]; then
echo_error "timeout of ${timeout}s has been reached"
fi
sleep $step;
done

echo_success "Integration tests succeeded!"
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.13
require (
github.com/aws/aws-sdk-go v1.37.4
github.com/aws/aws-sdk-go-v2 v0.23.0
github.com/crossplane/crossplane-runtime v0.13.0
github.com/crossplane/crossplane-runtime v0.13.1
github.com/crossplane/crossplane-tools v0.0.0-20210320162312-1baca298c527
github.com/evanphx/json-patch v4.9.0+incompatible
github.com/go-ini/ini v1.46.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/crossplane/crossplane-runtime v0.13.0 h1:TFeItxtW32/fETB9be0AsEha/ur0bbrtQRocC+Jd6RI=
github.com/crossplane/crossplane-runtime v0.13.0/go.mod h1:Bc54/KBvV9ld/tvervcnhcSzk13FYguTqmYt72Mybps=
github.com/crossplane/crossplane-runtime v0.13.1 h1:7KKErtwSs3hbY/6zLPV2O+iDnWByGy+1OW06jx+UuSo=
github.com/crossplane/crossplane-runtime v0.13.1/go.mod h1:Bc54/KBvV9ld/tvervcnhcSzk13FYguTqmYt72Mybps=
github.com/crossplane/crossplane-tools v0.0.0-20210320162312-1baca298c527 h1:9M6hMLKqjxtL9d9nwfcaAt59Ey0CPfSXQ3iIdYRUNaE=
github.com/crossplane/crossplane-tools v0.0.0-20210320162312-1baca298c527/go.mod h1:C735A9X0x0lR8iGVOOxb49Mt70Ua4EM2b7PGaRPBLd4=
github.com/dave/jennifer v1.3.0 h1:p3tl41zjjCZTNBytMwrUuiAnherNUZktlhPTKoF/sEk=
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/acm/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (e *external) Create(ctx context.Context, mgd resource.Managed) (managed.Ex
return managed.ExternalCreation{}, awsclient.Wrap(err, errCreate)
}
meta.SetExternalName(cr, aws.StringValue(response.RequestCertificateOutput.CertificateArn))
return managed.ExternalCreation{ExternalNameAssigned: true}, nil
return managed.ExternalCreation{}, nil

}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/acm/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func TestCreate(t *testing.T) {
want: want{
cr: certificate(
withDomainName()),
result: managed.ExternalCreation{ExternalNameAssigned: true},
result: managed.ExternalCreation{},
},
},
"InValidInput": {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/acmpca/certificateauthority/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (e *external) Create(ctx context.Context, mgd resource.Managed) (managed.Ex
return managed.ExternalCreation{}, awsclient.Wrap(err, errCreate)
}
meta.SetExternalName(cr, aws.StringValue(response.CreateCertificateAuthorityOutput.CertificateAuthorityArn))
return managed.ExternalCreation{ExternalNameAssigned: true}, nil
return managed.ExternalCreation{}, nil

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func TestCreate(t *testing.T) {
},
want: want{
cr: certificateAuthority(withCertificateAuthorityArn()),
result: managed.ExternalCreation{ExternalNameAssigned: true},
result: managed.ExternalCreation{},
},
},
"InValidInput": {
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/apigatewayv2/api/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func postCreate(_ context.Context, cr *svcapitypes.API, resp *svcsdk.CreateApiOu
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, aws.StringValue(resp.ApiId))
cre.ExternalNameAssigned = true
return cre, nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/apigatewayv2/apimapping/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func postCreate(_ context.Context, cr *svcapitypes.APIMapping, resp *svcsdk.Crea
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, aws.StringValue(resp.ApiMappingId))
cre.ExternalNameAssigned = true
return cre, nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/apigatewayv2/authorizer/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func postCreate(_ context.Context, cr *svcapitypes.Authorizer, resp *svcsdk.Crea
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, aws.StringValue(resp.AuthorizerId))
cre.ExternalNameAssigned = true
return cre, err
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/apigatewayv2/deployment/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func postCreate(_ context.Context, cr *svcapitypes.Deployment, resp *svcsdk.Crea
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, aws.StringValue(resp.DeploymentId))
cre.ExternalNameAssigned = true
return cre, nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/apigatewayv2/integration/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func postCreate(_ context.Context, cr *svcapitypes.Integration, resp *svcsdk.Cre
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, aws.StringValue(resp.IntegrationId))
cre.ExternalNameAssigned = true
return cre, nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/apigatewayv2/integrationresponse/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func postCreate(_ context.Context, cr *svcapitypes.IntegrationResponse, resp *sv
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, aws.StringValue(resp.IntegrationResponseId))
cre.ExternalNameAssigned = true
return cre, nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/apigatewayv2/model/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ func postCreate(_ context.Context, cr *svcapitypes.Model, resp *svcsdk.CreateMod
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, aws.StringValue(resp.ModelId))
cre.ExternalNameAssigned = true
return cre, nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/apigatewayv2/route/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func postCreate(_ context.Context, cr *svcapitypes.Route, res *svcsdk.CreateRout
// NOTE(muvaf): Route ID is chosen as external name since it's the only unique
// identifier.
meta.SetExternalName(cr, aws.StringValue(res.RouteId))
cre.ExternalNameAssigned = true
return cre, nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/apigatewayv2/routeresponse/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func postCreate(_ context.Context, cr *svcapitypes.RouteResponse, resp *svcsdk.C
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, aws.StringValue(resp.RouteResponseId))
cre.ExternalNameAssigned = true
return cre, nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/apigatewayv2/vpclink/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func postCreate(_ context.Context, cr *svcapitypes.VPCLink, resp *svcsdk.CreateV
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, aws.StringValue(resp.VpcLinkId))
cre.ExternalNameAssigned = true
return cre, nil
}

Expand Down
1 change: 0 additions & 1 deletion pkg/controller/dynamodb/backup/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ func postCreate(_ context.Context, cr *svcapitypes.Backup, resp *svcsdk.CreateBa
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, aws.StringValue(resp.BackupDetails.BackupArn))
cre.ExternalNameAssigned = true
return cre, err
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/controller/ec2/address/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package address
import (
"context"
"sort"
"time"

"github.com/aws/aws-sdk-go-v2/aws"
awsec2 "github.com/aws/aws-sdk-go-v2/service/ec2"
Expand Down Expand Up @@ -66,6 +67,7 @@ func SetupAddress(mgr ctrl.Manager, l logging.Logger, rl workqueue.RateLimiter)
Complete(managed.NewReconciler(mgr,
resource.ManagedKind(v1beta1.AddressGroupVersionKind),
managed.WithExternalConnecter(&connector{kube: mgr.GetClient()}),
managed.WithCreationGracePeriod(3*time.Minute),
managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())),
managed.WithConnectionPublishers(),
managed.WithInitializers(managed.NewDefaultProviderConfig(mgr.GetClient()), &tagger{kube: mgr.GetClient()}),
Expand Down Expand Up @@ -174,7 +176,7 @@ func (e *external) Create(ctx context.Context, mgd resource.Managed) (managed.Ex
} else {
meta.SetExternalName(cr, aws.StringValue(result.AllocateAddressOutput.AllocationId))
}
return managed.ExternalCreation{ExternalNameAssigned: true}, nil
return managed.ExternalCreation{}, nil
}

func (e *external) Update(ctx context.Context, mgd resource.Managed) (managed.ExternalUpdate, error) {
Expand Down
Loading

0 comments on commit bdc9d0f

Please sign in to comment.