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

[v2] Stable envRefs #678

Merged
merged 4 commits into from
Sep 23, 2024
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
7 changes: 3 additions & 4 deletions .github/workflows/v2-run-acceptance-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
go-version: 1.23.x
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
Expand All @@ -44,7 +44,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
go-version: 1.23.x
- name: Install Pulumi
uses: pulumi/actions@v5
- name: Run Tests (Agent)
Expand All @@ -61,7 +61,6 @@ jobs:
e2e-tests:
runs-on: ubuntu-latest
name: E2E tests
if: false
steps:
# Building the rootless image currently eats up all of our free disk.
- name: Free Disk Space (Ubuntu)
Expand All @@ -78,6 +77,6 @@ jobs:
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
go-version: 1.23.x
- name: Run tests
run: make -C operator test-e2e
2 changes: 1 addition & 1 deletion operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the operator binary
FROM --platform=${BUILDPLATFORM} golang:1.22 AS op-builder
FROM --platform=${BUILDPLATFORM} golang:1.23 AS op-builder
ARG TARGETOS
ARG TARGETARCH

Expand Down
3 changes: 0 additions & 3 deletions operator/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ func TestE2E(t *testing.T) {

cmd := exec.Command("bash", "-c", "envsubst < e2e/testdata/git-auth-nonroot/* | kubectl apply -f -")
require.NoError(t, run(cmd))
t.Cleanup(func() {
_ = run(exec.Command("kubectl", "delete", "-f", "e2e/testdata/git-auth-nonroot"))
})
Comment on lines -94 to -96
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was deleting the secret needed by the operator in order to poll the repo, preventing the stack from reconciling / getting deleted.


cmd = exec.Command("kubectl", "wait", "stacks/git-auth-nonroot",
"--for", "condition=Ready", "-n", "git-auth-nonroot", "--timeout", "300s")
Expand Down
2 changes: 1 addition & 1 deletion operator/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/pulumi/pulumi-kubernetes-operator/operator

go 1.22.5
go 1.23.1

require (
github.com/fluxcd/source-controller/api v1.3.0
Expand Down
14 changes: 11 additions & 3 deletions operator/internal/controller/pulumi/stack_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"encoding/json"
"errors"
"fmt"
"maps"
"os"
"path"
"slices"
Expand Down Expand Up @@ -882,13 +883,20 @@ func (sess *StackReconcilerSession) SetSecretEnvs(ctx context.Context, secretNam
// the EnvRefs field in the stack specification.
func (sess *StackReconcilerSession) SetEnvRefsForWorkspace(ctx context.Context) error {
envRefs := sess.stack.EnvRefs
for envVar, ref := range envRefs {

// envRefs is an unordered map, but we need to constrct env vars
// deterministically to not thrash our underlying StatefulSet.
keys := slices.Sorted(maps.Keys(envRefs))

for _, key := range keys {
ref := envRefs[key]

value, valueFrom, err := sess.resolveResourceRefAsEnvVar(ctx, &ref)
if err != nil {
return fmt.Errorf("resolving env variable reference for %q: %w", envVar, err)
return fmt.Errorf("resolving env variable reference for %q: %w", key, err)
}
sess.ws.Spec.Env = append(sess.ws.Spec.Env, corev1.EnvVar{
Name: envVar,
Name: key,
Value: value,
ValueFrom: valueFrom,
})
Expand Down