Merge pull request #936 from fluxcd/flux-gc-skip

Remove Flux GC markers from generated objects
This commit is contained in:
Stefan Prodan
2021-06-15 18:08:32 +03:00
committed by GitHub
7 changed files with 24 additions and 6 deletions
+4
View File
@@ -83,6 +83,10 @@ func makeAnnotations(annotations map[string]string) (map[string]string, error) {
id := fmt.Sprintf("%x-%x-%x-%x-%x", uuid[0:4], uuid[4:6], uuid[6:8], uuid[8:10], uuid[10:])
for k, v := range annotations {
// skip Flux GC markers
if strings.Contains(k, "/checksum") {
continue
}
if k != idKey {
res[k] = v
}
+2 -2
View File
@@ -211,7 +211,7 @@ func (i *IngressRouter) SetRoutes(
func (i *IngressRouter) makeAnnotations(annotations map[string]string) map[string]string {
res := make(map[string]string)
for k, v := range annotations {
for k, v := range makeAnnotations(annotations) {
if !strings.Contains(k, i.GetAnnotationWithPrefix("canary")) &&
!strings.Contains(k, "kubectl.kubernetes.io/last-applied-configuration") &&
!strings.Contains(k, i.GetAnnotationWithPrefix("canary-weight")) &&
@@ -232,7 +232,7 @@ func (i *IngressRouter) makeAnnotations(annotations map[string]string) map[strin
func (i *IngressRouter) makeHeaderAnnotations(annotations map[string]string,
header string, headerValue string, headerRegex string, cookie string) map[string]string {
res := make(map[string]string)
for k, v := range annotations {
for k, v := range makeAnnotations(annotations) {
if !strings.Contains(v, i.GetAnnotationWithPrefix("canary")) {
res[k] = v
}
+2
View File
@@ -259,6 +259,8 @@ func (ir *IstioRouter) reconcileVirtualService(canary *flaggerv1.Canary) error {
if vtClone.ObjectMeta.Annotations == nil {
vtClone.ObjectMeta.Annotations = make(map[string]string)
} else {
vtClone.ObjectMeta.Annotations = makeAnnotations(vtClone.ObjectMeta.Annotations)
}
vtClone.ObjectMeta.Annotations[configAnnotation] = string(b)
+2 -2
View File
@@ -206,8 +206,8 @@ func (c *KubernetesDefaultRouter) reconcileService(canary *flaggerv1.Canary, nam
if svc.ObjectMeta.Annotations == nil {
svc.ObjectMeta.Annotations = make(map[string]string)
}
if diff := cmp.Diff(metadata.Annotations, svc.ObjectMeta.Annotations); diff != "" {
svcClone.ObjectMeta.Annotations = metadata.Annotations
if diff := cmp.Diff(makeAnnotations(metadata.Annotations), svc.ObjectMeta.Annotations); diff != "" {
svcClone.ObjectMeta.Annotations = makeAnnotations(metadata.Annotations)
updateService = true
}
if diff := cmp.Diff(metadata.Labels, svc.ObjectMeta.Labels); diff != "" {
+1 -1
View File
@@ -129,7 +129,7 @@ func (skp *SkipperRouter) Reconcile(canary *flaggerv1.Canary) error {
if cmp.Diff(iClone.Spec, canaryIngress.Spec) != "" {
ingressClone := canaryIngress.DeepCopy()
ingressClone.Spec = iClone.Spec
ingressClone.Annotations = iClone.Annotations
ingressClone.Annotations = makeAnnotations(iClone.Annotations)
_, err := skp.kubeClient.NetworkingV1().Ingresses(canary.Namespace).Update(context.TODO(), ingressClone, metav1.UpdateOptions{})
if err != nil {
+1 -1
View File
@@ -72,7 +72,7 @@ func (tr *TraefikRouter) Reconcile(canary *flaggerv1.Canary) error {
Name: apexName,
Namespace: canary.Namespace,
Labels: tsMetadata.Labels,
Annotations: tsMetadata.Annotations,
Annotations: makeAnnotations(tsMetadata.Annotations),
OwnerReferences: []metav1.OwnerReference{
*metav1.NewControllerRef(canary, schema.GroupVersionKind{
Group: flaggerv1.SchemeGroupVersion.Group,
+12
View File
@@ -17,3 +17,15 @@ func includeLabelsByPrefix(labels map[string]string, includeLabelPrefixes []stri
return filteredLabels
}
func makeAnnotations(in map[string]string) map[string]string {
out := make(map[string]string)
for key, value := range in {
// skip Flux GC markers
if strings.Contains(key, "/checksum") {
continue
}
out[key] = value
}
return out
}