Skip to content

Commit cdd9d70

Browse files
jcrossley3knative-prow-robot
authored andcommitted
Update to latest manifestival to apply strategic merge patches to its resources. (knative#243)
* Pull in latest manifestival client-go branch This employs the k8s 3-way strategic merging for all manifest resources except ConfigMaps. This makes manifestival's Apply behave like kubectl apply. * Eliminate superfluous updates on Deployments and Images among others This should remove the noise in the logs from manifestival trying to update resources right after they're created. When we convert from unstructured to typed structs and back, we get zeroed defaults added to the unstructured objects (usually creationTimestamp) which manifestival interprets as a change worth persisting.
1 parent 5fc98d3 commit cdd9d70

File tree

7 files changed

+355
-42
lines changed

7 files changed

+355
-42
lines changed

Gopkg.lock

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/reconciler/knativeserving/common/certs.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"go.uber.org/zap"
2424
appsv1 "k8s.io/api/apps/v1"
2525
v1 "k8s.io/api/core/v1"
26+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2627
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2728
"k8s.io/client-go/kubernetes/scheme"
2829
servingv1alpha1 "knative.dev/serving-operator/pkg/apis/serving/v1alpha1"
@@ -54,6 +55,8 @@ func CustomCertsTransform(instance *servingv1alpha1.KnativeServing, log *zap.Sug
5455
if err := scheme.Scheme.Convert(deployment, u, nil); err != nil {
5556
return err
5657
}
58+
// Avoid superfluous updates from converted zero defaults
59+
u.SetCreationTimestamp(metav1.Time{})
5760
}
5861
return nil
5962
}

pkg/reconciler/knativeserving/common/images.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"go.uber.org/zap"
2323
appsv1 "k8s.io/api/apps/v1"
2424
corev1 "k8s.io/api/core/v1"
25+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2627
"k8s.io/client-go/kubernetes/scheme"
2728
caching "knative.dev/caching/pkg/apis/caching/v1alpha1"
@@ -75,6 +76,9 @@ func updateDeployment(instance *servingv1alpha1.KnativeServing, u *unstructured.
7576
if err != nil {
7677
return err
7778
}
79+
// The zero-value timestamp defaulted by the conversion causes
80+
// superfluous updates
81+
u.SetCreationTimestamp(metav1.Time{})
7882

7983
log.Debugw("Finished conversion", "name", u.GetName(), "unstructured", u.Object)
8084
return nil
@@ -109,6 +113,10 @@ func updateCachingImage(instance *servingv1alpha1.KnativeServing, u *unstructure
109113
if err != nil {
110114
return err
111115
}
116+
// Cleanup zero-value default to prevent superfluous updates
117+
u.SetCreationTimestamp(metav1.Time{})
118+
delete(u.Object, "status")
119+
112120
log.Debugw("Finished conversion", "name", u.GetName(), "unstructured", u.Object)
113121
return nil
114122
}

third_party/VENDOR-LICENSE

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,37 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
11631163
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11641164

11651165

1166+
===========================================================
1167+
Import: knative.dev/serving-operator/vendor/github.com/evanphx/json-patch
1168+
1169+
Copyright (c) 2014, Evan Phoenix
1170+
All rights reserved.
1171+
1172+
Redistribution and use in source and binary forms, with or without
1173+
modification, are permitted provided that the following conditions are met:
1174+
1175+
* Redistributions of source code must retain the above copyright notice, this
1176+
list of conditions and the following disclaimer.
1177+
* Redistributions in binary form must reproduce the above copyright notice
1178+
this list of conditions and the following disclaimer in the documentation
1179+
and/or other materials provided with the distribution.
1180+
* Neither the name of the Evan Phoenix nor the names of its contributors
1181+
may be used to endorse or promote products derived from this software
1182+
without specific prior written permission.
1183+
1184+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1185+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1186+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1187+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
1188+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1189+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1190+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1191+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1192+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1193+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1194+
1195+
1196+
11661197
===========================================================
11671198
Import: knative.dev/serving-operator/vendor/github.com/go-logr/logr
11681199

@@ -8524,4 +8555,3 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
85248555
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
85258556
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
85268557
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
8527-

vendor/github.com/jcrossley3/manifestival/manifestival.go

Lines changed: 14 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/jcrossley3/manifestival/patch/patch.go

Lines changed: 131 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)