Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
PLAT-6517: Support k8s 1.26 (#139)
Browse files Browse the repository at this point in the history
- Regenerate CRDs
- horizonalpodautoscaler is now autoscaling/v2
- updates to internal loggers
- switch protobuf library
  • Loading branch information
Michael Fraenkel committed May 23, 2023
1 parent 018fb60 commit 72b675e
Show file tree
Hide file tree
Showing 49 changed files with 3,921 additions and 3,030 deletions.
60 changes: 25 additions & 35 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,20 @@ jobs:
outputs:
version: ${{ steps.docker_prep.outputs.version }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.19.3

- name: Cache go modules and build data
uses: actions/cache@v3
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go119-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go119-
go-version: 1.20.3

- name: Cache build tools
uses: actions/cache@v3
with:
path: |
bin
testbin
key: ${{ runner.os }}-go119-${{ hashFiles('Makefile') }}
key: ${{ runner.os }}-go120-${{ hashFiles('Makefile') }}

- name: Build
run: make build
Expand All @@ -48,20 +38,20 @@ jobs:
run: make lint

- name: Upload coverage report
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v2

- name: Login to Github Container Registry
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Login to Quay
uses: docker/login-action@v1
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
Expand Down Expand Up @@ -96,19 +86,19 @@ jobs:
TAGS_MPI_INIT="${VENDOR_IMAGE_MPI_INIT}:${VERSION}"
TAGS_MPI_SYNC="${VENDOR_IMAGE_MPI_SYNC}:${VERSION}"
echo ::set-output name=description::${DESCRIPTION}
echo ::set-output name=image::${DOCKER_IMAGE}
echo ::set-output name=image_mpi_init::${DOCKER_IMAGE_MPI_INIT}
echo ::set-output name=image_mpi_sync::${DOCKER_IMAGE_MPI_SYNC}
echo ::set-output name=version::${VERSION}
echo ::set-output name=tags::${TAGS}
echo ::set-output name=tags_mpi_init::${TAGS_MPI_INIT}
echo ::set-output name=tags_mpi_sync::${TAGS_MPI_SYNC}
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
echo "description=${DESCRIPTION}" >> $GITHUB_OUTPUT
echo "image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
echo "image_mpi_init=${DOCKER_IMAGE_MPI_INIT}" >> $GITHUB_OUTPUT
echo "image_mpi_sync=${DOCKER_IMAGE_MPI_SYNC}" >> $GITHUB_OUTPUT
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
echo "tags_mpi_init=${TAGS_MPI_INIT}" >> $GITHUB_OUTPUT
echo "tags_mpi_sync=${TAGS_MPI_SYNC}" >> $GITHUB_OUTPUT
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT
- name: Build and push Docker image
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.docker_prep.outputs.tags }}
Expand All @@ -126,7 +116,7 @@ jobs:
- name: Build and push Docker image for MPI init container
id: docker_build_mpi_init
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: "{{defaultContext}}:dockerfiles"
file: mpi-init.Dockerfile
Expand All @@ -144,7 +134,7 @@ jobs:
- name: Build and push Docker image for MPI file sync container
id: docker_build_mpi_sync
uses: docker/build-push-action@v2
uses: docker/build-push-action@v4
with:
context: "{{defaultContext}}:dockerfiles"
file: mpi-sync.Dockerfile
Expand All @@ -164,7 +154,7 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Helm
run: |
Expand All @@ -191,15 +181,15 @@ jobs:
needs: build
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.19.3
go-version: 1.20.3

- name: Publish Github release
uses: goreleaser/goreleaser-action@v2
uses: goreleaser/goreleaser-action@v4
with:
args: release --rm-dist
env:
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.19.3 as builder
FROM golang:1.20.3 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -22,7 +22,7 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
FROM gcr.io/distroless/static-debian11:nonroot
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ setup-envtest: ## Download setup-envtest locally if necessary.

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.7.0)
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.11.3)

KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v3@v3.8.7)
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5@v5.0.1)

GOIMPORTS = $(shell pwd)/bin/goimports
goimports: ## Download goimports locally if necessary.
Expand All @@ -113,7 +113,7 @@ golangci-lint: ## Download golangci-lint locally if necessary.
@[ -f $(GOLANGCI_LINT) ] || { \
set -e ;\
echo "Installing golangci-lint" ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_DIR)/bin v1.50.1 ;\
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(PROJECT_DIR)/bin v1.52.2 ;\
}

HELM = $(shell pwd)/bin/helm
Expand All @@ -123,7 +123,7 @@ helm: ## Download helm locally if necessary.
echo "Installing helm" ;\
mkdir -p $(PROJECT_DIR)/bin ;\
export HELM_INSTALL_DIR=$(PROJECT_DIR)/bin ;\
curl -sSfL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | $(SHELL) -s -- --no-sudo --version v3.9.3 ;\
curl -sSfL https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | $(SHELL) -s -- --no-sudo --version v3.11.2 ;\
}

# go-get-tool will 'go get' any package $2 and install it to $1.
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/daskcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var (
}

daskDefaultPodSecurityContext = &corev1.PodSecurityContext{
RunAsUser: pointer.Int64Ptr(nobodyUID),
RunAsUser: pointer.Int64(nobodyUID),
}

daskDefaultImage = &OCIImageDefinition{
Expand Down Expand Up @@ -100,7 +100,7 @@ func (dc *DaskCluster) ValidateCreate() error {
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (dc *DaskCluster) ValidateUpdate(old runtime.Object) error {
func (dc *DaskCluster) ValidateUpdate(_ runtime.Object) error {
daskLogger.WithValues("daskcluster", client.ObjectKeyFromObject(dc)).Info("Validating update")
return dc.validateDaskCluster()
}
Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/mpicluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (j *MPICluster) ValidateCreate() error {
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
func (j *MPICluster) ValidateUpdate(old runtime.Object) error {
func (j *MPICluster) ValidateUpdate(_ runtime.Object) error {
mpiClusterLogger.WithValues("mpicluster", client.ObjectKeyFromObject(j)).Info("Validating update")

// TODO: reject all updates to spec, or certain fields?
Expand Down
6 changes: 3 additions & 3 deletions api/v1alpha1/raycluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ var (
rayDefaultGCSServerPort int32 = 2386
rayDefaultDashboardPort int32 = 8265
rayDefaultRedisShardPorts = []int32{6380, 6381}
rayDefaultEnableDashboard = pointer.BoolPtr(true)
rayDefaultEnableNetworkPolicy = pointer.BoolPtr(true)
rayDefaultWorkerReplicas = pointer.Int32Ptr(1)
rayDefaultEnableDashboard = pointer.Bool(true)
rayDefaultEnableNetworkPolicy = pointer.Bool(true)
rayDefaultWorkerReplicas = pointer.Int32(1)
rayDefaultNetworkPolicyPodLabels = map[string]string{
"ray-client": "true",
}
Expand Down
28 changes: 14 additions & 14 deletions api/v1alpha1/raycluster_webhook_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ var _ = Describe("RayCluster", func() {

It("does not enable the dashboard when false", func() {
rc := rayFixture(testNS.Name)
rc.Spec.EnableDashboard = pointer.BoolPtr(false)
rc.Spec.EnableDashboard = pointer.Bool(false)

Expect(k8sClient.Create(ctx, rc)).To(Succeed())
Expect(rc.Spec.EnableDashboard).To(PointTo(Equal(false)))
Expand All @@ -166,7 +166,7 @@ var _ = Describe("RayCluster", func() {
Context("Network policies", func() {
It("are not enabled when false", func() {
rc := rayFixture(testNS.Name)
rc.Spec.NetworkPolicy.Enabled = pointer.BoolPtr(false)
rc.Spec.NetworkPolicy.Enabled = pointer.Bool(false)

Expect(k8sClient.Create(ctx, rc)).To(Succeed())
Expect(rc.Spec.NetworkPolicy.Enabled).To(PointTo(Equal(false)))
Expand Down Expand Up @@ -202,14 +202,14 @@ var _ = Describe("RayCluster", func() {

It("requires a positive worker replica count", func() {
rc := rayFixture(testNS.Name)
rc.Spec.Worker.Replicas = pointer.Int32Ptr(-1)
rc.Spec.Worker.Replicas = pointer.Int32(-1)

Expect(k8sClient.Create(ctx, rc)).ToNot(Succeed())
})

It("requires a minimum of 75MB for object store memory", func() {
rc := rayFixture(testNS.Name)
rc.Spec.ObjectStoreMemoryBytes = pointer.Int64Ptr(74 * 1024 * 1024)
rc.Spec.ObjectStoreMemoryBytes = pointer.Int64(74 * 1024 * 1024)

Expect(k8sClient.Create(ctx, rc)).ToNot(Succeed())
})
Expand Down Expand Up @@ -298,10 +298,10 @@ var _ = Describe("RayCluster", func() {
It("requires min replicas to be > 0 when provided", func() {
rc := clusterWithAutoscaling()

rc.Spec.Autoscaling.MinReplicas = pointer.Int32Ptr(0)
rc.Spec.Autoscaling.MinReplicas = pointer.Int32(0)
Expect(k8sClient.Create(ctx, rc)).ToNot(Succeed())

rc.Spec.Autoscaling.MinReplicas = pointer.Int32Ptr(1)
rc.Spec.Autoscaling.MinReplicas = pointer.Int32(1)
Expect(k8sClient.Create(ctx, rc)).To(Succeed())
})

Expand All @@ -315,42 +315,42 @@ var _ = Describe("RayCluster", func() {
It("requires max replicas to be > min replicas", func() {
rc := clusterWithAutoscaling()

rc.Spec.Autoscaling.MinReplicas = pointer.Int32Ptr(2)
rc.Spec.Autoscaling.MinReplicas = pointer.Int32(2)
rc.Spec.Autoscaling.MaxReplicas = 1
Expect(k8sClient.Create(ctx, rc)).ToNot(Succeed())

rc.Spec.Autoscaling.MinReplicas = pointer.Int32Ptr(1)
rc.Spec.Autoscaling.MinReplicas = pointer.Int32(1)
rc.Spec.Autoscaling.MaxReplicas = 2
Expect(k8sClient.Create(ctx, rc)).To(Succeed())
})

It("requires average cpu utilization to be > 0", func() {
rc := clusterWithAutoscaling()

rc.Spec.Autoscaling.AverageCPUUtilization = pointer.Int32Ptr(0)
rc.Spec.Autoscaling.AverageCPUUtilization = pointer.Int32(0)
Expect(k8sClient.Create(ctx, rc)).ToNot(Succeed())

rc.Spec.Autoscaling.AverageCPUUtilization = pointer.Int32Ptr(75)
rc.Spec.Autoscaling.AverageCPUUtilization = pointer.Int32(75)
Expect(k8sClient.Create(ctx, rc)).To(Succeed())
})

It("requires average memory utilization to be > 0", func() {
rc := clusterWithAutoscaling()

rc.Spec.Autoscaling.AverageMemoryUtilization = pointer.Int32Ptr(0)
rc.Spec.Autoscaling.AverageMemoryUtilization = pointer.Int32(0)
Expect(k8sClient.Create(ctx, rc)).ToNot(Succeed())

rc.Spec.Autoscaling.AverageMemoryUtilization = pointer.Int32Ptr(75)
rc.Spec.Autoscaling.AverageMemoryUtilization = pointer.Int32(75)
Expect(k8sClient.Create(ctx, rc)).To(Succeed())
})

It("requires scale down stabilization to be >= 0 when provided", func() {
rc := clusterWithAutoscaling()

rc.Spec.Autoscaling.ScaleDownStabilizationWindowSeconds = pointer.Int32Ptr(-1)
rc.Spec.Autoscaling.ScaleDownStabilizationWindowSeconds = pointer.Int32(-1)
Expect(k8sClient.Create(ctx, rc)).ToNot(Succeed())

rc.Spec.Autoscaling.ScaleDownStabilizationWindowSeconds = pointer.Int32Ptr(0)
rc.Spec.Autoscaling.ScaleDownStabilizationWindowSeconds = pointer.Int32(0)
Expect(k8sClient.Create(ctx, rc)).To(Succeed())
})
})
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha1/sparkcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ var (
sparkDefaultDriverUIPort int32 = 4040
sparkDefaultDriverPort int32 = 4041
sparkDefaultDriverBlockManagerPort int32 = 4042
sparkDefaultEnableNetworkPolicy = pointer.BoolPtr(true)
sparkDefaultWorkerReplicas = pointer.Int32Ptr(1)
sparkDefaultEnableNetworkPolicy = pointer.Bool(true)
sparkDefaultWorkerReplicas = pointer.Int32(1)
sparkDefaultNetworkPolicyClientPodLabels = map[string]string{
"spark-client": "true",
}
Expand Down

0 comments on commit 72b675e

Please sign in to comment.