Skip to content

Commit

Permalink
Merge pull request #713 from weaveworks/fix-adding-finalizer-for-dele…
Browse files Browse the repository at this point in the history
…ted-obj

[v0.14] add finalizer to the dep only if object is not being deleted
  • Loading branch information
Chanwit Kaewkasi authored Jun 28, 2023
2 parents b203174 + 87e2dc1 commit 9424ffa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@ COPY utils/ utils/
# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -gcflags=all="-N -l" -a -o tf-controller cmd/manager/main.go

FROM alpine:3.16.5
FROM alpine:3.18

LABEL org.opencontainers.image.source="https://github.com/weaveworks/tf-controller"

RUN apk add --no-cache ca-certificates tini git openssh-client gnupg && \
RUN apk update

RUN apk add --no-cache libcrypto3=3.1.1-r1 && \
apk add --no-cache libssl3=3.1.1-r1 && \
apk add --no-cache ca-certificates tini git openssh-client gnupg && \
apk add --no-cache libretls && \
apk add --no-cache busybox

Expand Down
4 changes: 2 additions & 2 deletions controllers/tf_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,8 @@ func (r *TerraformReconciler) checkDependencies(source sourcev1.Source, terrafor
return fmt.Errorf("unable to get '%s' dependency: %w", dName, err)
}

// add finalizer to the dependency
if !controllerutil.ContainsFinalizer(&tf, dependantFinalizer) {
// add finalizer to the dependency only if object is not being deleted
if tf.ObjectMeta.DeletionTimestamp.IsZero() && !controllerutil.ContainsFinalizer(&tf, dependantFinalizer) {
patch := client.MergeFrom(tf.DeepCopy())
controllerutil.AddFinalizer(&tf, dependantFinalizer)
if err := r.Patch(context.Background(), &tf, patch, client.FieldOwner(r.statusManager)); err != nil {
Expand Down
8 changes: 6 additions & 2 deletions runner-azure.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ ARG TF_VERSION=1.3.9
ADD https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_${TARGETARCH}.zip /terraform_${TF_VERSION}_linux_${TARGETARCH}.zip
RUN unzip -q /terraform_${TF_VERSION}_linux_${TARGETARCH}.zip

FROM alpine:3.16.5
FROM alpine:3.18

LABEL org.opencontainers.image.source="https://github.com/weaveworks/tf-controller"

RUN apk add --no-cache ca-certificates tini git openssh-client gnupg && \
RUN apk update

RUN apk add --no-cache libcrypto3=3.1.1-r1 && \
apk add --no-cache libssl3=3.1.1-r1 && \
apk add --no-cache ca-certificates tini git openssh-client gnupg && \
apk add --no-cache libretls && \
apk add --no-cache busybox

Expand Down
8 changes: 6 additions & 2 deletions runner.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ ARG TF_VERSION=1.3.9
ADD https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_${TARGETARCH}.zip /terraform_${TF_VERSION}_linux_${TARGETARCH}.zip
RUN unzip -q /terraform_${TF_VERSION}_linux_${TARGETARCH}.zip

FROM alpine:3.16.5
FROM alpine:3.18

LABEL org.opencontainers.image.source="https://github.com/weaveworks/tf-controller"

RUN apk add --no-cache ca-certificates tini git openssh-client gnupg && \
RUN apk update

RUN apk add --no-cache libcrypto3=3.1.1-r1 && \
apk add --no-cache libssl3=3.1.1-r1 && \
apk add --no-cache ca-certificates tini git openssh-client gnupg && \
apk add --no-cache libretls && \
apk add --no-cache busybox

Expand Down

0 comments on commit 9424ffa

Please sign in to comment.