Skip to content

Commit

Permalink
Issue 30288 small fixes (#30289)
Browse files Browse the repository at this point in the history
This pull request includes several changes across different files,
focusing on updating health check paths, improving error handling, and
removing outdated JSP files. The most important changes include
modifying Kubernetes health check configurations, enhancing error
handling in the `CMSFilter` class, and cleaning up old JSP files.

### Kubernetes Configuration Updates:
*
[`docker/k8s-aws-eks-manifest-examples/alb.yaml`](diffhunk://#diff-183dd63ca7f7d70f78b13d9811fa2d67e3ae037897c9f9d9e7f37e48083a4b40L29-R29):
Updated the health check path to `/api/v1/alive`.
*
[`docker/k8s-aws-eks-manifest-examples/statefulset.yaml`](diffhunk://#diff-4afce029dc91e63bc9ec03ef86772471786be1a649c63676b2cbef411c28f23dL105-R105):
Updated the startup, liveness, and readiness probe paths to
`/api/v1/heavy` and `/api/v1/light`, and adjusted the failure threshold
for liveness probes.
[[1]](diffhunk://#diff-4afce029dc91e63bc9ec03ef86772471786be1a649c63676b2cbef411c28f23dL105-R105)
[[2]](diffhunk://#diff-4afce029dc91e63bc9ec03ef86772471786be1a649c63676b2cbef411c28f23dL114-R123)

### Error Handling Improvements:
*
[`dotCMS/src/main/java/com/dotmarketing/filters/CMSFilter.java`](diffhunk://#diff-fc826560595be523f8e9b63d8bf2a7b2b1f940876edb013298c79f1b66bc4914R60-R66):
Enhanced error handling to log `ClientAbortException` without throwing
it again.

### Codebase Cleanup:
* Removed outdated JSP files, including `init.jsp`, `sub_nav.jsp`,
`unlock_container.jsp`, `unlock_contentlet.jsp`, and
`unlock_htmlpage.jsp`.
[[1]](diffhunk://#diff-a39cd0ae99f45175cd71212e757a0dda96acd2d640850a9dbdd9cf194ffe9931L1-L27)
[[2]](diffhunk://#diff-e9647830e52bbfc94b9b4c57be61fffb142f87966f2a2e159949f6805ed5c3f5L1-L2)
[[3]](diffhunk://#diff-36f4ab5425e2ebcb57812003969b83ff412f2ae31a251729656cbfd769391de6L1-L108)
[[4]](diffhunk://#diff-956c5ffd29059f3a75b219c7644b29373f1181b74bd2d82f1a4b6d49aba2e3c1L1-L138)
[[5]](diffhunk://#diff-a7ae9b56c296565c4ab1d17e10d5c0c16d03ca6de4050af3110e635670dfb493L1-L115)

### Code Enhancements:
*
[`dotCMS/src/main/java/com/dotcms/rest/api/v1/maintenance/JVMInfoResource.java`](diffhunk://#diff-c7bbf72c2a19d4b781e1758ec24a8f5145403525a14a414d2d8b6aec6417fd0aR38-R42):
Introduced a new pattern `obfuscateBasePattern` for obfuscating
sensitive information and updated the `obfuscateIfNeeded` method to use
this new pattern.
[[1]](diffhunk://#diff-c7bbf72c2a19d4b781e1758ec24a8f5145403525a14a414d2d8b6aec6417fd0aR38-R42)
[[2]](diffhunk://#diff-c7bbf72c2a19d4b781e1758ec24a8f5145403525a14a414d2d8b6aec6417fd0aL190-R195)
*
[`dotCMS/src/main/java/com/dotmarketing/portlets/languagesmanager/business/LanguageFactoryImpl.java`](diffhunk://#diff-212db36a5f82c8a09383e28a982ace46ac4cdab908bfc595208127a22a8f6334L138-R138):
Improved the `getLanguage` method to handle language IDs containing
hyphens.
*
[`dotCMS/src/main/java/com/dotmarketing/portlets/templates/business/TemplateFactoryImpl.java`](diffhunk://#diff-30db473047bf01b113d2ea4e19f591cd5d08cc41516f01e5bb1ec5be9131dfd7L738-R742):
Simplified SQL query to remove MS SQL-specific code.

---------

Co-authored-by: Daniel Silva <[email protected]>
Co-authored-by: Jose Castro <[email protected]>
  • Loading branch information
3 people authored Jan 9, 2025
1 parent 0db9310 commit c74694b
Show file tree
Hide file tree
Showing 12 changed files with 49 additions and 529 deletions.
2 changes: 1 addition & 1 deletion docker/k8s-aws-eks-manifest-examples/alb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ metadata:
alb.ingress.kubernetes.io/backend-protocol: HTTP
alb.ingress.kubernetes.io/healthcheck-protocol: HTTP
alb.ingress.kubernetes.io/healthcheck-port: '8082'
alb.ingress.kubernetes.io/healthcheck-path: /api/v1/appconfiguration
alb.ingress.kubernetes.io/healthcheck-path: /api/v1/alive
alb.ingress.kubernetes.io/healthcheck-interval-seconds: '30'
alb.ingress.kubernetes.io/healthcheck-timeout-seconds: '5'
alb.ingress.kubernetes.io/success-codes: '200'
Expand Down
8 changes: 4 additions & 4 deletions docker/k8s-aws-eks-manifest-examples/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ spec:
fi; ln -s /data/shared/assets/.backup /data/local/dotsecure/backup;
startupProbe:
httpGet:
path: /api/v1/appconfiguration
path: /api/v1/heavy
port: 8082
initialDelaySeconds: 30
periodSeconds: 5
Expand All @@ -111,16 +111,16 @@ spec:
timeoutSeconds: 1
livenessProbe:
httpGet:
path: /api/v1/appconfiguration
path: /api/v1/light
port: 8082
initialDelaySeconds: 1
periodSeconds: 30
successThreshold: 1
failureThreshold: 1
failureThreshold: 3
timeoutSeconds: 10
readinessProbe:
httpGet:
path: /api/v1/appconfiguration
path: /api/v1/light
port: 8082
initialDelaySeconds: 1
periodSeconds: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
import com.dotmarketing.util.UtilMethods;
import com.liferay.portal.util.ReleaseInfo;
import io.vavr.control.Try;
import org.glassfish.jersey.server.JSONP;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;
import java.io.Serializable;
import java.lang.management.ManagementFactory;
Expand All @@ -20,23 +30,18 @@
import java.util.Map;
import java.util.Properties;
import java.util.regex.Pattern;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.JSONP;


@Path("/v1/jvm")
@SuppressWarnings("serial")
public class JVMInfoResource implements Serializable {

private static final String DEFAULT_OBFUSCATE_PATTERN = "passw|pass|passwd|secret|key|token";

public static final Pattern obfuscateBasePattern = Pattern.compile(DEFAULT_OBFUSCATE_PATTERN,
Pattern.CASE_INSENSITIVE);

public static final Pattern obfuscatePattern = Pattern.compile(
Config.getStringProperty("OBFUSCATE_SYSTEM_ENVIRONMENTAL_VARIABLES", "passw|pass|passwd|secret|key|token"),
Config.getStringProperty("OBFUSCATE_SYSTEM_ENVIRONMENTAL_VARIABLES", DEFAULT_OBFUSCATE_PATTERN),
Pattern.CASE_INSENSITIVE);

@Path("/")
Expand Down Expand Up @@ -187,7 +192,9 @@ private Map<String,Object> getReleaseInfo(){
public static String obfuscateIfNeeded(final String key, final Object valueObject) {
final String value = (String) valueObject;
if(UtilMethods.isEmpty(value)) return "";
return obfuscatePattern.matcher(key).find() ? obfuscate(value) : value;
return obfuscateBasePattern.matcher(key).find() || obfuscatePattern.matcher(key).find()
? obfuscate(value)
: value;
}

private static String obfuscate(final String value) {
Expand Down
7 changes: 7 additions & 0 deletions dotCMS/src/main/java/com/dotmarketing/filters/CMSFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)

try {
doFilterInternal(req, res, chain);
} catch (Exception e) {
if (e.getClass().getCanonicalName().contains("ClientAbortException")) {
Logger.info(this.getClass(), "ClientAbortException: " + ((HttpServletRequest) req).getRequestURI());
Logger.debug(this.getClass(), "ClientAbortException: " + e.getMessage());
} else {
throw e;
}
} finally {
DbConnectionFactory.closeSilently();
}
Expand Down
27 changes: 0 additions & 27 deletions dotCMS/src/main/webapp/html/portlet/ext/director/init.jsp

This file was deleted.

2 changes: 0 additions & 2 deletions dotCMS/src/main/webapp/html/portlet/ext/director/sub_nav.jsp

This file was deleted.

108 changes: 0 additions & 108 deletions dotCMS/src/main/webapp/html/portlet/ext/director/unlock_container.jsp

This file was deleted.

138 changes: 0 additions & 138 deletions dotCMS/src/main/webapp/html/portlet/ext/director/unlock_contentlet.jsp

This file was deleted.

Loading

0 comments on commit c74694b

Please sign in to comment.