Skip to content
Open
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
16 changes: 16 additions & 0 deletions api/v1beta1/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,14 @@ type KustomizationRef struct {
// +kubebuilder:default:=false
// +optional
SkipNamespaceCreation bool `json:"skipNamespaceCreation,omitempty"`

// Force indicates whether Sveltos should delete and recreate a resource defined in this
// KustomizationRef when an update is rejected with an error that only a delete+recreate
// can resolve (eg an invalid combination of fields, or a field enforced as immutable).
// By default, such errors are surfaced instead of recreating the resource.
// +kubebuilder:default:=false
// +optional
Force bool `json:"force,omitempty"`
}

// StopMatchingBehavior indicates what will happen when Cluster stops matching
Expand Down Expand Up @@ -779,6 +787,14 @@ type PolicyRef struct {
// +optional
SkipNamespaceCreation bool `json:"skipNamespaceCreation,omitempty"`

// Force indicates whether Sveltos should delete and recreate a resource defined in this
// PolicyRef when an update is rejected with an error that only a delete+recreate can
// resolve (eg an invalid combination of fields, or a field enforced as immutable).
// By default, such errors are surfaced instead of recreating the resource.
// +kubebuilder:default:=false
// +optional
Force bool `json:"force,omitempty"`

// RemoteURL configures fetching content from an HTTP/HTTPS endpoint or an OCI registry.
// When set, Kind/Name/Namespace must be omitted.
// +optional
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.

16 changes: 16 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clusterprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,14 @@ spec:
- Local
- Remote
type: string
force:
default: false
description: |-
Force indicates whether Sveltos should delete and recreate a resource defined in this
KustomizationRef when an update is rejected with an error that only a delete+recreate
can resolve (eg an invalid combination of fields, or a field enforced as immutable).
By default, such errors are surfaced instead of recreating the resource.
type: boolean
kind:
description: |-
Kind of the resource. Supported kinds are:
Expand Down Expand Up @@ -1064,6 +1072,14 @@ spec:
- Local
- Remote
type: string
force:
default: false
description: |-
Force indicates whether Sveltos should delete and recreate a resource defined in this
PolicyRef when an update is rejected with an error that only a delete+recreate can
resolve (eg an invalid combination of fields, or a field enforced as immutable).
By default, such errors are surfaced instead of recreating the resource.
type: boolean
kind:
description: |-
Kind of the resource. Supported kinds are:
Expand Down
32 changes: 32 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clusterpromotions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,14 @@ spec:
- Local
- Remote
type: string
force:
default: false
description: |-
Force indicates whether Sveltos should delete and recreate a resource defined in this
KustomizationRef when an update is rejected with an error that only a delete+recreate
can resolve (eg an invalid combination of fields, or a field enforced as immutable).
By default, such errors are surfaced instead of recreating the resource.
type: boolean
kind:
description: |-
Kind of the resource. Supported kinds are:
Expand Down Expand Up @@ -966,6 +974,14 @@ spec:
- Local
- Remote
type: string
force:
default: false
description: |-
Force indicates whether Sveltos should delete and recreate a resource defined in this
PolicyRef when an update is rejected with an error that only a delete+recreate can
resolve (eg an invalid combination of fields, or a field enforced as immutable).
By default, such errors are surfaced instead of recreating the resource.
type: boolean
kind:
description: |-
Kind of the resource. Supported kinds are:
Expand Down Expand Up @@ -2183,6 +2199,14 @@ spec:
- Local
- Remote
type: string
force:
default: false
description: |-
Force indicates whether Sveltos should delete and recreate a resource defined in this
PolicyRef when an update is rejected with an error that only a delete+recreate can
resolve (eg an invalid combination of fields, or a field enforced as immutable).
By default, such errors are surfaced instead of recreating the resource.
type: boolean
kind:
description: |-
Kind of the resource. Supported kinds are:
Expand Down Expand Up @@ -2545,6 +2569,14 @@ spec:
- Local
- Remote
type: string
force:
default: false
description: |-
Force indicates whether Sveltos should delete and recreate a resource defined in this
PolicyRef when an update is rejected with an error that only a delete+recreate can
resolve (eg an invalid combination of fields, or a field enforced as immutable).
By default, such errors are surfaced instead of recreating the resource.
type: boolean
kind:
description: |-
Kind of the resource. Supported kinds are:
Expand Down
16 changes: 16 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clustersummaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,14 @@ spec:
- Local
- Remote
type: string
force:
default: false
description: |-
Force indicates whether Sveltos should delete and recreate a resource defined in this
KustomizationRef when an update is rejected with an error that only a delete+recreate
can resolve (eg an invalid combination of fields, or a field enforced as immutable).
By default, such errors are surfaced instead of recreating the resource.
type: boolean
kind:
description: |-
Kind of the resource. Supported kinds are:
Expand Down Expand Up @@ -1103,6 +1111,14 @@ spec:
- Local
- Remote
type: string
force:
default: false
description: |-
Force indicates whether Sveltos should delete and recreate a resource defined in this
PolicyRef when an update is rejected with an error that only a delete+recreate can
resolve (eg an invalid combination of fields, or a field enforced as immutable).
By default, such errors are surfaced instead of recreating the resource.
type: boolean
kind:
description: |-
Kind of the resource. Supported kinds are:
Expand Down
16 changes: 16 additions & 0 deletions config/crd/bases/config.projectsveltos.io_profiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,14 @@ spec:
- Local
- Remote
type: string
force:
default: false
description: |-
Force indicates whether Sveltos should delete and recreate a resource defined in this
KustomizationRef when an update is rejected with an error that only a delete+recreate
can resolve (eg an invalid combination of fields, or a field enforced as immutable).
By default, such errors are surfaced instead of recreating the resource.
type: boolean
kind:
description: |-
Kind of the resource. Supported kinds are:
Expand Down Expand Up @@ -1064,6 +1072,14 @@ spec:
- Local
- Remote
type: string
force:
default: false
description: |-
Force indicates whether Sveltos should delete and recreate a resource defined in this
PolicyRef when an update is rejected with an error that only a delete+recreate can
resolve (eg an invalid combination of fields, or a field enforced as immutable).
By default, such errors are surfaced instead of recreating the resource.
type: boolean
kind:
description: |-
Kind of the resource. Supported kinds are:
Expand Down
22 changes: 12 additions & 10 deletions controllers/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,18 @@ var (
GenericDeploy = genericDeploy
GenericUndeploy = genericUndeploy

GetEntryKey = getEntryKey
DeployContentOfConfigMap = deployContentOfConfigMap
DeployContentOfSecret = deployContentOfSecret
DeployContent = deployContent
GetClusterSummaryAdmin = getClusterSummaryAdmin
CollectContent = collectContent
UndeployStaleResources = undeployStaleResources
GetDeployedGroupVersionKinds = getDeployedGroupVersionKinds
GetSecret = getSecret
ReadFiles = readFiles
GetEntryKey = getEntryKey
DeployContentOfConfigMap = deployContentOfConfigMap
DeployContentOfSecret = deployContentOfSecret
DeployContent = deployContent
GetClusterSummaryAdmin = getClusterSummaryAdmin
CollectContent = collectContent
CollectReferencedObjects = collectReferencedObjects
PrepareBundleSettersWithResourceInfo = prepareBundleSettersWithResourceInfo
UndeployStaleResources = undeployStaleResources
GetDeployedGroupVersionKinds = getDeployedGroupVersionKinds
GetSecret = getSecret
ReadFiles = readFiles

AddExtraLabels = addExtraLabels
AddExtraAnnotations = addExtraAnnotations
Expand Down
4 changes: 2 additions & 2 deletions controllers/handlers_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -4574,8 +4574,8 @@ func addExtraMetadata(ctx context.Context, requestedChart *configv1beta1.HelmCha

isDriftDetection := clusterSummary.Spec.ClusterProfileSpec.SyncMode == configv1beta1.SyncModeContinuousWithDriftDetection
isDryRun := clusterSummary.Spec.ClusterProfileSpec.SyncMode == configv1beta1.SyncModeDryRun
_, err = deployer.UpdateResource(ctx, dr, isDriftDetection, isDryRun, clusterSummary.Spec.ClusterProfileSpec.DriftExclusions,
r, []string{}, logger)
_, err = deployer.UpdateResource(ctx, dr, isDriftDetection, isDryRun, getForceValue(requestedChart.Options),
clusterSummary.Spec.ClusterProfileSpec.DriftExclusions, r, []string{}, logger)
if err != nil {
logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to update resource %s %s/%s: %v",
r.GetKind(), r.GetNamespace(), r.GetName(), err))
Expand Down
10 changes: 5 additions & 5 deletions controllers/handlers_kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,8 +1011,8 @@ func deployKustomizeResources(ctx context.Context, c client.Client, remoteRestCo
Name: kustomizationRef.Name,
}
localReports, err = deployUnstructured(ctx, true, localConfig, c, objectsToDeployLocally,
ref, kustomizationRef.Tier, kustomizationRef.SkipNamespaceCreation, libsveltosv1beta1.FeatureKustomize,
dCtx.clusterSummary, []string{}, logger)
ref, kustomizationRef.Tier, kustomizationRef.SkipNamespaceCreation, kustomizationRef.Force,
libsveltosv1beta1.FeatureKustomize, dCtx.clusterSummary, []string{}, logger)
if err != nil {
logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to deploy to management cluster %v", err))
return localReports, nil, err
Expand All @@ -1025,7 +1025,7 @@ func deployKustomizeResources(ctx context.Context, c client.Client, remoteRestCo
bundleResources[key] = convertPointerSliceToValueSlice(objectsToDeployRemotely)

setters := prepareBundleSettersWithResourceInfo(ref.Kind, ref.Namespace, ref.Name, kustomizationRef.Tier,
kustomizationRef.SkipNamespaceCreation)
kustomizationRef.SkipNamespaceCreation, kustomizationRef.Force)

return localReports, nil, pullmode.StageResourcesForDeployment(ctx, getManagementClusterClient(),
dCtx.clusterSummary.Spec.ClusterNamespace, dCtx.clusterSummary.Spec.ClusterName, configv1beta1.ClusterSummaryKind,
Expand All @@ -1038,8 +1038,8 @@ func deployKustomizeResources(ctx context.Context, c client.Client, remoteRestCo
}

remoteReports, err = deployUnstructured(ctx, false, remoteRestConfig, remoteClient, objectsToDeployRemotely,
ref, kustomizationRef.Tier, kustomizationRef.SkipNamespaceCreation, libsveltosv1beta1.FeatureKustomize,
dCtx.clusterSummary, []string{}, logger)
ref, kustomizationRef.Tier, kustomizationRef.SkipNamespaceCreation, kustomizationRef.Force,
libsveltosv1beta1.FeatureKustomize, dCtx.clusterSummary, []string{}, logger)
if err != nil {
logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to deploy to remote cluster %v", err))
return localReports, remoteReports, err
Expand Down
Loading
Loading