-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9dd3f6f
commit 3d83c4f
Showing
1 changed file
with
21 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -289,9 +289,12 @@ func (c *DeploymentConfigController) reconcileDeployments(existingDeployments [] | |
} | ||
|
||
func (c *DeploymentConfigController) updateStatus(config *deployapi.DeploymentConfig) error { | ||
if config.Generation > config.Status.ObservedGeneration { | ||
config.Status.ObservedGeneration = config.Generation | ||
// NOTE: We should update the status of the deployment config only if we need to, otherwise | ||
// we hotloop between updates. | ||
if !needsUpdate(config) { | ||
return nil | ||
} | ||
config.Status.ObservedGeneration = config.Generation | ||
if _, err := c.dn.DeploymentConfigs(config.Namespace).UpdateStatus(config); err != nil { | ||
glog.V(2).Infof("Cannot update the status for %q: %v", deployutil.LabelForDeploymentConfig(config), err) | ||
return transientError(err.Error()) | ||
|
@@ -300,18 +303,6 @@ func (c *DeploymentConfigController) updateStatus(config *deployapi.DeploymentCo | |
return nil | ||
} | ||
|
||
func deploymentCopy(rc *kapi.ReplicationController) (*kapi.ReplicationController, error) { | ||
objCopy, err := kapi.Scheme.DeepCopy(rc) | ||
if err != nil { | ||
return nil, err | ||
} | ||
copied, ok := objCopy.(*kapi.ReplicationController) | ||
if !ok { | ||
return nil, fmt.Errorf("expected ReplicationController, got %#v", objCopy) | ||
} | ||
return copied, nil | ||
} | ||
|
||
func (c *DeploymentConfigController) handleErr(err error, key interface{}) { | ||
if _, isFatal := err.(fatalError); isFatal { | ||
utilruntime.HandleError(err) | ||
|
@@ -325,3 +316,19 @@ func (c *DeploymentConfigController) handleErr(err error, key interface{}) { | |
} | ||
utilruntime.HandleError(err) | ||
} | ||
|
||
func needsUpdate(config *deployapi.DeploymentConfig) bool { | ||
return config.Generation > config.Status.ObservedGeneration | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
0xmichalis
Author
Contributor
|
||
} | ||
|
||
func deploymentCopy(rc *kapi.ReplicationController) (*kapi.ReplicationController, error) { | ||
objCopy, err := kapi.Scheme.DeepCopy(rc) | ||
if err != nil { | ||
return nil, err | ||
} | ||
copied, ok := objCopy.(*kapi.ReplicationController) | ||
if !ok { | ||
return nil, fmt.Errorf("expected ReplicationController, got %#v", objCopy) | ||
} | ||
return copied, nil | ||
} |
So is it correct/reasonable to do this check before enqueuing the work?