Skip to content
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
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dockerfile": "${localWorkspaceFolder}/.devcontainer/Dockerfile",
"context": "${localWorkspaceFolder}",
"args": {
"GO_VERSION": "1.26.5",
"GO_VERSION": "1.26.6",
"KUBECTX_VERSION": "0.9.5",
"SVELTOSCTL_VERSION": "0.53.0"
}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: 1.26.5
go-version: 1.26.6

- name: Initialize CodeQL
uses: github/codeql-action/init@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
uses: github/codeql-action/init@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7
with:
languages: ${{ matrix.language }}

Expand All @@ -46,6 +46,6 @@ jobs:
run: go build ./...

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@e4fba868fa4b1b91e1fdab776edc8cfbe6e9fb81 # v4.37.3
uses: github/codeql-action/analyze@ff2f1c621b7f889edc0d3c761ac2e6a3f8cdb0dd # v4.37.7
with:
category: "/language:${{ matrix.language }}"
18 changes: 9 additions & 9 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: 1.26.5
go-version: 1.26.6
- name: Build
run: make build
- name: FMT
Expand All @@ -36,7 +36,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: 1.26.5
go-version: 1.26.6
- name: ut
run: make test
env:
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: 1.26.5
go-version: 1.26.6
- name: fv
run: make create-cluster fv
env:
Expand All @@ -62,7 +62,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: 1.26.5
go-version: 1.26.6
- name: fv
run: make create-cluster new-fv
env:
Expand All @@ -75,7 +75,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: 1.26.5
go-version: 1.26.6
- name: fv-sharding
run: make create-cluster fv-sharding
env:
Expand All @@ -88,7 +88,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: 1.26.5
go-version: 1.26.6
- name: fv-agentless
run: make create-cluster fv-agentless
env:
Expand All @@ -101,7 +101,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: 1.26.5
go-version: 1.26.6
- name: fv-pullmode
run: make create-cluster-pullmode fv-pullmode
env:
Expand All @@ -114,7 +114,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: 1.26.5
go-version: 1.26.6
- name: new-fv-pullmode
run: make create-cluster-pullmode new-fv-pullmode
env:
Expand All @@ -127,7 +127,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: 1.26.5
go-version: 1.26.6
- name: fv
run: make create-cluster-infra fv-namespace
env:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.26.5@sha256:3aff6657219a4d9c14e27fb1d8976c49c29fddb70ba835014f477e1c70636647 AS builder
FROM golang:1.26.6 AS builder

ARG BUILDOS
ARG TARGETARCH
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile_WithGit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.26.5@sha256:3aff6657219a4d9c14e27fb1d8976c49c29fddb70ba835014f477e1c70636647 AS builder
FROM golang:1.26.6 AS builder

ARG BUILDOS
ARG TARGETARCH
Expand Down
5 changes: 2 additions & 3 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions controllers/handlers_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,10 @@ func undeployHelmChartsInPullMode(ctx context.Context, c client.Client, clusterS
if err != nil {
return err
}
setters := prepareSetters(clusterSummary, libsveltosv1beta1.FeatureHelm, profileRef, nil, false, true)
setters, err := prepareSetters(ctx, clusterSummary, libsveltosv1beta1.FeatureHelm, profileRef, nil, false, true, logger)
if err != nil {
return err
}

// If charts have pre/post delete hooks, those need to be deployed. A ConfigurationGroup to deploy those
// is created. If this does not exist yet assume we still have to deploy those.
Expand Down Expand Up @@ -5777,7 +5780,11 @@ func commitStagedResourcesForDeployment(ctx context.Context, clusterSummary *con
}

// if a stale helm release is being deleted, run the pre/post delete checks
setters := prepareSetters(clusterSummary, libsveltosv1beta1.FeatureHelm, profileRef, configurationHash, includeDeployChecks, len(staleReleases) != 0)
setters, err := prepareSetters(ctx, clusterSummary, libsveltosv1beta1.FeatureHelm, profileRef, configurationHash,
includeDeployChecks, len(staleReleases) != 0, logger)
if err != nil {
return err
}
// Commit deployment
return pullmode.CommitStagedResourcesForDeployment(ctx, getManagementClusterClient(),
clusterSummary.Spec.ClusterNamespace, clusterSummary.Spec.ClusterName, configv1beta1.ClusterSummaryKind,
Expand Down
26 changes: 19 additions & 7 deletions controllers/handlers_kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,7 @@ func processKustomizeDeployment(ctx context.Context, remoteRestConfig *rest.Conf
}

if isPullMode {
setters := prepareSetters(clusterSummary, libsveltosv1beta1.FeatureKustomize, profileRef,
configurationHash, true, false)
err = pullmode.CommitStagedResourcesForDeployment(ctx, c,
clusterSummary.Spec.ClusterNamespace, clusterSummary.Spec.ClusterName, configv1beta1.ClusterSummaryKind,
clusterSummary.Name, string(libsveltosv1beta1.FeatureKustomize),
logger, setters...)
if err != nil {
if err := commitPullModeKustomizeStaging(ctx, c, clusterSummary, profileRef, configurationHash, logger); err != nil {
return err
}

Expand All @@ -254,6 +248,24 @@ func processKustomizeDeployment(ctx context.Context, remoteRestConfig *rest.Conf
clusterSummary.Spec.ClusterProfileSpec.ValidateHealths, libsveltosv1beta1.FeatureKustomize, false, logger)
}

// commitPullModeKustomizeStaging prepares the ConfigurationGroup setters (including any
// resolved JobCheck manifests, see prepareSetters) and commits the staged Kustomize resources
// for sveltos-applier to pick up.
func commitPullModeKustomizeStaging(ctx context.Context, c client.Client, clusterSummary *configv1beta1.ClusterSummary,
profileRef *corev1.ObjectReference, configurationHash []byte, logger logr.Logger) error {

setters, err := prepareSetters(ctx, clusterSummary, libsveltosv1beta1.FeatureKustomize, profileRef,
configurationHash, true, false, logger)
if err != nil {
return err
}

return pullmode.CommitStagedResourcesForDeployment(ctx, c,
clusterSummary.Spec.ClusterNamespace, clusterSummary.Spec.ClusterName, configv1beta1.ClusterSummaryKind,
clusterSummary.Name, string(libsveltosv1beta1.FeatureKustomize),
logger, setters...)
}

func cleanStaleKustomizeResources(ctx context.Context, clusterSummary *configv1beta1.ClusterSummary,
localResourceReports, remoteResourceReports []libsveltosv1beta1.ResourceReport, logger logr.Logger,
) (localUndeployed, remoteUndeployed []libsveltosv1beta1.ResourceReport, err error) {
Expand Down
31 changes: 23 additions & 8 deletions controllers/handlers_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,7 @@ func postProcessDeployedResources(ctx context.Context, remoteRestConfig *rest.Co
}

if isPullMode {
setters := prepareSetters(clusterSummary, libsveltosv1beta1.FeatureResources, profileRef,
configurationHash, true, false)
err = pullmode.CommitStagedResourcesForDeployment(ctx, c,
clusterSummary.Spec.ClusterNamespace, clusterSummary.Spec.ClusterName, configv1beta1.ClusterSummaryKind,
clusterSummary.Name, string(libsveltosv1beta1.FeatureResources),
logger, setters...)
if err != nil {
if err := commitPullModeResourcesStaging(ctx, c, clusterSummary, profileRef, configurationHash, logger); err != nil {
return err
}

Expand All @@ -211,6 +205,24 @@ func postProcessDeployedResources(ctx context.Context, remoteRestConfig *rest.Co
clusterSummary.Spec.ClusterProfileSpec.ValidateHealths, libsveltosv1beta1.FeatureResources, false, logger)
}

// commitPullModeResourcesStaging prepares the ConfigurationGroup setters (including any
// resolved JobCheck manifests, see prepareSetters) and commits the staged resources for
// sveltos-applier to pick up.
func commitPullModeResourcesStaging(ctx context.Context, c client.Client, clusterSummary *configv1beta1.ClusterSummary,
profileRef *corev1.ObjectReference, configurationHash []byte, logger logr.Logger) error {

setters, err := prepareSetters(ctx, clusterSummary, libsveltosv1beta1.FeatureResources, profileRef,
configurationHash, true, false, logger)
if err != nil {
return err
}

return pullmode.CommitStagedResourcesForDeployment(ctx, c,
clusterSummary.Spec.ClusterNamespace, clusterSummary.Spec.ClusterName, configv1beta1.ClusterSummaryKind,
clusterSummary.Name, string(libsveltosv1beta1.FeatureResources),
logger, setters...)
}

func cleanStaleResources(ctx context.Context, clusterSummary *configv1beta1.ClusterSummary,
localResourceReports, remoteResourceReports []libsveltosv1beta1.ResourceReport, logger logr.Logger,
) (localUndeployed, remoteUndeployed []libsveltosv1beta1.ResourceReport, err error) {
Expand Down Expand Up @@ -504,7 +516,10 @@ func pullModeUndeployResources(ctx context.Context, c client.Client, clusterSumm
return err
}

setters := prepareSetters(clusterSummary, fID, profileRef, nil, false, true)
setters, err := prepareSetters(ctx, clusterSummary, fID, profileRef, nil, false, true, logger)
if err != nil {
return err
}

// discard all previous staged resources. This will instruct agent to undeploy
err = pullmode.RemoveDeployedResources(ctx, c, clusterSummary.Spec.ClusterNamespace,
Expand Down
35 changes: 31 additions & 4 deletions controllers/handlers_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1632,8 +1632,9 @@ func getPatchesHash(ctx context.Context, clusterSummary *configv1beta1.ClusterSu
return hashString, nil
}

func prepareSetters(clusterSummary *configv1beta1.ClusterSummary, featureID libsveltosv1beta1.FeatureID,
profileRef *corev1.ObjectReference, configurationHash []byte, includeDeployChecks, includeDeleteChecks bool) []pullmode.Option {
func prepareSetters(ctx context.Context, clusterSummary *configv1beta1.ClusterSummary, featureID libsveltosv1beta1.FeatureID,
profileRef *corev1.ObjectReference, configurationHash []byte, includeDeployChecks, includeDeleteChecks bool,
logger logr.Logger) ([]pullmode.Option, error) {

setters := make([]pullmode.Option, 0)
if clusterSummary.Spec.ClusterProfileSpec.SyncMode == configv1beta1.SyncModeContinuousWithDriftDetection {
Expand Down Expand Up @@ -1674,15 +1675,41 @@ func prepareSetters(clusterSummary *configv1beta1.ClusterSummary, featureID libs
pullmode.WithDeployedGVKs(gvks))

if includeDeployChecks {
preDeployCheckJobs, err := clusterops.ResolveJobChecksForPullMode(ctx, getManagementClusterDirectClient(),
clusterSummary, getSveltosNamespace(), clusterSummary.Spec.ClusterProfileSpec.PreDeployChecks, logger)
if err != nil {
return nil, err
}
validateHealthJobs, err := clusterops.ResolveJobChecksForPullMode(ctx, getManagementClusterDirectClient(),
clusterSummary, getSveltosNamespace(), clusterSummary.Spec.ClusterProfileSpec.ValidateHealths, logger)
if err != nil {
return nil, err
}

setters = append(setters,
pullmode.WithPreDeployChecks(clusterSummary.Spec.ClusterProfileSpec.PreDeployChecks),
pullmode.WithValidateHealths(clusterSummary.Spec.ClusterProfileSpec.ValidateHealths))
pullmode.WithPreDeployCheckJobs(preDeployCheckJobs),
pullmode.WithValidateHealths(clusterSummary.Spec.ClusterProfileSpec.ValidateHealths),
pullmode.WithValidateHealthJobs(validateHealthJobs))
}

if includeDeleteChecks {
preDeleteCheckJobs, err := clusterops.ResolveJobChecksForPullMode(ctx, getManagementClusterDirectClient(),
clusterSummary, getSveltosNamespace(), clusterSummary.Spec.ClusterProfileSpec.PreDeleteChecks, logger)
if err != nil {
return nil, err
}
postDeleteCheckJobs, err := clusterops.ResolveJobChecksForPullMode(ctx, getManagementClusterDirectClient(),
clusterSummary, getSveltosNamespace(), clusterSummary.Spec.ClusterProfileSpec.PostDeleteChecks, logger)
if err != nil {
return nil, err
}

setters = append(setters,
pullmode.WithPreDeleteChecks(clusterSummary.Spec.ClusterProfileSpec.PreDeleteChecks),
pullmode.WithPreDeleteCheckJobs(preDeleteCheckJobs),
pullmode.WithPostDeleteChecks(clusterSummary.Spec.ClusterProfileSpec.PostDeleteChecks),
pullmode.WithPostDeleteCheckJobs(postDeleteCheckJobs),
)
}

Expand All @@ -1700,7 +1727,7 @@ func prepareSetters(clusterSummary *configv1beta1.ClusterSummary, featureID libs

setters = append(setters, pullmode.WithSourceRef(&sourceRef))

return setters
return setters, nil
}

func updateReloaderWithDeployedResources(ctx context.Context, clusterSummary *configv1beta1.ClusterSummary,
Expand Down
32 changes: 16 additions & 16 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/projectsveltos/addon-controller

go 1.26.5
go 1.26.6

require (
dario.cat/mergo v1.0.2
Expand All @@ -20,7 +20,7 @@ require (
github.com/onsi/gomega v1.42.1
github.com/opencontainers/image-spec v1.1.1
github.com/pkg/errors v0.9.1
github.com/projectsveltos/libsveltos v1.13.1-0.20260817055546-e9cd5c7232a0
github.com/projectsveltos/libsveltos v1.13.1-0.20260817131031-65ba770060a8
github.com/prometheus/client_golang v1.24.1
github.com/sigstore/cosign/v3 v3.1.3
github.com/sigstore/sigstore v1.10.9
Expand Down Expand Up @@ -84,22 +84,22 @@ require (
github.com/aliyun/credentials-go v1.3.2 // indirect
github.com/antlr4-go/antlr/v4 v4.13.1 // indirect
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
github.com/aws/aws-sdk-go-v2 v1.43.5 // indirect
github.com/aws/aws-sdk-go-v2/config v1.32.36 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.19.35 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.36 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.36 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.36 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.37 // indirect
github.com/aws/aws-sdk-go-v2 v1.43.6 // indirect
github.com/aws/aws-sdk-go-v2/config v1.32.37 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.19.36 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.37 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.37 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.37 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.4.38 // indirect
github.com/aws/aws-sdk-go-v2/service/ecr v1.55.3 // indirect
github.com/aws/aws-sdk-go-v2/service/ecrpublic v1.38.10 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.16 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.36 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.5.5 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.33.5 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.38.5 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.45.5 // indirect
github.com/aws/smithy-go v1.27.7 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.17 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.37 // indirect
github.com/aws/aws-sdk-go-v2/service/signin v1.5.6 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.33.6 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.38.6 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.45.6 // indirect
github.com/aws/smithy-go v1.27.8 // indirect
github.com/awslabs/amazon-ecr-credential-helper/ecr-login v0.12.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
Expand Down
Loading