From 332e8a66277c562f7438520b93cc02ef34f62c97 Mon Sep 17 00:00:00 2001 From: Ludovic Champenois Date: Tue, 30 May 2023 07:02:12 -0700 Subject: [PATCH] Remove Cloud Debugger from Java 8 runtime. PiperOrigin-RevId: 536387567 Change-Id: Ia0384868e9971153dded1f2b2d08a18d37c92226 --- README.md | 2 +- protobuf/clone-controller.proto | 8 - protobuf/clone.proto | 20 -- .../base/protos/CloneControllerGrpc.java | 252 ------------------ .../google/apphosting/runtime/AppVersion.java | 32 +-- .../runtime/CloneControllerImpl.java | 51 +--- .../runtime/CloudDebuggerAgent.java | 74 ----- .../runtime/CloudDebuggerAgentWrapper.java | 35 --- .../runtime/CloudDebuggerCallback.java | 42 --- .../apphosting/runtime/JavaRuntime.java | 54 +--- .../runtime/JavaRuntimeFactory.java | 49 ---- .../apphosting/runtime/JavaRuntimeParams.java | 11 - .../apphosting/runtime/RequestManager.java | 52 ---- .../CloneControllerServerInterface.java | 6 - .../apphosting/runtime/grpc/GrpcPlugin.java | 19 -- .../runtime/ClassPathUtilsTest.java | 6 +- .../runtime/CloneControllerImplTest.java | 76 +----- .../runtime/JavaRuntimeParamsTest.java | 1 - .../runtime/RequestManagerTest.java | 131 +-------- .../anyrpc/AbstractRpcCompatibilityTest.java | 14 - .../runtime/anyrpc/ClientInterfaces.java | 10 - .../runtime/anyrpc/GrpcClients.java | 24 -- .../apphosting/runtime/ClassPathUtils.java | 3 +- 23 files changed, 9 insertions(+), 963 deletions(-) delete mode 100644 runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerAgent.java delete mode 100644 runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerAgentWrapper.java delete mode 100644 runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerCallback.java diff --git a/README.md b/README.md index f0c58218..c013e8fc 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,7 @@ The Java 11, Java 17 runtimes can benefit from extra user configuration when sta The default entrypoint used to boot the JVM is generated by App Engine Buildpacks. Essentially, it is equivalent to define this entrypoint in the `appengine-web.xml` file. For example: -
java --add-opens java.base/java.lang=ALL-UNNAMED  --add-opens java.base/java.nio.charset=ALL-UNNAMED -showversion -Xms32M -Xmx204M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:+PrintCommandLineFlags -agentpath:/opt/cdbg/cdbg_java_agent.so=--log_dir=/tmp,--alsologtostderr=true,--cdbg_extra_class_path=/workspace/WEB-INF/classes:/workspace/WEB-INF/lib -Dclasspath.runtimebase=/base/java_runtime -Djava.class.path=/base/java_runtime/runtime-main.jar -Djava.library.path=/base/java_runtime: com/google/apphosting/runtime/JavaRuntimeMainWithDefaults --fixed_application_path=/workspace /base/java_runtime
+
java --add-opens java.base/java.lang=ALL-UNNAMED  --add-opens java.base/java.nio.charset=ALL-UNNAMED -showversion -Xms32M -Xmx204M -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:+PrintCommandLineFlags -Dclasspath.runtimebase=/base/java_runtime -Djava.class.path=/base/java_runtime/runtime-main.jar -Djava.library.path=/base/java_runtime: com/google/apphosting/runtime/JavaRuntimeMainWithDefaults --fixed_application_path=/workspace /base/java_runtime
We do not recommend changing this default entrypoint as the memory settings are calculated based on the instance type (F1, F2, F4) and memory available. diff --git a/protobuf/clone-controller.proto b/protobuf/clone-controller.proto index 244f1f46..6733dd99 100644 --- a/protobuf/clone-controller.proto +++ b/protobuf/clone-controller.proto @@ -55,12 +55,4 @@ service CloneController { // Deprecated. rpc GetPerformanceData(PerformanceDataRequest) returns (java.apphosting.PerformanceData) {} - - // Updates a list of Cloud Debugger breakpoints on a clone. - rpc UpdateActiveBreakpoints(java.apphosting.CloudDebuggerBreakpoints) - returns (java.apphosting.CloudDebuggerBreakpoints) {} - - // Gets source context of the clone app. - rpc GetDebuggeeInfo(java.apphosting.DebuggeeInfoRequest) - returns (java.apphosting.DebuggeeInfoResponse) {} } diff --git a/protobuf/clone.proto b/protobuf/clone.proto index a5be97e2..02cbe244 100644 --- a/protobuf/clone.proto +++ b/protobuf/clone.proto @@ -429,23 +429,3 @@ message SupervisorSettings { // this. optional int32 clone_reducer_min_clones = 67; } - -// List of active Cloud Debugger breakpoints that AppServer sends to the clone. -message CloudDebuggerBreakpoints { - // Serialized "google.cloud.debugger.v1.Breakpoint" messages. We can't use - // it directly here because this file is build with proto1 and "Breakpoint" - // seems to be incompatible. - repeated bytes breakpoint_data = 1; -} - -message DebuggeeInfo { - optional google.devtools.source.v1.SourceContext source_context = 1; -} - -message DebuggeeInfoRequest { - required string app_version_id = 1; -} - -message DebuggeeInfoResponse { - optional DebuggeeInfo debuggee_info = 1; -} diff --git a/runtime/impl/src/main/java/com/google/apphosting/base/protos/CloneControllerGrpc.java b/runtime/impl/src/main/java/com/google/apphosting/base/protos/CloneControllerGrpc.java index 1f0d421a..9c712ff0 100755 --- a/runtime/impl/src/main/java/com/google/apphosting/base/protos/CloneControllerGrpc.java +++ b/runtime/impl/src/main/java/com/google/apphosting/base/protos/CloneControllerGrpc.java @@ -213,104 +213,6 @@ private CloneControllerGrpc() {} return getGetPerformanceDataMethod; } - private static volatile io.grpc.MethodDescriptor< - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints, - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints> - getUpdateActiveBreakpointsMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "UpdateActiveBreakpoints", - requestType = com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints.class, - responseType = com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints, - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints> - getUpdateActiveBreakpointsMethod() { - io.grpc.MethodDescriptor< - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints, - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints> - getUpdateActiveBreakpointsMethod; - if ((getUpdateActiveBreakpointsMethod = CloneControllerGrpc.getUpdateActiveBreakpointsMethod) - == null) { - synchronized (CloneControllerGrpc.class) { - if ((getUpdateActiveBreakpointsMethod = - CloneControllerGrpc.getUpdateActiveBreakpointsMethod) - == null) { - CloneControllerGrpc.getUpdateActiveBreakpointsMethod = - getUpdateActiveBreakpointsMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName( - generateFullMethodName(SERVICE_NAME, "UpdateActiveBreakpoints")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints - .getDefaultInstance())) - .setSchemaDescriptor( - new CloneControllerMethodDescriptorSupplier("UpdateActiveBreakpoints")) - .build(); - } - } - } - return getUpdateActiveBreakpointsMethod; - } - - private static volatile io.grpc.MethodDescriptor< - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest, - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse> - getGetDebuggeeInfoMethod; - - @io.grpc.stub.annotations.RpcMethod( - fullMethodName = SERVICE_NAME + '/' + "GetDebuggeeInfo", - requestType = com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest.class, - responseType = com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse.class, - methodType = io.grpc.MethodDescriptor.MethodType.UNARY) - public static io.grpc.MethodDescriptor< - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest, - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse> - getGetDebuggeeInfoMethod() { - io.grpc.MethodDescriptor< - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest, - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse> - getGetDebuggeeInfoMethod; - if ((getGetDebuggeeInfoMethod = CloneControllerGrpc.getGetDebuggeeInfoMethod) == null) { - synchronized (CloneControllerGrpc.class) { - if ((getGetDebuggeeInfoMethod = CloneControllerGrpc.getGetDebuggeeInfoMethod) == null) { - CloneControllerGrpc.getGetDebuggeeInfoMethod = - getGetDebuggeeInfoMethod = - io.grpc.MethodDescriptor - . - newBuilder() - .setType(io.grpc.MethodDescriptor.MethodType.UNARY) - .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetDebuggeeInfo")) - .setSampledToLocalTracing(true) - .setRequestMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest - .getDefaultInstance())) - .setResponseMarshaller( - io.grpc.protobuf.ProtoUtils.marshaller( - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse - .getDefaultInstance())) - .setSchemaDescriptor( - new CloneControllerMethodDescriptorSupplier("GetDebuggeeInfo")) - .build(); - } - } - } - return getGetDebuggeeInfoMethod; - } - /** Creates a new async stub that supports all call types for the service */ public static CloneControllerStub newStub(io.grpc.Channel channel) { io.grpc.stub.AbstractStub.StubFactory factory = @@ -418,37 +320,6 @@ public void getPerformanceData( getGetPerformanceDataMethod(), responseObserver); } - /** - * - * - *
-     * Updates a list of Cloud Debugger breakpoints on a clone.
-     * 
- */ - public void updateActiveBreakpoints( - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints request, - io.grpc.stub.StreamObserver< - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints> - responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getUpdateActiveBreakpointsMethod(), responseObserver); - } - - /** - * - * - *
-     * Gets source context of the clone app.
-     * 
- */ - public void getDebuggeeInfo( - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( - getGetDebuggeeInfoMethod(), responseObserver); - } - @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() { return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor()) @@ -480,20 +351,6 @@ public final io.grpc.ServerServiceDefinition bindService() { com.google.apphosting.base.protos.ModelClonePb.PerformanceDataRequest, com.google.apphosting.base.protos.ClonePb.PerformanceData>( this, METHODID_GET_PERFORMANCE_DATA))) - .addMethod( - getUpdateActiveBreakpointsMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints, - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints>( - this, METHODID_UPDATE_ACTIVE_BREAKPOINTS))) - .addMethod( - getGetDebuggeeInfoMethod(), - io.grpc.stub.ServerCalls.asyncUnaryCall( - new MethodHandlers< - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest, - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse>( - this, METHODID_GET_DEBUGGEE_INFO))) .build(); } } @@ -580,41 +437,6 @@ public void getPerformanceData( request, responseObserver); } - - /** - * - * - *
-     * Updates a list of Cloud Debugger breakpoints on a clone.
-     * 
- */ - public void updateActiveBreakpoints( - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints request, - io.grpc.stub.StreamObserver< - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints> - responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getUpdateActiveBreakpointsMethod(), getCallOptions()), - request, - responseObserver); - } - - /** - * - * - *
-     * Gets source context of the clone app.
-     * 
- */ - public void getDebuggeeInfo( - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest request, - io.grpc.stub.StreamObserver - responseObserver) { - io.grpc.stub.ClientCalls.asyncUnaryCall( - getChannel().newCall(getGetDebuggeeInfoMethod(), getCallOptions()), - request, - responseObserver); - } } /** */ @@ -684,33 +506,6 @@ public com.google.apphosting.base.protos.ClonePb.PerformanceData getPerformanceD return io.grpc.stub.ClientCalls.blockingUnaryCall( getChannel(), getGetPerformanceDataMethod(), getCallOptions(), request); } - - /** - * - * - *
-     * Updates a list of Cloud Debugger breakpoints on a clone.
-     * 
- */ - public com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints - updateActiveBreakpoints( - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getUpdateActiveBreakpointsMethod(), getCallOptions(), request); - } - - /** - * - * - *
-     * Gets source context of the clone app.
-     * 
- */ - public com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse getDebuggeeInfo( - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest request) { - return io.grpc.stub.ClientCalls.blockingUnaryCall( - getChannel(), getGetDebuggeeInfoMethod(), getCallOptions(), request); - } } /** */ @@ -785,43 +580,12 @@ protected CloneControllerFutureStub build( return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getGetPerformanceDataMethod(), getCallOptions()), request); } - - /** - * - * - *
-     * Updates a list of Cloud Debugger breakpoints on a clone.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints> - updateActiveBreakpoints( - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getUpdateActiveBreakpointsMethod(), getCallOptions()), request); - } - - /** - * - * - *
-     * Gets source context of the clone app.
-     * 
- */ - public com.google.common.util.concurrent.ListenableFuture< - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse> - getDebuggeeInfo(com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest request) { - return io.grpc.stub.ClientCalls.futureUnaryCall( - getChannel().newCall(getGetDebuggeeInfoMethod(), getCallOptions()), request); - } } private static final int METHODID_WAIT_FOR_SANDBOX = 0; private static final int METHODID_APPLY_CLONE_SETTINGS = 1; private static final int METHODID_SEND_DEADLINE = 2; private static final int METHODID_GET_PERFORMANCE_DATA = 3; - private static final int METHODID_UPDATE_ACTIVE_BREAKPOINTS = 4; - private static final int METHODID_GET_DEBUGGEE_INFO = 5; private static final class MethodHandlers implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -865,20 +629,6 @@ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserv com.google.apphosting.base.protos.ClonePb.PerformanceData>) responseObserver); break; - case METHODID_UPDATE_ACTIVE_BREAKPOINTS: - serviceImpl.updateActiveBreakpoints( - (com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints) request, - (io.grpc.stub.StreamObserver< - com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints>) - responseObserver); - break; - case METHODID_GET_DEBUGGEE_INFO: - serviceImpl.getDebuggeeInfo( - (com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest) request, - (io.grpc.stub.StreamObserver< - com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse>) - responseObserver); - break; default: throw new AssertionError(); } @@ -947,8 +697,6 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() { .addMethod(getApplyCloneSettingsMethod()) .addMethod(getSendDeadlineMethod()) .addMethod(getGetPerformanceDataMethod()) - .addMethod(getUpdateActiveBreakpointsMethod()) - .addMethod(getGetDebuggeeInfoMethod()) .build(); } } diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/AppVersion.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/AppVersion.java index 46e244fb..889bed6d 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/AppVersion.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/AppVersion.java @@ -34,8 +34,6 @@ import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.HashSet; import java.util.Properties; import java.util.Set; @@ -52,7 +50,7 @@ * @see AppVersionKey * */ -public class AppVersion implements CloudDebuggerCallback { +public class AppVersion { private static final GoogleLogger logger = GoogleLogger.forEnclosingClass(); /** * We assume that this string is prepended to the path for any @@ -198,33 +196,6 @@ public ThreadGroupPool getThreadGroupPool() { return threadGroupPool; } - @Override - public ClassType getClassType(final Class cls) { - return AccessController.doPrivileged( - (PrivilegedAction) - () -> { - ClassLoader testedClassLoader = cls.getClassLoader(); - - // TODO: add support for custom class loaders that an application may create. - if (testedClassLoader == classLoader) { - return ClassType.APPLICATION; - } - - if (testedClassLoader == getClass().getClassLoader()) { - return ClassType.RUNTIME; - } - - ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader(); - if ((testedClassLoader == systemClassLoader) - || (testedClassLoader - == systemClassLoader.getParent())) { // Bootstrap ClassLoader. - return ClassType.SAFE_RUNTIME; - } - - return ClassType.UNKNOWN; - }); - } - public synchronized SourceContext getSourceContext() { if (!sourceContextLoaded) { sourceContext = readSourceContext(); @@ -246,6 +217,7 @@ private SourceContext readSourceContext() { } // TODO: read source context from binary for google apps running in 'borg' context. + @Nullable private SourceContext readSourceContextFromJsonFile() { SourceContext sourceContext = null; try { diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/CloneControllerImpl.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/CloneControllerImpl.java index bedc5372..1ead755c 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/CloneControllerImpl.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/CloneControllerImpl.java @@ -18,9 +18,6 @@ import com.google.apphosting.base.protos.ClonePb.ApiPackageDeadlines; import com.google.apphosting.base.protos.ClonePb.CloneSettings; -import com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints; -import com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest; -import com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse; import com.google.apphosting.base.protos.ClonePb.PerformanceData; import com.google.apphosting.base.protos.EmptyMessage; import com.google.apphosting.base.protos.ModelClonePb.DeadlineInfo; @@ -42,19 +39,16 @@ public class CloneControllerImpl implements CloneControllerServerInterface { private final ApiDeadlineOracle deadlineOracle; private final RequestManager requestManager; private final ByteBuffer hotspotPerformanceData; - private final CloudDebuggerAgentWrapper cloudDebuggerAgent; public CloneControllerImpl( Callback callback, ApiDeadlineOracle deadlineOracle, RequestManager requestManager, - ByteBuffer hotspotPerformanceData, - CloudDebuggerAgentWrapper cloudDebuggerAgent) { + ByteBuffer hotspotPerformanceData) { this.callback = callback; this.deadlineOracle = deadlineOracle; this.requestManager = requestManager; this.hotspotPerformanceData = hotspotPerformanceData; - this.cloudDebuggerAgent = cloudDebuggerAgent; } /** @@ -141,49 +135,6 @@ public void getPerformanceData(AnyRpcServerContext rpc, PerformanceDataRequest r rpc.finishWithResponse(data.build()); } - @Override - public void updateActiveBreakpoints(AnyRpcServerContext rpc, CloudDebuggerBreakpoints request) { - // Give the updated list of breakpoints to the debuglet. - // TODO: make this a List to avoid copying. That will require - // updating JNI code in gae_jvmti_agent.cc. - byte[][] requestData = new byte[request.getBreakpointDataCount()][]; - for (int i = 0; i < requestData.length; ++i) { - requestData[i] = request.getBreakpointData(i).toByteArray(); - } - - cloudDebuggerAgent.setActiveBreakpoints(requestData); - - // Query any breakpoint updates it might have (typically that would be errors for invalid - // breakpoints). - CloudDebuggerBreakpoints.Builder response = CloudDebuggerBreakpoints.newBuilder(); - byte[][] responseData = cloudDebuggerAgent.dequeueBreakpointUpdates(); - if (responseData != null) { - for (byte[] breakpointData : responseData) { - response.addBreakpointData(ByteString.copyFrom(breakpointData)); - } - } - - rpc.finishWithResponse(response.build()); - } - - @Override - public void getDebuggeeInfo(AnyRpcServerContext rpc, DebuggeeInfoRequest request) { - DebuggeeInfoResponse.Builder response = DebuggeeInfoResponse.newBuilder(); - - // AppVersionId is required and expected to have AppId and VersionId separated by '/' - String[] parts = request.getAppVersionId().split("/"); - if (parts.length == 2) { - SourceContext sourceContext = getSourceContext(parts[0], parts[1]); - if (sourceContext != null) { - response.getDebuggeeInfoBuilder().setSourceContext(sourceContext); - } - } else { - logger.atWarning().log("invalid AppVersionId : %s", request.getAppVersionId()); - } - - rpc.finishWithResponse(response.build()); - } - SourceContext getSourceContext(String appId, String versionId) { AppVersion appVersion = callback.getAppVersion(appId, versionId); diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerAgent.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerAgent.java deleted file mode 100644 index d3e9a757..00000000 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerAgent.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * Licensed 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 - * - * https://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 com.google.apphosting.runtime; - -/** - * Native methods exposed by Java Cloud Debugger agent. - * - *

These methods should only be called if the Cloud Debugger is enabled. Otherwise these calls - * will throw exception. The debugger agent is loaded very early, so these methods can be used at - * any time. - */ -public final class CloudDebuggerAgent { - /** - * Starts the initialization sequence of the Java Cloud Debugger agent. - * - * @param debuggerInternalsClassLoader ClassLoader object to use to load internal debugger Java - * classes. - */ - public static native void bind(ClassLoader debuggerInternalsClassLoader); - - /** - * Hooks up Cloud Debugger to the application. - * - *

Multiple paths in {@code classPath} are separated with {@code File.pathSeparator}. The - * debugger is exploring all the paths recursively opening .JAR files as they are encountered. - * - *

This function must be called after {@code bind} but before the first breakpoint is set. - * Setting breakpoints will fail until this method is called. - * - * @param classPath paths to application classes - * @param callback Callback interface used by Cloud Debugger to query AppEngine Classic runtime - */ - public static native void setApplication(String[] classPath, CloudDebuggerCallback callback); - - /** - * Updates the list of active breakpoints in the debugger. - * - * @param breakpoints list of currently active breakpoints, where each breakpoint is a serialized - * "com.google.protos.google.cloud.debugger.v1.CloudDebuggerData.Breakpoint" message. - */ - public static native void setActiveBreakpoints(byte[][] breakpoints); - - /** - * Verifies if there are breakpoint updates to send to the Cloud Debugger service. - * - * @return true if there are breakpoint updates available, false otherwise. - */ - public static native boolean hasBreakpointUpdates(); - - /** - * Pulls breakpoint updates to send to the Cloud Debugger service through AppServer. - * - * @return serialized {@code - * com.google.protos.google.cloud.debugger.v1.CloudDebuggerData.Breakpoint} messages or null if - * no breakpoint updates available. - */ - public static native byte[][] dequeueBreakpointUpdates(); - - private CloudDebuggerAgent() {} -} diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerAgentWrapper.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerAgentWrapper.java deleted file mode 100644 index 2eed57dc..00000000 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerAgentWrapper.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * Licensed 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 - * - * https://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 com.google.apphosting.runtime; - -/** - * Wraps {@code CloudDebuggerAgent} with interface. {@code CloudDebuggerAgent} contains static - * methods that can't be mocked. - * - *

See {@code CloudDebuggerAgent} for explanation of each method. - */ -public interface CloudDebuggerAgentWrapper { - void bind(ClassLoader debuggerInternalsClassLoader); - - void setApplication(String[] classPath, CloudDebuggerCallback callback); - - void setActiveBreakpoints(byte[][] breakpoints); - - boolean hasBreakpointUpdates(); - - byte[][] dequeueBreakpointUpdates(); -} diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerCallback.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerCallback.java deleted file mode 100644 index 2e6b6ac3..00000000 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/CloudDebuggerCallback.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * Licensed 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 - * - * https://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 com.google.apphosting.runtime; - -/** - * Callback interface used by Cloud Debugger to query AppEngine Classic runtime. - */ -public interface CloudDebuggerCallback { - /** - * Classification of a Java class. - * - *

This enum must be synced with its C++ counterpart in gae_callback.h. - */ - public enum ClassType { - JDK, // Obsolete - SAFE_RUNTIME, - RUNTIME, - APPLICATION, - UNKNOWN - } - - /** - * Classifies Java class. - * - *

The debugger hides or shows local variables and fields based on the class classification. - */ - ClassType getClassType(Class cls); -} diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntime.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntime.java index d76568b4..10435639 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntime.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntime.java @@ -17,7 +17,6 @@ package com.google.apphosting.runtime; import static com.google.common.base.StandardSystemProperty.JAVA_SPECIFICATION_VERSION; -import static java.util.stream.Collectors.toList; import com.google.apphosting.base.AppVersionKey; import com.google.apphosting.base.protos.AppinfoPb.AppInfo; @@ -31,7 +30,6 @@ import com.google.apphosting.utils.config.AppEngineWebXml; import com.google.auto.value.AutoBuilder; import com.google.common.annotations.VisibleForTesting; -import com.google.common.collect.Iterables; import com.google.common.flogger.GoogleLogger; import java.io.ByteArrayInputStream; import java.io.File; @@ -39,14 +37,10 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.InetAddress; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLClassLoader; import java.net.UnknownHostException; import java.nio.ByteBuffer; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -115,9 +109,6 @@ public class JavaRuntime implements EvaluationRuntimeServerInterface { private final boolean enableHotspotPerformanceMetrics; - private final CloudDebuggerAgentWrapper cloudDebuggerAgent; - private boolean cloudDebuggerEnabled; - private final boolean pollForNetwork; private final boolean redirectStdoutStderr; @@ -146,7 +137,6 @@ public static Builder builder() { return new AutoBuilder_JavaRuntime_Builder() .setCompressResponse(true) .setEnableHotspotPerformanceMetrics(true) - .setCloudDebuggerEnabled(false) .setPollForNetwork(false) .setDefaultToNativeUrlStreamHandler(false) .setForceUrlfetchUrlStreamHandler(false) @@ -204,12 +194,6 @@ public abstract Builder setEnableHotspotPerformanceMetrics( public abstract boolean enableHotspotPerformanceMetrics(); - public abstract Builder setCloudDebuggerAgent(CloudDebuggerAgentWrapper cloudDebuggerAgent); - - public abstract Builder setCloudDebuggerEnabled(boolean cloudDebuggerEnabled); - - public abstract boolean cloudDebuggerEnabled(); - public abstract Builder setPollForNetwork(boolean pollForNetwork); public abstract boolean pollForNetwork(); @@ -264,8 +248,6 @@ public abstract Builder setDefaultToNativeUrlStreamHandler( BackgroundRequestCoordinator coordinator, boolean compressResponse, boolean enableHotspotPerformanceMetrics, - CloudDebuggerAgentWrapper cloudDebuggerAgent, - boolean cloudDebuggerEnabled, boolean pollForNetwork, boolean defaultToNativeUrlStreamHandler, boolean forceUrlfetchUrlStreamHandler, @@ -297,8 +279,6 @@ public abstract Builder setDefaultToNativeUrlStreamHandler( this.coordinator = coordinator; this.compressResponse = compressResponse; this.enableHotspotPerformanceMetrics = enableHotspotPerformanceMetrics; - this.cloudDebuggerAgent = cloudDebuggerAgent; - this.cloudDebuggerEnabled = cloudDebuggerEnabled; this.pollForNetwork = pollForNetwork; this.redirectStdoutStderr = redirectStdoutStderr; this.logJsonToFile = logJsonToFile; @@ -462,11 +442,6 @@ public synchronized void addAppVersion(AnyRpcServerContext rpc, AppInfo appInfo) appVersionFactory.createAppVersion(appInfo, appEngineWebXml, templateConfiguration); ApplicationEnvironment env = appVersion.getEnvironment(); - if (cloudDebuggerEnabled && env.isCloudDebuggerDisabled()) { - logger.atInfo().log("Cloud Debugger is disabled through appengine-web.xml"); - cloudDebuggerEnabled = false; - requestManager.disableCloudDebugger(); - } if ("1.8".equals(JAVA_SPECIFICATION_VERSION.value())) { setEnvironmentVariables(env.getEnvironmentVariables()); @@ -498,20 +473,6 @@ public synchronized void addAppVersion(AnyRpcServerContext rpc, AppInfo appInfo) // Now notify the servlet engine, so it can do any setup it // has to do. servletEngine.addAppVersion(appVersion); - - if (cloudDebuggerEnabled) { - try { - // Runtimes such as Java8/Java8g use gVisor instead of sandboxing (i.e., they use a null - // sandbox). It is safe for the debugger to display the internals of these runtimes. - // We expect this to always downcast successfully in java8: - URLClassLoader urlLoader = (URLClassLoader) appVersion.getClassLoader(); - cloudDebuggerAgent.setApplication( - Iterables.toArray(urlsToPaths(urlLoader.getURLs()), String.class), appVersion); - } catch (RuntimeException ex) { - // Don't fail the operation if we have a problem with Cloud Debugger. - logger.atWarning().withCause(ex).log("Error setting class path for Cloud Debugger:"); - } - } } catch (Exception ex) { logger.atWarning().withCause(ex).log("Error adding app version:"); rpc.finishWithAppError(UPAddDelete.ERROR.FAILURE_VALUE, ex.toString()); @@ -552,19 +513,6 @@ public static void killCloneIfSeriousException(Throwable th) { } } - private static String urlToPath(URL url) { - try { - return Paths.get(url.toURI()).toFile().getAbsolutePath(); - } catch (URISyntaxException ex) { - logger.atWarning().withCause(ex).log("Failed to convert URL %s to string: ", url); - return null; - } - } - - private static Iterable urlsToPaths(URL[] urls) { - return Arrays.stream(urls).map(JavaRuntime::urlToPath).filter(s -> s != null).collect(toList()); - } - private static void setEnvironmentVariables(Map vars) { // Setting the environment variables after the JVM has started requires a bit of a hack: // we reach into the package-private java.lang.ProcessEnvironment class, which incidentally @@ -621,7 +569,7 @@ private void startServer() throws Exception { CloneControllerImplCallback callback = new CloneControllerImplCallback(); CloneControllerImpl controller = new CloneControllerImpl( - callback, deadlineOracle, requestManager, hotspotPerformanceData, cloudDebuggerAgent); + callback, deadlineOracle, requestManager, hotspotPerformanceData); rpcPlugin.startServer(JavaRuntime.this, controller); rpcStarted.put(rpcPlugin); diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntimeFactory.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntimeFactory.java index 09a4448c..26366685 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntimeFactory.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntimeFactory.java @@ -41,37 +41,6 @@ public class JavaRuntimeFactory { private static final GoogleLogger logger = GoogleLogger.forEnclosingClass(); - /** - * Real implementation of {@code CloudDebuggerAgentWrapper} interface that forwards all the calls - * to the actual Cloud Debugger agent. - */ - static class CloudDebuggerAgentWrapperImpl implements CloudDebuggerAgentWrapper { - @Override - public void bind(ClassLoader debuggerInternalsClassLoader) { - CloudDebuggerAgent.bind(debuggerInternalsClassLoader); - } - - @Override - public void setApplication(String[] classPath, CloudDebuggerCallback callback) { - CloudDebuggerAgent.setApplication(classPath, callback); - } - - @Override - public void setActiveBreakpoints(byte[][] breakpoints) { - CloudDebuggerAgent.setActiveBreakpoints(breakpoints); - } - - @Override - public boolean hasBreakpointUpdates() { - return CloudDebuggerAgent.hasBreakpointUpdates(); - } - - @Override - public byte[][] dequeueBreakpointUpdates() { - return CloudDebuggerAgent.dequeueBreakpointUpdates(); - } - } - @VisibleForTesting JavaRuntimeFactory() {} @@ -146,20 +115,6 @@ public JavaRuntime getStartedRuntime(NullSandboxPlugin sandboxPlugin, String[] a BackgroundRequestCoordinator coordinator = new BackgroundRequestCoordinator(); - CloudDebuggerAgentWrapper cloudDebuggerAgent = new CloudDebuggerAgentWrapperImpl(); - boolean cloudDebuggerEnabled = false; - if (params.getEnableCloudDebugger()) { - // Initialize Cloud Debugger (if enabled). This initialization is very lightweight: - // it only loads a few classes. The bulk of a more expensive initialization is deferred by - // the debugger to the moment the first breakpoint is set. - try { - cloudDebuggerAgent.bind(JavaRuntimeFactory.class.getClassLoader()); - cloudDebuggerEnabled = true; - } catch (Throwable ex) { - logger.atWarning().log("Failed to bind to Cloud Debugger agent"); - } - } - ApiProxyImpl apiProxyImpl = ApiProxyImpl.builder() .setApiHost( @@ -186,8 +141,6 @@ public JavaRuntime getStartedRuntime(NullSandboxPlugin sandboxPlugin, String[] a .setMaxOutstandingApiRpcs(params.getCloneMaxOutstandingApiRpcs()) .setThreadStopTerminatesClone(params.getThreadStopTerminatesClone()) .setInterruptFirstOnSoftDeadline(params.getInterruptThreadsFirstOnSoftDeadline()) - .setCloudDebuggerAgent(cloudDebuggerAgent) - .setEnableCloudDebugger(cloudDebuggerEnabled) .setCyclesPerSecond(params.getCyclesPerSecond()) .setWaitForDaemonRequestThreads(params.getWaitForDaemonRequestThreads()); @@ -213,8 +166,6 @@ public JavaRuntime getStartedRuntime(NullSandboxPlugin sandboxPlugin, String[] a .setCoordinator(coordinator) .setCompressResponse(params.getRuntimeHttpCompression()) .setEnableHotspotPerformanceMetrics(params.getEnableHotspotPerformanceMetrics()) - .setCloudDebuggerAgent(cloudDebuggerAgent) - .setCloudDebuggerEnabled(cloudDebuggerEnabled) .setPollForNetwork(params.getPollForNetwork()) .setDefaultToNativeUrlStreamHandler(params.getDefaultToNativeUrlStreamHandler()) .setForceUrlfetchUrlStreamHandler(params.getForceUrlfetchUrlStreamHandler()) diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntimeParams.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntimeParams.java index 9a92e160..908210e1 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntimeParams.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/JavaRuntimeParams.java @@ -238,13 +238,6 @@ final class JavaRuntimeParams { ) private boolean enableHotspotPerformanceMetrics = false; - @Parameter( - description = "Enables Java Cloud Debugger JVMTI agent loaded in the process.", - names = {"--enable_cloud_debugger"}, - arity = 1 - ) - private boolean enableCloudDebugger = false; - @Parameter( description = "Enables Java Cloud Profiler CPU usage agent in the process.", names = {"--enable_cloud_cpu_profiler"}, @@ -435,10 +428,6 @@ boolean getLogJettyExceptionsToAppLogs() { return logJettyExceptionsToAppLogs; } - boolean getEnableCloudDebugger() { - return enableCloudDebugger; - } - boolean getEnableCloudCpuProfiler() { return enableCloudCpuProfiler; } diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestManager.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestManager.java index 03a621c5..ba484bef 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestManager.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/RequestManager.java @@ -65,7 +65,6 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicBoolean; import javax.annotation.Nullable; /** @@ -138,10 +137,7 @@ public class RequestManager implements RequestThreadManager { private final Map requests; private final boolean interruptFirstOnSoftDeadline; private int maxOutstandingApiRpcs; - @Nullable private final CloudDebuggerAgentWrapper cloudDebuggerAgent; - private final AtomicBoolean enableCloudDebugger; private final boolean waitForDaemonRequestThreads; - private final AtomicBoolean debugletStartNotified = new AtomicBoolean(false); private final Map environmentVariables; /** Make a partly-initialized builder for a RequestManager. */ @@ -184,12 +180,6 @@ public abstract static class Builder { public abstract boolean interruptFirstOnSoftDeadline(); - public abstract Builder setCloudDebuggerAgent(@Nullable CloudDebuggerAgentWrapper x); - - public abstract Builder setEnableCloudDebugger(boolean x); - - public abstract boolean enableCloudDebugger(); - public abstract Builder setCyclesPerSecond(long x); public abstract long cyclesPerSecond(); @@ -212,8 +202,6 @@ public abstract static class Builder { int maxOutstandingApiRpcs, boolean threadStopTerminatesClone, boolean interruptFirstOnSoftDeadline, - @Nullable CloudDebuggerAgentWrapper cloudDebuggerAgent, - boolean enableCloudDebugger, long cyclesPerSecond, boolean waitForDaemonRequestThreads, ImmutableMap environment) { @@ -228,8 +216,6 @@ public abstract static class Builder { this.maxOutstandingApiRpcs = maxOutstandingApiRpcs; this.threadStopTerminatesClone = threadStopTerminatesClone; this.interruptFirstOnSoftDeadline = interruptFirstOnSoftDeadline; - this.cloudDebuggerAgent = cloudDebuggerAgent; - this.enableCloudDebugger = new AtomicBoolean(enableCloudDebugger); this.waitForDaemonRequestThreads = waitForDaemonRequestThreads; this.requests = Collections.synchronizedMap(new HashMap()); this.environmentVariables = environment; @@ -239,16 +225,6 @@ public void setMaxOutstandingApiRpcs(int maxOutstandingApiRpcs) { this.maxOutstandingApiRpcs = maxOutstandingApiRpcs; } - /** - * Disables Cloud Debugger. - * - *

If called before the first request has been processed, the Cloud Debugger will not be even - * activated. - */ - public void disableCloudDebugger() { - enableCloudDebugger.set(false); - } - /** * Set up any state necessary to execute a new request using the * specified parameters. The current thread should be the one that @@ -359,9 +335,6 @@ public RequestToken startRequest( // logged-in user. ApiProxy.setEnvironmentForCurrentThread(environment); - // Let the appserver know that we're up and running. - setPendingStartCloudDebugger(upResponse); - // Start counting CPU cycles used by this thread. timer.start(); @@ -399,11 +372,6 @@ public void finishRequest(RequestToken requestToken) { thread.interrupt(); } - // Send any pending breakpoint updates from Cloud Debugger. - if (enableCloudDebugger.get() && cloudDebuggerAgent.hasBreakpointUpdates()) { - setPendingCloudDebuggerBreakpointUpdates(requestToken.getUpResponse()); - } - // Now wait for any async API calls and all request threads to complete. waitForUserCodeToComplete(requestToken); @@ -623,26 +591,6 @@ public void sendDeadline(RequestToken token, boolean isUncatchable) { } - private void setPendingStartCloudDebugger(MutableUpResponse upResponse) { - if (!enableCloudDebugger.get()) { - return; - } - - // First time ever we need to set "DebugletStarted" flag. This will trigger - // debuggee initialization sequence on AppServer. - if (debugletStartNotified.compareAndSet(false, true)) { - upResponse.setPendingCloudDebuggerActionDebuggeeRegistration(true); - } - } - - private void setPendingCloudDebuggerBreakpointUpdates(MutableUpResponse upResponse) { - if (!enableCloudDebugger.get()) { - return; - } - - upResponse.setPendingCloudDebuggerActionBreakpointUpdates(true); - } - private String threadDump(Collection threads, String prefix) { StringBuilder message = new StringBuilder(prefix); for (Thread thread : threads) { diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/anyrpc/CloneControllerServerInterface.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/anyrpc/CloneControllerServerInterface.java index 0cc5035d..a0477e1e 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/anyrpc/CloneControllerServerInterface.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/anyrpc/CloneControllerServerInterface.java @@ -17,8 +17,6 @@ package com.google.apphosting.runtime.anyrpc; import com.google.apphosting.base.protos.ClonePb.CloneSettings; -import com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints; -import com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest; import com.google.apphosting.base.protos.EmptyMessage; import com.google.apphosting.base.protos.ModelClonePb.DeadlineInfo; import com.google.apphosting.base.protos.ModelClonePb.PerformanceDataRequest; @@ -37,8 +35,4 @@ public interface CloneControllerServerInterface { void sendDeadline(AnyRpcServerContext ctx, DeadlineInfo req); void getPerformanceData(AnyRpcServerContext ctx, PerformanceDataRequest req); - - void updateActiveBreakpoints(AnyRpcServerContext ctx, CloudDebuggerBreakpoints req); - - void getDebuggeeInfo(AnyRpcServerContext ctx, DebuggeeInfoRequest req); } diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/grpc/GrpcPlugin.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/grpc/GrpcPlugin.java index ac677712..c397d095 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/grpc/GrpcPlugin.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/grpc/GrpcPlugin.java @@ -19,8 +19,6 @@ import com.google.apphosting.base.protos.AppinfoPb; import com.google.apphosting.base.protos.CloneControllerGrpc.CloneControllerImplBase; import com.google.apphosting.base.protos.ClonePb; -import com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest; -import com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse; import com.google.apphosting.base.protos.EmptyMessage; import com.google.apphosting.base.protos.EvaluationRuntimeGrpc.EvaluationRuntimeImplBase; import com.google.apphosting.base.protos.ModelClonePb; @@ -258,22 +256,5 @@ public void getPerformanceData( new GrpcServerContext<>(ClonePb.PerformanceData.class, streamObserver); cloneController.getPerformanceData(serverContext, request); } - - @Override - public void updateActiveBreakpoints( - ClonePb.CloudDebuggerBreakpoints cloudDebuggerBreakpoints, - StreamObserver streamObserver) { - GrpcServerContext serverContext = - new GrpcServerContext<>(ClonePb.CloudDebuggerBreakpoints.class, streamObserver); - cloneController.updateActiveBreakpoints(serverContext, cloudDebuggerBreakpoints); - } - - @Override - public void getDebuggeeInfo( - DebuggeeInfoRequest request, StreamObserver streamObserver) { - GrpcServerContext serverContext = - new GrpcServerContext<>(ClonePb.DebuggeeInfoResponse.class, streamObserver); - cloneController.getDebuggeeInfo(serverContext, request); - } } } diff --git a/runtime/impl/src/test/java/com/google/apphosting/runtime/ClassPathUtilsTest.java b/runtime/impl/src/test/java/com/google/apphosting/runtime/ClassPathUtilsTest.java index 0b782254..4349c73a 100644 --- a/runtime/impl/src/test/java/com/google/apphosting/runtime/ClassPathUtilsTest.java +++ b/runtime/impl/src/test/java/com/google/apphosting/runtime/ClassPathUtilsTest.java @@ -28,7 +28,6 @@ @RunWith(JUnit4.class) public final class ClassPathUtilsTest { - private static final String PATH_SEPARATOR = System.getProperty("path.separator"); private String runtimeLocation = null; @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @@ -72,10 +71,7 @@ public void verifyMavenJarsPropertiesAreConfigured() throws Exception { assertThat(System.getProperty("classpath.runtime-impl")) .isEqualTo( runtimeLocation - + "/jars/runtime-impl.jar" - + PATH_SEPARATOR - + runtimeLocation - + "/frozen_debugger.jar"); + + "/jars/runtime-impl.jar"); assertThat(System.getProperty("classpath.runtime-shared")) .isEqualTo(runtimeLocation + "/jars/runtime-shared.jar"); diff --git a/runtime/impl/src/test/java/com/google/apphosting/runtime/CloneControllerImplTest.java b/runtime/impl/src/test/java/com/google/apphosting/runtime/CloneControllerImplTest.java index 423e6a8f..470eaef6 100644 --- a/runtime/impl/src/test/java/com/google/apphosting/runtime/CloneControllerImplTest.java +++ b/runtime/impl/src/test/java/com/google/apphosting/runtime/CloneControllerImplTest.java @@ -17,14 +17,9 @@ package com.google.apphosting.runtime; import static com.google.common.truth.Truth.assertThat; -import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints; -import com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest; -import com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse; import com.google.apphosting.base.protos.ClonePb.PerformanceData; import com.google.apphosting.base.protos.GitSourceContext; import com.google.apphosting.base.protos.ModelClonePb.PerformanceDataRequest; @@ -57,9 +52,6 @@ public class CloneControllerImplTest { private static final int FAKE_HSPERFDATA_SIZE = 100; private static final long CYCLES_PER_SECOND = 2333414000L; - private final CloudDebuggerAgentWrapper cloudDebuggerAgent = - mock(CloudDebuggerAgentWrapper.class); - private final JavaRuntime javaRuntime = mock(JavaRuntime.class); private final AppVersion appVersion = mock(AppVersion.class); private final SourceContext sourceContext = SourceContext.newBuilder() @@ -122,69 +114,6 @@ public void testPerformanceDataEnabledAgainstRealPerfData() throws Exception { .isEqualTo(new byte[] {(byte) 0xCA, (byte) 0xFE, (byte) 0xC0, (byte) 0xC0}); } - @Test - public void testUpdateActiveBreakpoints() { - CloneControllerImpl cloneController = createCloneController(null); - - MockAnyRpcServerContext rpc = createRpc(); - cloneController.updateActiveBreakpoints(rpc, CloudDebuggerBreakpoints.getDefaultInstance()); - rpc.assertSuccess(); - - verify(cloudDebuggerAgent).setActiveBreakpoints(any(byte[][].class)); - verify(cloudDebuggerAgent).dequeueBreakpointUpdates(); - } - - @Test - public void testGetDebuggeeInfoRpc() { - CloneControllerImpl cloneController = createCloneController(null); - - // Get source context for valid running application - MockAnyRpcServerContext rpc = createRpc(); - DebuggeeInfoRequest request1 = - DebuggeeInfoRequest.newBuilder().setAppVersionId("app1/1.1").build(); - - cloneController.getDebuggeeInfo(rpc, request1); - DebuggeeInfoResponse response = (DebuggeeInfoResponse) rpc.assertSuccess(); - assertThat(response.hasDebuggeeInfo()).isTrue(); - assertThat(response.getDebuggeeInfo().hasSourceContext()).isTrue(); - assertThat(response.getDebuggeeInfo().getSourceContext().getContextCase()) - .isEqualTo(SourceContext.ContextCase.GIT); - assertThat(response.getDebuggeeInfo().getSourceContext().getGit().getUrl()) - .isEqualTo("http://foo/bar"); - - // Get source context for valid but non running application - rpc = createRpc(); - DebuggeeInfoRequest request2 = - DebuggeeInfoRequest.newBuilder().setAppVersionId("someApp/someVersion").build(); - - cloneController.getDebuggeeInfo(rpc, request2); - response = (DebuggeeInfoResponse) rpc.assertSuccess(); - assertThat(response.hasDebuggeeInfo()).isFalse(); - - // Get source context of application with invalid AppVersionId - rpc = createRpc(); - DebuggeeInfoRequest request3 = - DebuggeeInfoRequest.newBuilder().setAppVersionId("Invalid+App-Version?!@").build(); - - cloneController.getDebuggeeInfo(rpc, request3); - response = (DebuggeeInfoResponse) rpc.assertSuccess(); - assertThat(response.hasDebuggeeInfo()).isFalse(); - } - - @Test - public void testGetDebuggeeInfo() { - CloneControllerImpl cloneController = createCloneController(null); - - // Get source context of valid application - SourceContext sourceContext = cloneController.getSourceContext("app1", "1.1"); - assertThat(sourceContext.getContextCase()).isEqualTo(SourceContext.ContextCase.GIT); - assertThat(sourceContext.getGit().getUrl()).isEqualTo("http://foo/bar"); - - // Get source context of invalid application - sourceContext = cloneController.getSourceContext("someApp", "someVersion"); - assertThat(sourceContext).isNull(); - } - private CloneControllerImpl createCloneController(ByteBuffer hotspotPerformanceData) { return new CloneControllerImpl( javaRuntime.new CloneControllerImplCallback(), @@ -193,8 +122,7 @@ javaRuntime.new CloneControllerImplCallback(), .initOfflineDeadlineMap(API_DEADLINE, "", 0.0, "") .build(), createRequestManager(false, true, false), - hotspotPerformanceData, - cloudDebuggerAgent); + hotspotPerformanceData); } private RequestManager createRequestManager( @@ -208,8 +136,6 @@ private RequestManager createRequestManager( .setMaxOutstandingApiRpcs(10) .setThreadStopTerminatesClone(terminateClones) .setInterruptFirstOnSoftDeadline(interruptOnSoftDeadline) - .setCloudDebuggerAgent(cloudDebuggerAgent) - .setEnableCloudDebugger(true) .setCyclesPerSecond(CYCLES_PER_SECOND) .setWaitForDaemonRequestThreads(true) .build(); diff --git a/runtime/impl/src/test/java/com/google/apphosting/runtime/JavaRuntimeParamsTest.java b/runtime/impl/src/test/java/com/google/apphosting/runtime/JavaRuntimeParamsTest.java index 1da599d0..f8dc268b 100644 --- a/runtime/impl/src/test/java/com/google/apphosting/runtime/JavaRuntimeParamsTest.java +++ b/runtime/impl/src/test/java/com/google/apphosting/runtime/JavaRuntimeParamsTest.java @@ -278,7 +278,6 @@ public void testDefaults() { // Skipped deprecated params. assertThat(params.getInterruptThreadsFirstOnSoftDeadline()).isFalse(); assertThat(params.getEnableHotspotPerformanceMetrics()).isFalse(); - assertThat(params.getEnableCloudDebugger()).isFalse(); assertThat(params.getEnableCloudCpuProfiler()).isFalse(); assertThat(params.getEnableCloudHeapProfiler()).isFalse(); assertThat(params.getUrlfetchDeriveResponseMessage()).isTrue(); diff --git a/runtime/impl/src/test/java/com/google/apphosting/runtime/RequestManagerTest.java b/runtime/impl/src/test/java/com/google/apphosting/runtime/RequestManagerTest.java index cf0d0dfe..8dd0023c 100644 --- a/runtime/impl/src/test/java/com/google/apphosting/runtime/RequestManagerTest.java +++ b/runtime/impl/src/test/java/com/google/apphosting/runtime/RequestManagerTest.java @@ -20,8 +20,6 @@ import static com.google.common.truth.Truth.assertThat; import static java.util.concurrent.TimeUnit.MILLISECONDS; import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; import com.google.apphosting.api.ApiProxy; import com.google.apphosting.api.DeadlineExceededException; @@ -62,7 +60,6 @@ import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.MockitoAnnotations; /** @@ -89,7 +86,6 @@ public class RequestManagerTest { private UPRequest upRequest; private MutableUpResponse upResponse; private RuntimeLogSink logSink; - @Mock private CloudDebuggerAgentWrapper cloudDebuggerAgent; @Mock private APIHostClientInterface mockApiHost; private boolean isJava8() { @@ -102,7 +98,6 @@ private boolean isJava8() { @BeforeClass public static void initClasses() { assertThat(true).isTrue(); - Mockito.mock(CloudDebuggerAgentWrapper.class).hasBreakpointUpdates(); } private static class DeadlineThread extends Thread { @@ -180,13 +175,11 @@ private RequestManager.Builder requestManagerBuilder() { .setRuntimeLogSink(Optional.of(logSink)) .setApiProxyImpl(ApiProxyImpl.builder().setApiHost(mockApiHost).build()) .setMaxOutstandingApiRpcs(10) - .setCloudDebuggerAgent(cloudDebuggerAgent) .setCyclesPerSecond(CYCLES_PER_SECOND) .setWaitForDaemonRequestThreads(true) .setDisableDeadlineTimers(false) .setThreadStopTerminatesClone(true) - .setInterruptFirstOnSoftDeadline(false) - .setEnableCloudDebugger(true); + .setInterruptFirstOnSoftDeadline(false); } private RequestManager createRequestManager() { @@ -320,7 +313,6 @@ public void testSoftExceptionNoCloneTermination() { RequestManager requestManager = requestManagerBuilder() .setThreadStopTerminatesClone(false) - .setEnableCloudDebugger(false) .build(); MockAnyRpcServerContext rpc = createRpc(); RequestManager.RequestToken token = @@ -355,7 +347,6 @@ public void testSoftExceptionNoTimer() { RequestManager requestManager = requestManagerBuilder() .setDisableDeadlineTimers(true) - .setEnableCloudDebugger(false) .build(); MockAnyRpcServerContext rpc = createRpc(); RequestManager.RequestToken token = @@ -403,7 +394,6 @@ public void testSoftExceptionWithInterruption() throws Exception { RequestManager requestManager = requestManagerBuilder() .setInterruptFirstOnSoftDeadline(true) - .setEnableCloudDebugger(false) .build(); MockAnyRpcServerContext rpc = createRpc(); ThreadGroup threadGroup = new ThreadGroup("test-interruption"); @@ -469,7 +459,6 @@ public void testHardExceptionNoTimer() { requestManagerBuilder() .setDisableDeadlineTimers(true) .setThreadStopTerminatesClone(false) - .setEnableCloudDebugger(false) .build(); MockAnyRpcServerContext rpc = createRpc(); RequestManager.RequestToken token = @@ -613,124 +602,6 @@ public void testRuntimeLogging() { } } - @Test - public void testCloudDebugger() { - RequestManager requestManager = createRequestManager(); - ApiProxy.Delegate delegate = mock(ApiProxy.Delegate.class); - ApiProxy.setDelegate(delegate); - - try { - // Prepare return values of 3 calls to hasBreakpointUpdates() - // as we simulate 3 sequential requests. - when(cloudDebuggerAgent.hasBreakpointUpdates()) - .thenReturn(false) - .thenReturn(false) - .thenReturn(true); - - // 1st request - MockAnyRpcServerContext rpc = createRpc(); - MutableUpResponse upResponse1 = new MutableUpResponse(); - RequestManager.RequestToken token = - requestManager.startRequest( - appVersion, rpc, upRequest, upResponse1, new ThreadGroup("test")); - requestManager.finishRequest(token); - - // Validation of PendingCloudDebuggerAction in UPResponse - // - debuggee initialization is set - // - no breakpoint updates from hasBreakpointUpdates() - Mockito.verifyNoMoreInteractions(delegate); - assertThat(upResponse1.hasPendingCloudDebuggerAction()).isTrue(); - assertThat(upResponse1.getPendingCloudDebuggerAction().getDebuggeeRegistration()).isTrue(); - assertThat(upResponse1.getPendingCloudDebuggerAction().getBreakpointUpdates()).isFalse(); - - // 2nd request - rpc = createRpc(); - MutableUpResponse upResponse2 = new MutableUpResponse(); - token = - requestManager.startRequest( - appVersion, rpc, upRequest, upResponse2, new ThreadGroup("test")); - requestManager.finishRequest(token); - - // Validation of PendingCloudDebuggerAction in UPResponse - // - no PendingCloudDebuggerAction since - // - no debuggee initialization (this is not 1st request) - // - no breakpoint updates from hasBreakpointUpdates() - Mockito.verifyNoMoreInteractions(delegate); - assertThat(upResponse2.hasPendingCloudDebuggerAction()).isFalse(); - - // 3rd request - rpc = createRpc(); - MutableUpResponse upResponse3 = new MutableUpResponse(); - token = - requestManager.startRequest( - appVersion, rpc, upRequest, upResponse3, new ThreadGroup("test")); - requestManager.finishRequest(token); - - // Validation of PendingCloudDebuggerAction in UPResponse - // - no debuggee initialization (this is not 1st request) - // - pending breakpoint updates from hasBreakpointUpdates() - Mockito.verifyNoMoreInteractions(delegate); - assertThat(upResponse3.hasPendingCloudDebuggerAction()).isTrue(); - assertThat(upResponse3.getPendingCloudDebuggerAction().getDebuggeeRegistration()).isFalse(); - assertThat(upResponse3.getPendingCloudDebuggerAction().getBreakpointUpdates()).isTrue(); - - } finally { - ApiProxy.setDelegate(null); - } - } - - @Test - public void testCloudDebuggerDisabled() { - RequestManager requestManager = requestManagerBuilder().setEnableCloudDebugger(false).build(); - - ApiProxy.Delegate delegate = mock(ApiProxy.Delegate.class); - ApiProxy.setDelegate(delegate); - - try { - MockAnyRpcServerContext rpc = createRpc(); - RequestManager.RequestToken token = - requestManager.startRequest( - appVersion, rpc, upRequest, upResponse, new ThreadGroup("test")); - requestManager.finishRequest(token); - - // Validate there's no PendingCloudDebuggerAction in UPResponse - Mockito.verifyNoMoreInteractions(cloudDebuggerAgent); - Mockito.verifyNoMoreInteractions(delegate); - assertThat(upResponse.hasPendingCloudDebuggerAction()).isFalse(); - } finally { - ApiProxy.setDelegate(null); - } - } - - @Test - public void testCloudDebuggerApplicationDisabled() { - // Cloud debugger is initially enabled. - RequestManager.Builder builder = requestManagerBuilder(); - assertThat(builder.enableCloudDebugger()).isTrue(); - RequestManager requestManager = builder.build(); - - // Now programmatically disable Cloud Debugger. - requestManager.disableCloudDebugger(); - - // Verify that the Cloud Debugger is indeed disabled on RequestManager. - ApiProxy.Delegate delegate = mock(ApiProxy.Delegate.class); - ApiProxy.setDelegate(delegate); - - try { - MockAnyRpcServerContext rpc = createRpc(); - RequestManager.RequestToken token = - requestManager.startRequest( - appVersion, rpc, upRequest, upResponse, new ThreadGroup("test")); - requestManager.finishRequest(token); - - Mockito.verifyNoMoreInteractions(cloudDebuggerAgent); - Mockito.verifyNoMoreInteractions(delegate); - assertThat(upResponse.hasPendingCloudDebuggerAction()).isFalse(); - } finally { - ApiProxy.setDelegate(null); - } - } - private MockAnyRpcServerContext createRpc() { return new MockAnyRpcServerContext(Duration.ofNanos(Math.round(RPC_DEADLINE * 1e9))); } diff --git a/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/AbstractRpcCompatibilityTest.java b/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/AbstractRpcCompatibilityTest.java index 89476e2e..9e4a0505 100644 --- a/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/AbstractRpcCompatibilityTest.java +++ b/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/AbstractRpcCompatibilityTest.java @@ -32,9 +32,6 @@ import com.google.apphosting.base.protos.AppinfoPb; import com.google.apphosting.base.protos.AppinfoPb.AppInfo; import com.google.apphosting.base.protos.ClonePb.CloneSettings; -import com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints; -import com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest; -import com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse; import com.google.apphosting.base.protos.ClonePb.PerformanceData; import com.google.apphosting.base.protos.Codes.Code; import com.google.apphosting.base.protos.EmptyMessage; @@ -830,11 +827,6 @@ private static T getFakeMessage(Class messageType) { .put( DeadlineInfo.class, DeadlineInfo.newBuilder().setSecurityTicket("tickety boo").setHard(true).build()) - .put(CloudDebuggerBreakpoints.class, makeCloudDebuggerBreakpoints()) - .put( - DebuggeeInfoRequest.class, - DebuggeeInfoRequest.newBuilder().setAppVersionId("app/1.1").build()) - .put(DebuggeeInfoResponse.class, DebuggeeInfoResponse.getDefaultInstance()) .build(); private static T implementAsUnsupported(Class interfaceToImplement) { @@ -867,12 +859,6 @@ private static PerformanceData makePerformanceData() { .build(); } - private static CloudDebuggerBreakpoints makeCloudDebuggerBreakpoints() { - return CloudDebuggerBreakpoints.newBuilder() - .addBreakpointData(ByteString.copyFrom("breakpoint", UTF_8)) - .build(); - } - private String createRandomString(int size) { Random random = new Random(); byte[] bytes = new byte[size]; diff --git a/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/ClientInterfaces.java b/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/ClientInterfaces.java index 560bf82d..f73de0db 100644 --- a/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/ClientInterfaces.java +++ b/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/ClientInterfaces.java @@ -18,9 +18,6 @@ import com.google.apphosting.base.protos.AppinfoPb.AppInfo; import com.google.apphosting.base.protos.ClonePb.CloneSettings; -import com.google.apphosting.base.protos.ClonePb.CloudDebuggerBreakpoints; -import com.google.apphosting.base.protos.ClonePb.DebuggeeInfoRequest; -import com.google.apphosting.base.protos.ClonePb.DebuggeeInfoResponse; import com.google.apphosting.base.protos.ClonePb.PerformanceData; import com.google.apphosting.base.protos.EmptyMessage; import com.google.apphosting.base.protos.ModelClonePb.DeadlineInfo; @@ -56,12 +53,5 @@ void applyCloneSettings( void getPerformanceData( AnyRpcClientContext ctx, PerformanceDataRequest req, AnyRpcCallback cb); - - void updateActiveBreakpoints( - AnyRpcClientContext ctx, CloudDebuggerBreakpoints req, - AnyRpcCallback cb); - - void getDebuggeeInfo( - AnyRpcClientContext ctx, DebuggeeInfoRequest req, AnyRpcCallback cb); } } diff --git a/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/GrpcClients.java b/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/GrpcClients.java index c7f473ce..c7ce7d92 100644 --- a/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/GrpcClients.java +++ b/runtime/impl/src/test/java/com/google/apphosting/runtime/anyrpc/GrpcClients.java @@ -143,29 +143,5 @@ public void getPerformanceData( req, streamObserver); } - - @Override - public void updateActiveBreakpoints( - AnyRpcClientContext ctx, - ClonePb.CloudDebuggerBreakpoints req, - AnyRpcCallback callback) { - GrpcClientContext grpcContext = (GrpcClientContext) ctx; - StreamObserver streamObserver = - CallbackStreamObserver.of(grpcContext, callback); - grpcContext.call( - channel, CloneControllerGrpc.getUpdateActiveBreakpointsMethod(), req, streamObserver); - } - - @Override - public void getDebuggeeInfo( - AnyRpcClientContext ctx, - ClonePb.DebuggeeInfoRequest req, - AnyRpcCallback callback) { - GrpcClientContext grpcContext = (GrpcClientContext) ctx; - StreamObserver streamObserver = - CallbackStreamObserver.of(grpcContext, callback); - grpcContext.call( - channel, CloneControllerGrpc.getGetDebuggeeInfoMethod(), req, streamObserver); - } } } diff --git a/runtime/util/src/main/java/com/google/apphosting/runtime/ClassPathUtils.java b/runtime/util/src/main/java/com/google/apphosting/runtime/ClassPathUtils.java index da9a601b..e9c2e9ae 100644 --- a/runtime/util/src/main/java/com/google/apphosting/runtime/ClassPathUtils.java +++ b/runtime/util/src/main/java/com/google/apphosting/runtime/ClassPathUtils.java @@ -68,14 +68,13 @@ public ClassPathUtils(File root) { return; } - String cloudDebuggerJar = "frozen_debugger.jar"; String profilerJar = null; if (System.getenv("GAE_PROFILER_MODE") != null) { profilerJar = "profiler.jar"; // Close source, not in Maven.; logger.log(Level.INFO, "AppEngine profiler enabled."); } List runtimeClasspathEntries = - Arrays.asList("jars/runtime-impl.jar", cloudDebuggerJar, profilerJar); + Arrays.asList("jars/runtime-impl.jar", profilerJar); String runtimeClasspath = runtimeClasspathEntries.stream()