Skip to content
Open
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
10 changes: 5 additions & 5 deletions pkg/reconciler/revision/cruds.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,6 @@ func (c *Reconciler) checkAndUpdateDeployment(ctx context.Context, rev *v1.Revis
// TODO(dprotaso): determine other immutable properties.
deployment.Spec.Selector = have.Spec.Selector

// If the spec we want is the spec we have, then we're good.
if equality.Semantic.DeepEqual(have.Spec, deployment.Spec) {
return have, nil
}

// Otherwise attempt an update (with ONLY the spec changes).
desiredDeployment := have.DeepCopy()
desiredDeployment.Spec = deployment.Spec
Expand All @@ -80,6 +75,11 @@ func (c *Reconciler) checkAndUpdateDeployment(ctx context.Context, rev *v1.Revis
desiredDeployment.Spec.Template.Labels = mergeMetadata(deployment.Spec.Template.Labels, have.Spec.Template.Labels)
desiredDeployment.Spec.Template.Annotations = mergeMetadata(deployment.Spec.Template.Annotations, have.Spec.Template.Annotations)

// If the spec we want is the spec we have, then we're good.
if equality.Semantic.DeepEqual(have.Spec, desiredDeployment.Spec) {
return have, nil
}

d, err := c.kubeclient.AppsV1().Deployments(deployment.Namespace).Update(ctx, desiredDeployment, metav1.UpdateOptions{})
if err != nil {
return nil, err
Expand Down
10 changes: 10 additions & 0 deletions pkg/reconciler/revision/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,16 @@ func TestReconcile(t *testing.T) {
Object: addDeploymentMetadata(deploy(t, "foo", "preserve-annotations"), false),
}},
Key: "foo/preserve-annotations",
}, {
Name: "do not update deployments with no spec changes",
Objects: []runtime.Object{
Revision("foo", "preserve-annotations",
WithLogURL, allUnknownConditions, withDefaultContainerStatuses(), WithRevisionObservedGeneration(1)),
pa("foo", "preserve-annotations", WithReachabilityUnknown),
addDeploymentMetadata(deploy(t, "foo", "preserve-annotations"), false),
image("foo", "preserve-annotations"),
},
Key: "foo/preserve-annotations",
}, {
Name: "failure updating deployment",
// Test that we handle an error updating the deployment properly.
Expand Down
Loading