Skip to content

Commit

Permalink
Merge branch 'bsoghigian/list-node-image-versions-poc' of github.com:…
Browse files Browse the repository at this point in the history
…Azure/karpenter-provider-azure into bsoghigian/list-node-image-versions-poc
  • Loading branch information
Bryce-Soghigian committed Dec 16, 2024
2 parents 5cc3757 + 64a6fa6 commit 2337c05
Show file tree
Hide file tree
Showing 14 changed files with 639 additions and 439 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@ description: 'Installs Go Downloads and installs Karpenter Dependencies'
inputs:
k8sVersion:
description: Kubernetes version to use when installing the toolchain
default: "1.27.x"
default: "1.31.x"
runs:
using: "composite"
steps:
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
id: setup-go
with:
go-version-file: go.mod
check-latest: true
cache-dependency-path: "**/go.sum"
# Root path permission workaround for caching https://github.com/actions/cache/issues/845#issuecomment-1252594999
- run: sudo chown "$USER" /usr/local
shell: bash
- uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0
- uses: actions/cache@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
id: cache-toolchain
with:
path: |
Expand All @@ -26,4 +27,4 @@ runs:
shell: bash
env:
K8S_VERSION: ${{ inputs.k8sVersion }}
run: make toolchain
run: make toolchain
8 changes: 8 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,11 @@ updates:
action-deps:
patterns:
- '*'
- package-ecosystem: github-actions
directory: .github/actions/install-deps
schedule:
interval: weekly
groups:
action-deps:
patterns:
- '*'
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: ./.github/actions/install-deps
- run: make vulncheck
- uses: github/codeql-action/init@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
- uses: github/codeql-action/init@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
with:
languages: ${{ matrix.language }}
- uses: github/codeql-action/autobuild@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
- uses: github/codeql-action/analyze@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
- uses: github/codeql-action/autobuild@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
- uses: github/codeql-action/analyze@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@f09c1c0a94de965c15400f5634aa42fac8fb8f88 # v3.27.5
uses: github/codeql-action/upload-sarif@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6
with:
sarif_file: results.sarif
37 changes: 16 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,24 @@ help: ## Display help

presubmit: verify test ## Run all steps in the developer loop

ci-test: battletest coverage ## Runs tests and submits coverage
ci-test: test coverage ## Runs tests and submits coverage

ci-non-test: verify vulncheck ## Runs checks other than tests
ci-non-test: verify licenses vulncheck ## Runs checks other than tests

test: ## Run tests
ginkgo -v --focus="${FOCUS}" ./pkg/$(shell echo $(TEST_SUITE) | tr A-Z a-z)

battletest: ## Run randomized, racing, code-covered tests
ginkgo -v \
-race \
ginkgo -vv \
-cover -coverprofile=coverage.out -output-dir=. -coverpkg=./pkg/... \
--focus="${FOCUS}" \
--randomize-all \
-tags random_test_delay \
./pkg/...

deflake: ## Run randomized, racing tests until the test fails to catch flakes
ginkgo \
--race \
--focus="${FOCUS}" \
--randomize-all \
--until-it-fails \
-v \
./pkg/...

e2etests: ## Run the e2e suite against your local cluster
Expand All @@ -59,18 +63,6 @@ e2etests: ## Run the e2e suite against your local cluster
benchmark:
go test -tags=test_performance -run=NoTests -bench=. ./...

deflake: ## Run randomized, racing, code-covered tests to deflake failures
for i in $(shell seq 1 5); do make battletest || exit 1; done

deflake-until-it-fails: ## Run randomized, racing tests until the test fails to catch flakes
ginkgo \
--race \
--focus="${FOCUS}" \
--randomize-all \
--until-it-fails \
-v \
./pkg/...

coverage:
go tool cover -html coverage.out -o coverage.html

Expand Down Expand Up @@ -102,6 +94,9 @@ verify: toolchain tidy download ## Verify code. Includes dependencies, linting,
vulncheck: ## Verify code vulnerabilities
@govulncheck ./pkg/...

licenses: download ## Verifies dependency licenses
! go-licenses csv ./... | grep -v -e 'MIT' -e 'Apache-2.0' -e 'BSD-3-Clause' -e 'BSD-2-Clause' -e 'ISC' -e 'MPL-2.0'

codegen: ## Auto generate files based on Azure API responses
./hack/codegen.sh

Expand All @@ -120,7 +115,7 @@ tidy: ## Recursively "go mod tidy" on all directories where go.mod exists
download: ## Recursively "go mod download" on all directories where go.mod exists
$(foreach dir,$(MOD_DIRS),cd $(dir) && go mod download $(newline))

.PHONY: help test battletest e2etests verify tidy download codegen toolchain vulncheck snapshot release
.PHONY: help presubmit ci-test ci-non-test test deflake e2etests coverage verify vulncheck licenses codegen snapshot release toolchain tidy download

define newline

Expand Down
10 changes: 10 additions & 0 deletions pkg/cloudprovider/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/awslabs/operatorpkg/object"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/samber/lo"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Expand Down Expand Up @@ -223,5 +224,14 @@ var _ = Describe("CloudProvider", func() {
Expect(err).To(HaveOccurred())
Expect(drifted).To(BeEmpty())
})
It("should trigger drift when the image gallery changes to SIG", func() {
options := test.Options(test.OptionsFields{
UseSIG: lo.ToPtr(true),
})
ctx = options.ToContext(ctx)
drifted, err := cloudProvider.IsDrifted(ctx, nodeClaim)
Expect(err).ToNot(HaveOccurred())
Expect(string(drifted)).To(Equal("ImageVersionDrift"))
})
})
})
13 changes: 0 additions & 13 deletions pkg/fake/communityimageversionsapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ package fake

import (
"context"
"fmt"

"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5"
"github.com/samber/lo"

"github.com/Azure/karpenter-provider-azure/pkg/providers/imagefamily"
)
Expand Down Expand Up @@ -53,17 +51,6 @@ func (c *CommunityGalleryImageVersionsAPI) NewListPager(_ string, _ string, _ st
return runtime.NewPager(pagingHandler)
}

func (c *CommunityGalleryImageVersionsAPI) Get(_ context.Context, location string, publicGalleryName string, galleryImageName string, galleryImageVersionName string, options *armcompute.CommunityGalleryImageVersionsClientGetOptions) (armcompute.CommunityGalleryImageVersionsClientGetResponse, error) {
// TODO: Add case where this get doesn't work or succeed
return armcompute.CommunityGalleryImageVersionsClientGetResponse{
CommunityGalleryImageVersion: armcompute.CommunityGalleryImageVersion{
Identifier: &armcompute.CommunityGalleryIdentifier{
UniqueID: lo.ToPtr(fmt.Sprintf("/CommunityGalleries/%s/images/%s/versions/%s", publicGalleryName, galleryImageName, galleryImageVersionName)),
},
},
}, nil
}

func (c *CommunityGalleryImageVersionsAPI) Reset() {
if c == nil {
return
Expand Down
Loading

0 comments on commit 2337c05

Please sign in to comment.