-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: discard update action on notify only #1637
base: main
Are you sure you want to change the base?
Conversation
@@ -504,10 +505,12 @@ private void cancelCurrentDeployment() { | |||
.isCancellable()) { | |||
logger.atInfo().log("Deployment already finished processing or cannot be cancelled"); | |||
} else { | |||
boolean canCancelDeployment = context.get(UpdateSystemPolicyService.class).discardPendingUpdateAction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, this returns true
for the deployments that do not have the update policy set to DeploymentComponentUpdatePolicyAction.NOTIFY_COMPONENTS
which is wrong. We should discard an update only when the policy is set to notify.
logger.atError().setEventType("service-update-action-error").addKeyValue("action", todo.getKey()) | ||
.setCause(t).log(); | ||
} | ||
final UpdateAction pendingUpdateAction = pendingActions.remove(deploymentId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix: Pending actions that only correspond to the specified deployment id should be performed.
Fix and refactor: Rely on pendingActions
map to check if the update action is in progress/completed or never added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that a deferred deployment cannot be cancelled? Ideally, if a component is deferring a config merge due a deployment, this deployment should still be cancellable given that defer period is still ongoing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Deferred deployments are still cancellable. That code path is not modified.
runUpdateActions
is run only after we waited enough for the deferred time.- While we're waiting for the deferred time, deployment pending actions can be discarded upon request.
|
||
boolean ggcRestarting = false; | ||
for (UpdateAction action : pendingActions.values()) { | ||
if (action.isGgcRestart()) { | ||
ggcRestarting = true; | ||
break; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix: Restarting GG feature flag should be set only for the update actions of a single deployment ID.
|
||
PreComponentUpdateEvent preComponentUpdateEvent = new PreComponentUpdateEvent(); | ||
preComponentUpdateEvent.setIsGgcRestarting(ggcRestarting); | ||
String deploymentId = pendingActions.values().stream().map(UpdateAction::getDeploymentId).findFirst().get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix: At this point, pendingActions
can be empty and result in NPE. So, we send component updates only if there's an entry by invoking a consumer with ifPresent
.
return false; | ||
} | ||
final UpdateAction pendingUpdateAction = pendingActions.get(tag); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix - race: A thread can reach this point before the update action is completed (but in progress) resulting in returning an incorrect value for discardPendingUpdateAction
and sending two post update events (one via runUpdateActions
and other via discardPendingUpdateAction
). This is because 1/ runUpdateActions
removes the action from the map only after it is completed 2/ No locking used while accessing/modifying the map .
Use remove
to ensure that the updated state is reflected across threads.
src/main/java/com/aws/greengrass/lifecyclemanager/UpdateSystemPolicyService.java
Outdated
Show resolved
Hide resolved
src/main/java/com/aws/greengrass/lifecyclemanager/UpdateSystemPolicyService.java
Outdated
Show resolved
Hide resolved
7eb23e6
to
6894e18
Compare
6894e18
to
cda58eb
Compare
Binary incompatibility detected for commit cda58eb. com.aws.greengrass.deployment.DeploymentConfigMerger is binary incompatible and is source incompatible because of CONSTRUCTOR_REMOVED Produced by binaryCompatability.py |
Unit Tests Coverage Report
Minimum allowed coverage is Generated by 🐒 cobertura-action against cda58eb |
Integration Tests Coverage Report
Minimum allowed coverage is Generated by 🐒 cobertura-action against cda58eb |
Issue #, if available:
Description of changes:
Why is this change necessary:
How was this change tested:
Any additional information or context required to review the change:
Documentation Checklist:
Compatibility Checklist:
any deprecated method or type.
Refer to Compatibility Guidelines for more information.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.