You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Config and live object are all handled with remarshal(), should object from LastAppliedConfigAnnotation need to be handled with remarshal() too? This can avoid null values in LastAppliedConfigAnnotation make diff result different.
Related Code
func Diff(config, live *unstructured.Unstructured, opts ...Option) (*DiffResult, error) {
o := applyOptions(opts)
if config != nil {
config = remarshal(config, o)
Normalize(config, opts...)
}
if live != nil {
live = remarshal(live, o)
Normalize(live, opts...)
}
orig, err := GetLastAppliedConfigAnnotation(live)
if err != nil {
o.log.V(1).Info(fmt.Sprintf("Failed to get last applied configuration: %v", err))
} else {
if orig != nil && config != nil {
orig = remarshal(orig, o) // add core here
Normalize(orig, opts...)
dr, err := ThreeWayDiff(orig, config, live)
if err == nil {
return dr, nil
}
o.log.V(1).Info(fmt.Sprintf("three-way diff calculation failed: %v. Falling back to two-way diff", err))
}
}
return TwoWayDiff(config, live)
}
apiVersion: v1
kind: Service
metadata:
labels:
argocd.argoproj.io/instance: test
name: test
namespace: default
spec:
ports:
- name: http
nodePort: null
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: test
type: NodePort
When someone set nodePort of Service to null, k8s will allocate a port to the Service, so the live object will have nodePort: 30395 and config object will have nodePort: null, remarshal() will clear nodePort: null, so there will be no diff between live object and config object, but object from LastAppliedConfigAnnotation without remarshal() will broke the result, mark application OutOfSync, Maybe we can prevent this meaningless sync.
The text was updated successfully, but these errors were encountered:
Description
Config and live object are all handled with remarshal(), should object from LastAppliedConfigAnnotation need to be handled with remarshal() too? This can avoid null values in LastAppliedConfigAnnotation make diff result different.
Related Code
Example
live object:
config object:
When someone set
nodePort
of Service to null, k8s will allocate a port to the Service, so the live object will havenodePort: 30395
and config object will havenodePort: null
, remarshal() will clearnodePort: null
, so there will be no diff between live object and config object, but object from LastAppliedConfigAnnotation without remarshal() will broke the result, mark application OutOfSync, Maybe we can prevent this meaningless sync.The text was updated successfully, but these errors were encountered: