diff --git a/addon/v1alpha1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml b/addon/v1alpha1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml index 2c808a89b..93c91fa29 100644 --- a/addon/v1alpha1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml +++ b/addon/v1alpha1/0000_03_addon.open-cluster-management.io_addontemplates.crd.yaml @@ -271,19 +271,32 @@ spec: paths in the resource that will not be updated on the spoke. items: - type: string + properties: + condition: + default: OnSpokePresent + description: |- + Condition defines the condition that the fields should be ignored when apply the resource. + Fields in JSONPaths are all ignored when condition is met, otherwise no fields is ignored + in the apply operation. + enum: + - OnSpokePresent + - OnSpokeChange + type: string + jsonPaths: + description: JSONPaths defines the list of + json path in the resource to be ignored + items: + type: string + minItems: 1 + type: array + required: + - condition + - jsonPaths + type: object type: array - onSpokeChange: - default: Override - description: |- - OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed - on the spoke by another actor. - enum: - - Override - - NoOverride - type: string - required: - - onSpokeChange + x-kubernetes-list-map-keys: + - condition + x-kubernetes-list-type: map type: object type: default: Update @@ -302,17 +315,6 @@ spec: - ServerSideApply - ReadOnly type: string - update: - description: |- - update defines the configuration for update. It is honored only when the type of the updateStrategy - is Update - properties: - onSpokeChange: - description: |- - OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed - on the spoke by another actor. - type: string - type: object required: - type type: object diff --git a/work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml b/work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml index b7096f9d7..4ab3403c7 100644 --- a/work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml +++ b/work/v1/0000_00_work.open-cluster-management.io_manifestworks.crd.yaml @@ -253,19 +253,32 @@ spec: description: IgnoreFields defines a list of json paths in the resource that will not be updated on the spoke. items: - type: string + properties: + condition: + default: OnSpokePresent + description: |- + Condition defines the condition that the fields should be ignored when apply the resource. + Fields in JSONPaths are all ignored when condition is met, otherwise no fields is ignored + in the apply operation. + enum: + - OnSpokePresent + - OnSpokeChange + type: string + jsonPaths: + description: JSONPaths defines the list of json + path in the resource to be ignored + items: + type: string + minItems: 1 + type: array + required: + - condition + - jsonPaths + type: object type: array - onSpokeChange: - default: Override - description: |- - OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed - on the spoke by another actor. - enum: - - Override - - NoOverride - type: string - required: - - onSpokeChange + x-kubernetes-list-map-keys: + - condition + x-kubernetes-list-type: map type: object type: default: Update @@ -284,17 +297,6 @@ spec: - ServerSideApply - ReadOnly type: string - update: - description: |- - update defines the configuration for update. It is honored only when the type of the updateStrategy - is Update - properties: - onSpokeChange: - description: |- - OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed - on the spoke by another actor. - type: string - type: object required: - type type: object diff --git a/work/v1/types.go b/work/v1/types.go index 1b90a36e2..f7c271f44 100644 --- a/work/v1/types.go +++ b/work/v1/types.go @@ -174,13 +174,10 @@ type UpdateStrategy struct { // type of the updateStrategy is ServerSideApply // +optional ServerSideApply *ServerSideApplyConfig `json:"serverSideApply,omitempty"` - - // update defines the configuration for update. It is honored only when the type of the updateStrategy - // is Update - Update *UpdateConfig `json:"update,omitempty"` } type UpdateStrategyType string +type IgnoreFieldsCondition string const ( // UpdateStrategyTypeUpdate means to update resource by an update call. @@ -200,6 +197,13 @@ const ( // If the statusFeedBackRules are set, the feedbackResult will also be returned. // The resource will not be removed when the type is ReadOnly, and only resource metadata is required. UpdateStrategyTypeReadOnly UpdateStrategyType = "ReadOnly" + + // IgnoreFieldsConditionOnSpokeChange is the condition when resource fields is updated by another actor + // on the spoke cluster. + IgnoreFieldsConditionOnSpokeChange IgnoreFieldsCondition = "OnSpokeChange" + + // IgnoreFieldsConditionOnSpokePresent is the condition when the resource exist on the spoke cluster. + IgnoreFieldsConditionOnSpokePresent IgnoreFieldsCondition = "OnSpokePresent" ) type ServerSideApplyConfig struct { @@ -215,21 +219,27 @@ type ServerSideApplyConfig struct { FieldManager string `json:"fieldManager,omitempty"` // IgnoreFields defines a list of json paths in the resource that will not be updated on the spoke. - IgnoreFields []string `json:"ignoreFields,omitempty"` + // +listType:=map + // +listMapKey:=condition + // +optional + IgnoreFields []IgnoreField `json:"ignoreFields,omitempty"` +} - // OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed - // on the spoke by another actor. - // +kubebuilder:default=Override - // +kubebuilder:validation:Enum=Override;NoOverride +type IgnoreField struct { + // Condition defines the condition that the fields should be ignored when apply the resource. + // Fields in JSONPaths are all ignored when condition is met, otherwise no fields is ignored + // in the apply operation. + // +kubebuilder:default=OnSpokePresent + // +kubebuilder:validation:Enum=OnSpokePresent;OnSpokeChange // +kubebuilder:validation:Required // +required - OnSpokeChange string `json:"onSpokeChange,omitempty"` -} + Condition IgnoreFieldsCondition `json:"condition"` -type UpdateConfig struct { - // OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed - // on the spoke by another actor. - OnSpokeChange string `json:"onSpokeChange,omitempty"` + // JSONPaths defines the list of json path in the resource to be ignored + // +kubebuilder:validation:Required + // +kubebuilder:validation:MinItems=1 + // +required + JSONPaths []string `json:"jsonPaths"` } // DefaultFieldManager is the default field manager of the manifestwork when the field manager is not set. @@ -525,6 +535,10 @@ const ( // ensure all resource relates to appliedmanifestwork is deleted before appliedmanifestwork itself // is deleted. AppliedManifestWorkFinalizer = "cluster.open-cluster-management.io/applied-manifest-work-cleanup" + + // ObjectSpecHash is the key of the annotation on the applied resources. The value is the computed hash + // from the resource manifests in the manifestwork. + ObjectSpecHash = "open-cluster-management.io/object-hash" ) // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/work/v1/zz_generated.deepcopy.go b/work/v1/zz_generated.deepcopy.go index e242ed40d..a09a23b62 100644 --- a/work/v1/zz_generated.deepcopy.go +++ b/work/v1/zz_generated.deepcopy.go @@ -224,6 +224,27 @@ func (in *FieldValue) DeepCopy() *FieldValue { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IgnoreField) DeepCopyInto(out *IgnoreField) { + *out = *in + if in.JSONPaths != nil { + in, out := &in.JSONPaths, &out.JSONPaths + *out = make([]string, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IgnoreField. +func (in *IgnoreField) DeepCopy() *IgnoreField { + if in == nil { + return nil + } + out := new(IgnoreField) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *JsonPath) DeepCopyInto(out *JsonPath) { *out = *in @@ -604,8 +625,10 @@ func (in *ServerSideApplyConfig) DeepCopyInto(out *ServerSideApplyConfig) { *out = *in if in.IgnoreFields != nil { in, out := &in.IgnoreFields, &out.IgnoreFields - *out = make([]string, len(*in)) - copy(*out, *in) + *out = make([]IgnoreField, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } return } @@ -643,22 +666,6 @@ func (in *StatusFeedbackResult) DeepCopy() *StatusFeedbackResult { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *UpdateConfig) DeepCopyInto(out *UpdateConfig) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdateConfig. -func (in *UpdateConfig) DeepCopy() *UpdateConfig { - if in == nil { - return nil - } - out := new(UpdateConfig) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UpdateStrategy) DeepCopyInto(out *UpdateStrategy) { *out = *in @@ -667,11 +674,6 @@ func (in *UpdateStrategy) DeepCopyInto(out *UpdateStrategy) { *out = new(ServerSideApplyConfig) (*in).DeepCopyInto(*out) } - if in.Update != nil { - in, out := &in.Update, &out.Update - *out = new(UpdateConfig) - **out = **in - } return } diff --git a/work/v1/zz_generated.swagger_doc_generated.go b/work/v1/zz_generated.swagger_doc_generated.go index aae77962b..97385341a 100644 --- a/work/v1/zz_generated.swagger_doc_generated.go +++ b/work/v1/zz_generated.swagger_doc_generated.go @@ -102,6 +102,15 @@ func (FieldValue) SwaggerDoc() map[string]string { return map_FieldValue } +var map_IgnoreField = map[string]string{ + "condition": "Condition defines the condition that the fields should be ignored when apply the resource. Fields in JSONPaths are all ignored when condition is met, otherwise no fields is ignored in the apply operation.", + "jsonPaths": "JSONPaths defines the list of json path in the resource to be ignored", +} + +func (IgnoreField) SwaggerDoc() map[string]string { + return map_IgnoreField +} + var map_JsonPath = map[string]string{ "name": "Name represents the alias name for this field", "version": "Version is the version of the Kubernetes resource. If it is not specified, the resource with the semantically latest version is used to resolve the path.", @@ -268,10 +277,9 @@ func (SelectivelyOrphan) SwaggerDoc() map[string]string { } var map_ServerSideApplyConfig = map[string]string{ - "force": "Force represents to force apply the manifest.", - "fieldManager": "FieldManager is the manager to apply the resource. It is work-agent by default, but can be other name with work-agent as the prefix.", - "ignoreFields": "IgnoreFields defines a list of json paths in the resource that will not be updated on the spoke.", - "onSpokeChange": "OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed on the spoke by another actor.", + "force": "Force represents to force apply the manifest.", + "fieldManager": "FieldManager is the manager to apply the resource. It is work-agent by default, but can be other name with work-agent as the prefix.", + "ignoreFields": "IgnoreFields defines a list of json paths in the resource that will not be updated on the spoke.", } func (ServerSideApplyConfig) SwaggerDoc() map[string]string { @@ -287,19 +295,10 @@ func (StatusFeedbackResult) SwaggerDoc() map[string]string { return map_StatusFeedbackResult } -var map_UpdateConfig = map[string]string{ - "onSpokeChange": "OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed on the spoke by another actor.", -} - -func (UpdateConfig) SwaggerDoc() map[string]string { - return map_UpdateConfig -} - var map_UpdateStrategy = map[string]string{ "": "UpdateStrategy defines the strategy to update this manifest", "type": "type defines the strategy to update this manifest, default value is Update. Update type means to update resource by an update call. CreateOnly type means do not update resource based on current manifest. ServerSideApply type means to update resource using server side apply with work-controller as the field manager. If there is conflict, the related Applied condition of manifest will be in the status of False with the reason of ApplyConflict. ReadOnly type means the agent will only check the existence of the resource based on its metadata, statusFeedBackRules can still be used to get feedbackResults.", "serverSideApply": "serverSideApply defines the configuration for server side apply. It is honored only when the type of the updateStrategy is ServerSideApply", - "update": "update defines the configuration for update. It is honored only when the type of the updateStrategy is Update", } func (UpdateStrategy) SwaggerDoc() map[string]string { diff --git a/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml b/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml index 4ad47ec39..3d6de1d72 100644 --- a/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml +++ b/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml @@ -278,19 +278,32 @@ spec: paths in the resource that will not be updated on the spoke. items: - type: string + properties: + condition: + default: OnSpokePresent + description: |- + Condition defines the condition that the fields should be ignored when apply the resource. + Fields in JSONPaths are all ignored when condition is met, otherwise no fields is ignored + in the apply operation. + enum: + - OnSpokePresent + - OnSpokeChange + type: string + jsonPaths: + description: JSONPaths defines the list of + json path in the resource to be ignored + items: + type: string + minItems: 1 + type: array + required: + - condition + - jsonPaths + type: object type: array - onSpokeChange: - default: Override - description: |- - OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed - on the spoke by another actor. - enum: - - Override - - NoOverride - type: string - required: - - onSpokeChange + x-kubernetes-list-map-keys: + - condition + x-kubernetes-list-type: map type: object type: default: Update @@ -309,17 +322,6 @@ spec: - ServerSideApply - ReadOnly type: string - update: - description: |- - update defines the configuration for update. It is honored only when the type of the updateStrategy - is Update - properties: - onSpokeChange: - description: |- - OnSpokeChange defines whether the resource should be overriden by the manifestwork it is changed - on the spoke by another actor. - type: string - type: object required: - type type: object