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

Handle Userstore failures gracefully without affecting other Userstores #3632

Merged
merged 37 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
8af6af3
Add CircuitBreaker Exception Handling Class
Tiffany-silva Aug 4, 2023
b699ff1
Add CircuitBreaker definition & Verification
Tiffany-silva Aug 4, 2023
18664b4
Implement circuit breaker in ldap & jdbc
Tiffany-silva Aug 4, 2023
38c9359
Refactor class and methods
Tiffany-silva Aug 7, 2023
3f3141e
Refactor classes and methods
Tiffany-silva Aug 8, 2023
d654681
Add circuit breaker to handle old user store manager classes
Tiffany-silva Aug 9, 2023
38a3f9e
Refactor classes and methods
Tiffany-silva Aug 10, 2023
79747b5
Add Circuit breaker to handle authentication step
Tiffany-silva Aug 11, 2023
c1d3b77
Refactor code
Tiffany-silva Aug 30, 2023
4593db8
Refactor code
Tiffany-silva Sep 17, 2023
56ffe3d
added readWriteLock for Circuit Breaker and refactored
Tiffany-silva Sep 17, 2023
c8542f2
Add configurable connection re-establish attempt counter for JDBC cir…
Tiffany-silva Sep 17, 2023
80209ab
Refactored code
Tiffany-silva Sep 18, 2023
3bcce63
Add UI support for connection retry count and delay properties
Tiffany-silva Sep 18, 2023
3b47c93
Add readWriteLock concept and configurable connection retry count for…
Tiffany-silva Sep 18, 2023
7902837
improve readability and update circuit breaker logs
Tiffany-silva Sep 18, 2023
0c38438
Improve styling and refactor userstore classes
Tiffany-silva Sep 20, 2023
05d5379
Merge branch '4.10.x' of https://github.com/wso2/carbon-kernel into f…
Tiffany-silva May 7, 2024
4daa720
Address review comments
Tiffany-silva May 7, 2024
11cb297
Add CircuitBreaker validation to authenticateInternal methods.
Tiffany-silva May 14, 2024
bbbee83
Added circuit breaker validation for authenticate methods.
Tiffany-silva May 20, 2024
eefe3fe
Added circuit breaker validation to retrieve userid for backward comp…
Tiffany-silva May 20, 2024
9fcb49b
Handle initial connection error in authenticate pre- and post-listeners.
Tiffany-silva May 20, 2024
e340775
Add config validation for introduced userstore properties.
Tiffany-silva May 24, 2024
1f31c06
Introduce config properties for userstore circuit breaker.
Tiffany-silva May 24, 2024
f434999
Add introduced property to configuration files.
Tiffany-silva May 28, 2024
c86a454
Add connectionRetryCount property to userstore configuration.
Tiffany-silva May 28, 2024
069fd2d
Add circuit breaker property validation for userstores.
Tiffany-silva May 28, 2024
d32882a
update thresholdtimeout method name for ldap userstore.
Tiffany-silva May 28, 2024
2da7768
Add circuitbreaker support for old pre-listeners.
Tiffany-silva May 31, 2024
f265101
Address review comments.
Tiffany-silva May 31, 2024
9875cc3
Moved Server level configuration to user core.
Tiffany-silva May 31, 2024
504dd13
Updated retrieving circuit breaker server level configuration.
Tiffany-silva May 31, 2024
f5da567
Address review comments.
Tiffany-silva May 31, 2024
8da970c
Merge remote-tracking branch 'upstream/4.10.x' into fix-auth-failure-…
Tiffany-silva Jun 5, 2024
39b7275
Updated warn log to include the domain name.
Tiffany-silva Jun 9, 2024
c92a759
Update circuit breaker validation to listUsers for unique and non-uni…
Tiffany-silva Jun 9, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.user.core;

/**
* The exception to throw when the Circuit Breaker triggers for user stores.
*/
public class CircuitBreakerOpenException extends UserStoreException {

public CircuitBreakerOpenException(String message, Throwable cause) {

super(message, cause);
}

public CircuitBreakerOpenException(String message, String errorCode, Throwable cause) {

super(message, errorCode, cause);
}

public CircuitBreakerOpenException(String message, String errorCode) {

super(message, errorCode);
}

public CircuitBreakerOpenException(String message) {

super(message);
}

public CircuitBreakerOpenException(Throwable cause) {

super(cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public class UserCoreConstants {
public static final String USER_LOCKED = "true";
public static final String USER_UNLOCKED = "false";

// Server level config introduced for backward compatibility with the CircuitBreaker.
public static final String PROP_ENABLE_CIRCUIT_BREAKER_FOR_USERSTORE =
"UserStore.enableCircuitBreakerForUserStores";

public static final class RealmConfig {
public static final String LOCAL_NAME_USER_MANAGER = "UserManager";
public static final String LOCAL_NAME_REALM = "Realm";
Expand Down Expand Up @@ -239,6 +243,9 @@ public static final class RealmConfig {
public static final String LEADING_OR_TRAILING_SPACE_ALLOWED_IN_USERNAME =
"LeadingOrTrailingSpaceAllowedInUserName";
public static final String PROPERTY_USER_ID_ENABLED = "UserIDEnabled";

public static final String CIRCUIT_STATE_OPEN = "open";
public static final String CIRCUIT_STATE_CLOSE = "close";
}

public static final class ClaimTypeURIs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,18 @@ public class UserStoreConfigConstants {
public static final String CONNECTION_RETRY_DELAY_DESCRIPTION = "Specifies waiting time in milliseconds"
+ " inorder to establish the connection after couple of failure attempts.";
public static final int DEFAULT_CONNECTION_RETRY_DELAY_IN_MILLISECONDS = 120000;
public static final String MAX_CONNECTION_RETRY_DELAY_IN_MILLISECONDS =
"UserStore.maxConnectionRetryDelayInMilliSeconds";

public static final String OBJECT_GUID = "objectGuid";

public static final String CONNECTION_RETRY_COUNT = "ConnectionRetryCount";
public static final int DEFAULT_CONNECTION_RETRY_COUNT = 2;
public static final String MAX_CONNECTION_RETRY_COUNT = "UserStore.maxConnectionRetryCount";
public static final String CONNECTION_RETRY_COUNT_DISPLAY_NAME = "Connection Retry Count";
public static final String CONNECTION_RETRY_COUNT_DESCRIPTION = "Specifies connection retry times"
+ " inorder to re-establish the connection on failure";

// Property for specify case insensitivity for User stores.
public static final String CASE_INSENSITIVE_USERNAME = "CaseInsensitiveUsername";
public static final String CASE_INSENSITIVE_USERNAME_DESCRIPTION = "Whether the username is case sensitive or not";
Expand All @@ -198,4 +208,5 @@ public class UserStoreConfigConstants {
public static final String singleValuedAttributesDescription = "Comma-separated list of attributes that need to " +
"skip multi-valued attribute separation";
public static final String singleValuedAttributesDisplayName = "Single Valued Attributes";

}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,17 @@ public class JDBCUserStoreConstants {
"The default auto-commit state of connections created by this pool",
new Property[] { CONNECTION.getProperty(), BOOLEAN.getProperty(), FALSE.getProperty() });

/* Added for circuit breaker implementation. */
setAdvancedProperty(UserStoreConfigConstants.CONNECTION_RETRY_COUNT, UserStoreConfigConstants
.CONNECTION_RETRY_COUNT_DISPLAY_NAME, String.valueOf(UserStoreConfigConstants
.DEFAULT_CONNECTION_RETRY_COUNT), UserStoreConfigConstants.CONNECTION_RETRY_COUNT_DESCRIPTION,
new Property[] { CONNECTION.getProperty(), NUMBER.getProperty(), FALSE.getProperty() });
setAdvancedProperty(UserStoreConfigConstants.CONNECTION_RETRY_DELAY, UserStoreConfigConstants.
CONNECTION_RETRY_DELAY_DISPLAY_NAME, String.valueOf(UserStoreConfigConstants
.DEFAULT_CONNECTION_RETRY_DELAY_IN_MILLISECONDS), UserStoreConfigConstants
.CONNECTION_RETRY_DELAY_DESCRIPTION, new Property[] { CONNECTION.getProperty(), NUMBER.getProperty(),
FALSE.getProperty() });

setAdvancedProperty(JDBCRealmConstants.DEFAULT_READ_ONLY, "Default Read Only", "",
"The default read-only state of connections created by this pool",
new Property[] { CONNECTION.getProperty(), BOOLEAN.getProperty(), FALSE.getProperty() });
Expand Down
Loading