fix: added ff fallback if cs is down (#27187)
## Description > This PR returns only the local flags if the CS is down and there are no cached flags. #### PR fixes following issue(s) Fixes #25977 #### Type of change - Bug fix ## Testing #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed
This commit is contained in:
parent
d463b0a7c1
commit
19cc756467
|
|
@ -22,11 +22,13 @@ import com.appsmith.server.solutions.ReleaseNotesService;
|
|||
import com.appsmith.util.WebClientUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.web.reactive.function.BodyInserters;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
|
@ -51,6 +53,11 @@ public class CacheableFeatureFlagHelperCEImpl implements CacheableFeatureFlagHel
|
|||
CachedFlags cachedFlags = new CachedFlags();
|
||||
cachedFlags.setRefreshedAt(Instant.now());
|
||||
cachedFlags.setFlags(flags);
|
||||
// if cs is down, returning the empty flags, so the request doesn't error out.
|
||||
// setting the refreshed at to an older time, so that the next call reaches to CS
|
||||
if (flags.isEmpty()) {
|
||||
cachedFlags.setRefreshedAt(Instant.now().minus(1, ChronoUnit.DAYS));
|
||||
}
|
||||
return Mono.just(cachedFlags);
|
||||
});
|
||||
}
|
||||
|
|
@ -105,7 +112,7 @@ public class CacheableFeatureFlagHelperCEImpl implements CacheableFeatureFlagHel
|
|||
return this.getRemoteFeatureFlagsByIdentity(new FeatureFlagIdentityTraits(
|
||||
objects.getT1(), tenantId, Set.of(userIdentifier), objects.getT3()));
|
||||
})
|
||||
.map(newValue -> newValue.get(userIdentifier));
|
||||
.map(newValue -> ObjectUtils.defaultIfNull(newValue.get(userIdentifier), Map.of()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user