Skip to content
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

Bug 1818021 - Implement observedDigest #842

Merged
merged 7 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/app/plan/components/Wizard/VolumesForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const VolumesForm: React.FunctionComponent<IVolumesFormProps> = ({
}, []);

const discoveredPersistentVolumes = (currentPlan && currentPlan.spec.persistentVolumes) || [];

useEffect(() => {
if (discoveredPersistentVolumes.length > 0) {
getPVResourcesRequest(discoveredPersistentVolumes, values.sourceCluster || '');
Expand Down Expand Up @@ -103,7 +102,7 @@ const VolumesForm: React.FunctionComponent<IVolumesFormProps> = ({
}
setFieldValue('persistentVolumes', mappedPVs);
}
}, [discoveredPersistentVolumes.length]); // Only re-run the effect if fetching value changes
}, [discoveredPersistentVolumes, currentPlanStatus]); // Only re-run the effect if fetching value changes

//TODO: added this component level error state to handle the case of no PVs
// showing up after 3 checks of the interval. When the isPVError flag is checked,
Expand Down
24 changes: 15 additions & 9 deletions src/app/plan/duck/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ function* planUpdateRetry(action) {
JSON.stringify(getPlanRes.data.spec.srcMigClusterRef.name) !==
JSON.stringify(planValues.sourceCluster)
) {
const updatedPlanRes = yield client.patch(
yield client.patch(
new MigResource(MigResourceKind.MigPlan, migMeta.namespace),
getPlanRes.data.metadata.name,
updatedMigPlan
Expand Down Expand Up @@ -287,17 +287,23 @@ function* checkUpdatedPVs(action) {

if (updatedPlan) {
const isUpdatedPVList = () => {
const updatedGeneration = updatedPlan.metadata.generation;
const oldGeneration = currentPlan.metadata.generation;

//Generation check incremented twice: once for ui change, once for controller change.
if (isRerunPVDiscovery) {
return updatedGeneration >= oldGeneration + 2;
// TODO: refactor this function to improve logic.
if (updatedPlan.status) {
if (isRerunPVDiscovery) {
const updatedObservedDigest = updatedPlan.status.observedDigest;
const oldObservedDigest = currentPlan.status.observedDigest;
if (updatedObservedDigest === oldObservedDigest) {
return false;
} else {
return true;
}
} else {
return true;
}
} else {
return updatedGeneration > 1;
return false;
}
};

if (isUpdatedPVList()) {
yield put(PlanActions.setCurrentPlan(updatedPlan));
yield put(PlanActions.pvUpdateSuccess());
Expand Down