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
24 changes: 24 additions & 0 deletions api/v1beta1/spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,18 @@ type KustomizationRef struct {
// the actual region retrieved earlier.
// +optional
ValuesFrom []ValueFrom `json:"valuesFrom,omitempty"`

// Tier controls the order of deployment for resources coming from different KustomizationRef
// within the same ClusterProfile or Profile.
// When two KustomizationRef attempt to deploy the same resource, the KustomizationRef with the lowest
// Tier value takes priority and deploys/updates the resource.
// This priority mechanism is only checked after the parent ClusterProfile has won
// the primary conflict resolution against other ClusterProfiles.
// Higher Tier values represent lower priority. The default Tier value is 100.
// +kubebuilder:default:=100
// +kubebuilder:validation:Minimum=1
// +optional
Tier int32 `json:"tier,omitempty"`
}

// StopMatchingBehavior indicates what will happen when Cluster stops matching
Expand Down Expand Up @@ -595,6 +607,18 @@ type PolicyRef struct {
// +kubebuilder:default:=false
// +optional
Optional bool `json:"optional,omitempty"`

// Tier controls the order of deployment for resources coming from different PolicyRefs
// within the same ClusterProfile or Profile.
// When two PolicyRefs attempt to deploy the same resource, the PolicyRef with the lowest
// Tier value takes priority and deploys/updates the resource.
// This priority mechanism is only checked after the parent ClusterProfile has won
// the primary conflict resolution against other ClusterProfiles.
// Higher Tier values represent lower priority. The default Tier value is 100.
// +kubebuilder:default:=100
// +kubebuilder:validation:Minimum=1
// +optional
Tier int32 `json:"tier,omitempty"`
}

type Clusters struct {
Expand Down
26 changes: 26 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clusterprofiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,19 @@ spec:
maxLength: 63
minLength: 1
type: string
tier:
default: 100
description: |-
Tier controls the order of deployment for resources coming from different KustomizationRef
within the same ClusterProfile or Profile.
When two KustomizationRef attempt to deploy the same resource, the KustomizationRef with the lowest
Tier value takes priority and deploys/updates the resource.
This priority mechanism is only checked after the parent ClusterProfile has won
the primary conflict resolution against other ClusterProfiles.
Higher Tier values represent lower priority. The default Tier value is 100.
format: int32
minimum: 1
type: integer
values:
additionalProperties:
type: string
Expand Down Expand Up @@ -920,6 +933,19 @@ spec:
Defaults to 'None', which translates to the root path of the SourceRef.
Used only for GitRepository;OCIRepository;Bucket
type: string
tier:
default: 100
description: |-
Tier controls the order of deployment for resources coming from different PolicyRefs
within the same ClusterProfile or Profile.
When two PolicyRefs attempt to deploy the same resource, the PolicyRef with the lowest
Tier value takes priority and deploys/updates the resource.
This priority mechanism is only checked after the parent ClusterProfile has won
the primary conflict resolution against other ClusterProfiles.
Higher Tier values represent lower priority. The default Tier value is 100.
format: int32
minimum: 1
type: integer
required:
- kind
- name
Expand Down
26 changes: 26 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clusterpromotions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,19 @@ spec:
maxLength: 63
minLength: 1
type: string
tier:
default: 100
description: |-
Tier controls the order of deployment for resources coming from different KustomizationRef
within the same ClusterProfile or Profile.
When two KustomizationRef attempt to deploy the same resource, the KustomizationRef with the lowest
Tier value takes priority and deploys/updates the resource.
This priority mechanism is only checked after the parent ClusterProfile has won
the primary conflict resolution against other ClusterProfiles.
Higher Tier values represent lower priority. The default Tier value is 100.
format: int32
minimum: 1
type: integer
values:
additionalProperties:
type: string
Expand Down Expand Up @@ -821,6 +834,19 @@ spec:
Defaults to 'None', which translates to the root path of the SourceRef.
Used only for GitRepository;OCIRepository;Bucket
type: string
tier:
default: 100
description: |-
Tier controls the order of deployment for resources coming from different PolicyRefs
within the same ClusterProfile or Profile.
When two PolicyRefs attempt to deploy the same resource, the PolicyRef with the lowest
Tier value takes priority and deploys/updates the resource.
This priority mechanism is only checked after the parent ClusterProfile has won
the primary conflict resolution against other ClusterProfiles.
Higher Tier values represent lower priority. The default Tier value is 100.
format: int32
minimum: 1
type: integer
required:
- kind
- name
Expand Down
26 changes: 26 additions & 0 deletions config/crd/bases/config.projectsveltos.io_clustersummaries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,19 @@ spec:
maxLength: 63
minLength: 1
type: string
tier:
default: 100
description: |-
Tier controls the order of deployment for resources coming from different KustomizationRef
within the same ClusterProfile or Profile.
When two KustomizationRef attempt to deploy the same resource, the KustomizationRef with the lowest
Tier value takes priority and deploys/updates the resource.
This priority mechanism is only checked after the parent ClusterProfile has won
the primary conflict resolution against other ClusterProfiles.
Higher Tier values represent lower priority. The default Tier value is 100.
format: int32
minimum: 1
type: integer
values:
additionalProperties:
type: string
Expand Down Expand Up @@ -958,6 +971,19 @@ spec:
Defaults to 'None', which translates to the root path of the SourceRef.
Used only for GitRepository;OCIRepository;Bucket
type: string
tier:
default: 100
description: |-
Tier controls the order of deployment for resources coming from different PolicyRefs
within the same ClusterProfile or Profile.
When two PolicyRefs attempt to deploy the same resource, the PolicyRef with the lowest
Tier value takes priority and deploys/updates the resource.
This priority mechanism is only checked after the parent ClusterProfile has won
the primary conflict resolution against other ClusterProfiles.
Higher Tier values represent lower priority. The default Tier value is 100.
format: int32
minimum: 1
type: integer
required:
- kind
- name
Expand Down
26 changes: 26 additions & 0 deletions config/crd/bases/config.projectsveltos.io_profiles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,19 @@ spec:
maxLength: 63
minLength: 1
type: string
tier:
default: 100
description: |-
Tier controls the order of deployment for resources coming from different KustomizationRef
within the same ClusterProfile or Profile.
When two KustomizationRef attempt to deploy the same resource, the KustomizationRef with the lowest
Tier value takes priority and deploys/updates the resource.
This priority mechanism is only checked after the parent ClusterProfile has won
the primary conflict resolution against other ClusterProfiles.
Higher Tier values represent lower priority. The default Tier value is 100.
format: int32
minimum: 1
type: integer
values:
additionalProperties:
type: string
Expand Down Expand Up @@ -920,6 +933,19 @@ spec:
Defaults to 'None', which translates to the root path of the SourceRef.
Used only for GitRepository;OCIRepository;Bucket
type: string
tier:
default: 100
description: |-
Tier controls the order of deployment for resources coming from different PolicyRefs
within the same ClusterProfile or Profile.
When two PolicyRefs attempt to deploy the same resource, the PolicyRef with the lowest
Tier value takes priority and deploys/updates the resource.
This priority mechanism is only checked after the parent ClusterProfile has won
the primary conflict resolution against other ClusterProfiles.
Higher Tier values represent lower priority. The default Tier value is 100.
format: int32
minimum: 1
type: integer
required:
- kind
- name
Expand Down
4 changes: 2 additions & 2 deletions controllers/handlers_kustomize.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ func deployKustomizeResources(ctx context.Context, c client.Client, remoteRestCo
Name: kustomizationRef.Name,
}
localReports, err = deployUnstructured(ctx, true, localConfig, c, objectsToDeployLocally,
ref, libsveltosv1beta1.FeatureKustomize, clusterSummary, []string{}, logger)
ref, kustomizationRef.Tier, libsveltosv1beta1.FeatureKustomize, 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 @@ -916,7 +916,7 @@ func deployKustomizeResources(ctx context.Context, c client.Client, remoteRestCo
}

remoteReports, err = deployUnstructured(ctx, false, remoteRestConfig, remoteClient, objectsToDeployRemotely,
ref, libsveltosv1beta1.FeatureKustomize, clusterSummary, []string{}, logger)
ref, kustomizationRef.Tier, libsveltosv1beta1.FeatureKustomize, 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
10 changes: 3 additions & 7 deletions controllers/handlers_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -651,15 +651,11 @@ func deployPolicyRefs(ctx context.Context, c client.Client, remoteConfig *rest.C

refs := featureHandler.getRefs(clusterSummary)

var objectsToDeployLocally []client.Object
var objectsToDeployRemotely []client.Object
var objectsToDeployLocally []referencedObject
var objectsToDeployRemotely []referencedObject
// collect all referenced resources whose content need to be deployed
// in the management cluster (local) or manaded cluster (remote)
objectsToDeployLocally, objectsToDeployRemotely, err =
collectReferencedObjects(ctx, c, clusterSummary, refs, logger)
if err != nil {
return nil, nil, err
}
objectsToDeployLocally, objectsToDeployRemotely = collectReferencedObjects(refs)

return deployReferencedObjects(ctx, c, remoteConfig, remoteClient, clusterSummary,
objectsToDeployLocally, objectsToDeployRemotely, logger)
Expand Down
Loading