Search in sources :

Example 56 with Check

use of io.fabric8.karaf.checks.Check in project strimzi by strimzi.

the class ControllerTest method testOnConfigMapAdded_ClusterAuthorizationException.

/**
 * 1. controller is notified that a ConfigMap is created
 * 2. error when creating topic in kafka
 */
@Test
public void testOnConfigMapAdded_ClusterAuthorizationException(TestContext context) {
    Exception createException = new ClusterAuthorizationException("");
    Controller op = configMapAdded(context, createException, null);
// TODO check a k8s event got created
// TODO what happens when we subsequently reconcile?
}
Also used : KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) ClusterAuthorizationException(org.apache.kafka.common.errors.ClusterAuthorizationException) TopicExistsException(org.apache.kafka.common.errors.TopicExistsException) UnknownTopicOrPartitionException(org.apache.kafka.common.errors.UnknownTopicOrPartitionException) ClusterAuthorizationException(org.apache.kafka.common.errors.ClusterAuthorizationException) Test(org.junit.Test)

Example 57 with Check

use of io.fabric8.karaf.checks.Check in project strimzi by strimzi.

the class ControllerTest method testOnConfigMapAdded_TopicExistsException.

/**
 * 1. controller is notified that a ConfigMap is created
 * 2. error when creating topic in kafka
 */
@Test
public void testOnConfigMapAdded_TopicExistsException(TestContext context) {
    Exception createException = new TopicExistsException("");
    configMapAdded(context, createException, null);
// TODO check a k8s event got created
// TODO what happens when we subsequently reconcile?
}
Also used : TopicExistsException(org.apache.kafka.common.errors.TopicExistsException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) ClusterAuthorizationException(org.apache.kafka.common.errors.ClusterAuthorizationException) TopicExistsException(org.apache.kafka.common.errors.TopicExistsException) UnknownTopicOrPartitionException(org.apache.kafka.common.errors.UnknownTopicOrPartitionException) Test(org.junit.Test)

Example 58 with Check

use of io.fabric8.karaf.checks.Check in project strimzi by strimzi.

the class OpenShiftTemplatesTest method testStrimziPersistentWithCustomParameters.

@Test
public void testStrimziPersistentWithCustomParameters() throws IOException {
    String clusterName = "test-persistent-with-custom-parameters";
    oc.newApp("strimzi-persistent", map("CLUSTER_NAME", clusterName, "ZOOKEEPER_HEALTHCHECK_DELAY", "30", "ZOOKEEPER_HEALTHCHECK_TIMEOUT", "10", "KAFKA_HEALTHCHECK_DELAY", "30", "KAFKA_HEALTHCHECK_TIMEOUT", "10", "KAFKA_DEFAULT_REPLICATION_FACTOR", "2", "KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR", "5", "KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR", "5", "ZOOKEEPER_VOLUME_CAPACITY", "2Gi", "KAFKA_VOLUME_CAPACITY", "2Gi"));
    // TODO Add assertions to check that Kafka brokers have a custom configuration
    ConfigMap cm = client.configMaps().inNamespace(NAMESPACE).withName(clusterName).get();
    assertNotNull(cm);
    Map<String, String> cmData = cm.getData();
    assertEquals("30", cmData.get("zookeeper-healthcheck-delay"));
    assertEquals("10", cmData.get("zookeeper-healthcheck-timeout"));
    assertEquals("30", cmData.get("kafka-healthcheck-delay"));
    assertEquals("10", cmData.get("kafka-healthcheck-timeout"));
    assertEquals("2", cmData.get("KAFKA_DEFAULT_REPLICATION_FACTOR"));
    assertEquals("5", cmData.get("KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR"));
    assertEquals("5", cmData.get("KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR"));
    assertEquals("2Gi", mapper.readTree(cmData.get("kafka-storage")).get("size").asText());
    assertEquals("2Gi", mapper.readTree(cmData.get("zookeeper-storage")).get("size").asText());
}
Also used : ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) Test(org.junit.Test)

Example 59 with Check

use of io.fabric8.karaf.checks.Check in project flink by apache.

the class KubernetesClusterDescriptorTest method checkUpdatedConfigAndResourceSetting.

private void checkUpdatedConfigAndResourceSetting() {
    // Check updated flink config options
    assertEquals(String.valueOf(Constants.BLOB_SERVER_PORT), flinkConfig.getString(BlobServerOptions.PORT));
    assertEquals(String.valueOf(Constants.TASK_MANAGER_RPC_PORT), flinkConfig.getString(TaskManagerOptions.RPC_PORT));
    assertEquals(InternalServiceDecorator.getNamespacedInternalServiceName(CLUSTER_ID, NAMESPACE), flinkConfig.getString(JobManagerOptions.ADDRESS));
    final Deployment jmDeployment = kubeClient.apps().deployments().list().getItems().get(0);
    final Container jmContainer = jmDeployment.getSpec().getTemplate().getSpec().getContainers().get(0);
    assertEquals(String.valueOf(clusterSpecification.getMasterMemoryMB()), jmContainer.getResources().getRequests().get(Constants.RESOURCE_NAME_MEMORY).getAmount());
    assertEquals(String.valueOf(clusterSpecification.getMasterMemoryMB()), jmContainer.getResources().getLimits().get(Constants.RESOURCE_NAME_MEMORY).getAmount());
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) Deployment(io.fabric8.kubernetes.api.model.apps.Deployment)

Example 60 with Check

use of io.fabric8.karaf.checks.Check in project alluxio by Alluxio.

the class ManagerProcessContext method handleStatusRuntimeException.

private void handleStatusRuntimeException(String message, Throwable t) {
    LogUtils.warnWithException(LOG, message, t);
    if (Status.fromThrowable(t).getCode() == Status.UNAUTHENTICATED.getCode()) {
        if (mLock.tryLock()) {
            try {
                // shut down the Hub Manager and Agents
                String msg = String.format("Shutting down the Hub Agent because the Hub Manager is " + "unauthenticated. Check %s, %s properties in the Hub Manager's " + "alluxio-site.properties.", PropertyKey.Name.HUB_AUTHENTICATION_API_KEY, PropertyKey.Name.HUB_AUTHENTICATION_SECRET_KEY);
                AgentShutdownRequest req = AgentShutdownRequest.newBuilder().setLogMessage(msg).setExitCode(401).build();
                Function<AgentManagerServiceGrpc.AgentManagerServiceBlockingStub, AgentShutdownResponse> x = (client) -> {
                    AgentShutdownResponse resp = client.shutdown(req);
                    return resp;
                };
                try {
                    execOnHub(x);
                } catch (Exception e) {
                    LogUtils.warnWithException(LOG, "Failed to call shutdown() on Hub Agent. " + "Continuing with shutting down Hub Manager.", e);
                }
            } finally {
                mLock.unlock();
            }
        }
        LOG.error(String.format("Shutting down the Hub manager because it is unauthenticated. " + "Check %s, %s properties in alluxio-site.properties.", PropertyKey.Name.HUB_AUTHENTICATION_API_KEY, PropertyKey.Name.HUB_AUTHENTICATION_SECRET_KEY));
        System.exit(401);
    }
}
Also used : RemoveFile(alluxio.hub.proto.RemoveFile) PropertyKey(alluxio.conf.PropertyKey) UploadFile(alluxio.hub.proto.UploadFile) IOTaskSummary(alluxio.stress.worker.IOTaskSummary) FileSystem(alluxio.client.file.FileSystem) SpeedTestRequest(alluxio.hub.proto.SpeedTestRequest) AgentFileUploadResponse(alluxio.hub.proto.AgentFileUploadResponse) Duration(java.time.Duration) Map(java.util.Map) Status(io.grpc.Status) CLUSTER_DEFAULT(alluxio.conf.Source.CLUSTER_DEFAULT) AgentWriteConfigurationSetRequest(alluxio.hub.proto.AgentWriteConfigurationSetRequest) ValidationUtils(alluxio.cli.ValidationUtils) AgentProcessStatusChangeResponse(alluxio.hub.proto.AgentProcessStatusChangeResponse) RpcClient(alluxio.hub.common.RpcClient) Set(java.util.Set) AlluxioException(alluxio.exception.AlluxioException) AgentHeartbeatRequest(alluxio.hub.proto.AgentHeartbeatRequest) ThreadSafe(javax.annotation.concurrent.ThreadSafe) GetPrestoConfDirResponse(alluxio.hub.proto.GetPrestoConfDirResponse) AlluxioProperties(alluxio.conf.AlluxioProperties) StandardCharsets(java.nio.charset.StandardCharsets) Executors(java.util.concurrent.Executors) AgentGetConfigurationSetRequest(alluxio.hub.proto.AgentGetConfigurationSetRequest) Config(io.fabric8.kubernetes.client.Config) Source(alluxio.conf.Source) InstancedConfiguration(alluxio.conf.InstancedConfiguration) AgentFileUploadRequest(alluxio.hub.proto.AgentFileUploadRequest) RuntimeConstants(alluxio.RuntimeConstants) AgentShutdownRequest(alluxio.hub.proto.AgentShutdownRequest) DetectPrestoResponse(alluxio.hub.proto.DetectPrestoResponse) RemoveFileRequest(alluxio.hub.proto.RemoveFileRequest) ProcessStatusChangeResponse(alluxio.hub.proto.ProcessStatusChangeResponse) ArrayList(java.util.ArrayList) UfsIOBench(alluxio.stress.cli.UfsIOBench) AlluxioClusterHeartbeatResponse(alluxio.hub.proto.AlluxioClusterHeartbeatResponse) AlluxioURI(alluxio.AlluxioURI) HubNodeAddress(alluxio.hub.proto.HubNodeAddress) ListMountPointResponse(alluxio.hub.proto.ListMountPointResponse) RequestStreamObserver(alluxio.hub.manager.rpc.observer.RequestStreamObserver) UfsIOParameters(alluxio.stress.worker.UfsIOParameters) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) AlluxioConfiguration(alluxio.conf.AlluxioConfiguration) MountPOptions(alluxio.grpc.MountPOptions) HubAuthenticationInterceptor(alluxio.hub.manager.rpc.interceptor.HubAuthenticationInterceptor) RetryPolicy(alluxio.retry.RetryPolicy) Nullable(javax.annotation.Nullable) ListFile(alluxio.hub.proto.ListFile) Properties(java.util.Properties) AgentDetectPrestoResponse(alluxio.hub.proto.AgentDetectPrestoResponse) PingManagerRequest(alluxio.hub.proto.PingManagerRequest) IOException(java.io.IOException) AgentWriteConfigurationSetResponse(alluxio.hub.proto.AgentWriteConfigurationSetResponse) DeleteMountPointResponse(alluxio.hub.proto.DeleteMountPointResponse) AlluxioClusterHeartbeatRequest(alluxio.hub.proto.AlluxioClusterHeartbeatRequest) ConfigMap(io.fabric8.kubernetes.api.model.ConfigMap) ConfigMapBuilder(io.fabric8.kubernetes.api.model.ConfigMapBuilder) ApplyMountPointResponse(alluxio.hub.proto.ApplyMountPointResponse) Lock(java.util.concurrent.locks.Lock) HubAuthentication(alluxio.hub.proto.HubAuthentication) AgentSetPrestoConfRequest(alluxio.hub.proto.AgentSetPrestoConfRequest) PingManagerResponse(alluxio.hub.proto.PingManagerResponse) Preconditions(com.google.common.base.Preconditions) UploadFileResponse(alluxio.hub.proto.UploadFileResponse) AgentListFileRequest(alluxio.hub.proto.AgentListFileRequest) HubUtil(alluxio.hub.common.HubUtil) DetectPrestoRequest(alluxio.hub.proto.DetectPrestoRequest) AgentSetPrestoConfResponse(alluxio.hub.proto.AgentSetPrestoConfResponse) AlluxioCluster(alluxio.hub.manager.util.AlluxioCluster) AgentShutdownResponse(alluxio.hub.proto.AgentShutdownResponse) ListCatalogRequest(alluxio.hub.proto.ListCatalogRequest) JsonSerializable(alluxio.util.JsonSerializable) AlluxioConfigurationSet(alluxio.hub.proto.AlluxioConfigurationSet) LoggerFactory(org.slf4j.LoggerFactory) SpeedTestResponse(alluxio.hub.proto.SpeedTestResponse) Channel(io.grpc.Channel) GetConfigurationSetResponse(alluxio.hub.proto.GetConfigurationSetResponse) RegisterManagerResponse(alluxio.hub.proto.RegisterManagerResponse) LogUtils(alluxio.util.LogUtils) AgentRemoveFileResponse(alluxio.hub.proto.AgentRemoveFileResponse) HostedManagerServiceGrpc(alluxio.hub.proto.HostedManagerServiceGrpc) InvalidPathException(alluxio.exception.InvalidPathException) StreamObserver(io.grpc.stub.StreamObserver) DeleteMountPointRequest(alluxio.hub.proto.DeleteMountPointRequest) ByteArrayInputStream(java.io.ByteArrayInputStream) GrpcChannel(alluxio.grpc.GrpcChannel) AgentDetectPrestoRequest(alluxio.hub.proto.AgentDetectPrestoRequest) DefaultKubernetesClient(io.fabric8.kubernetes.client.DefaultKubernetesClient) RegisterManagerRequest(alluxio.hub.proto.RegisterManagerRequest) HubCluster(alluxio.hub.manager.util.HubCluster) ServerConfiguration(alluxio.conf.ServerConfiguration) ImmutableMap(com.google.common.collect.ImmutableMap) ExponentialTimeBoundedRetry(alluxio.retry.ExponentialTimeBoundedRetry) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) GetConfigurationSetRequest(alluxio.hub.proto.GetConfigurationSetRequest) SetPrestoConfDirRequest(alluxio.hub.proto.SetPrestoConfDirRequest) ByteString(com.google.protobuf.ByteString) Base64(java.util.Base64) List(java.util.List) SetPrestoConfDirResponse(alluxio.hub.proto.SetPrestoConfDirResponse) HubMetadata(alluxio.hub.proto.HubMetadata) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) ListCatalogResponse(alluxio.hub.proto.ListCatalogResponse) RemoveFileResponse(alluxio.hub.proto.RemoveFileResponse) Pattern(java.util.regex.Pattern) AgentListCatalogRequest(alluxio.hub.proto.AgentListCatalogRequest) ExponentialBackoffRetry(alluxio.retry.ExponentialBackoffRetry) MountPointInfo(alluxio.wire.MountPointInfo) HashMap(java.util.HashMap) NetworkAddressUtils(alluxio.util.network.NetworkAddressUtils) AgentManagerServiceGrpc(alluxio.hub.proto.AgentManagerServiceGrpc) ListFileResponse(alluxio.hub.proto.ListFileResponse) Function(java.util.function.Function) SpeedStat(alluxio.hub.proto.SpeedStat) WriteConfigurationSetResponse(alluxio.hub.proto.WriteConfigurationSetResponse) ExecutionType(alluxio.hub.proto.ExecutionType) AlluxioNodeType(alluxio.hub.proto.AlluxioNodeType) PrestoCatalogListingResult(alluxio.hub.proto.PrestoCatalogListingResult) PathUtils(alluxio.util.io.PathUtils) ImmutableList(com.google.common.collect.ImmutableList) HDFSMountPointInfo(alluxio.hub.proto.HDFSMountPointInfo) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException) AlluxioEdition(alluxio.hub.proto.AlluxioEdition) ExecutorService(java.util.concurrent.ExecutorService) RegisterAgentRequest(alluxio.hub.proto.RegisterAgentRequest) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) AgentRemoveFileRequest(alluxio.hub.proto.AgentRemoveFileRequest) ApplyMountPointRequest(alluxio.hub.proto.ApplyMountPointRequest) GetPrestoConfDirRequest(alluxio.hub.proto.GetPrestoConfDirRequest) ThreadFactoryUtils(alluxio.util.ThreadFactoryUtils) Pair(alluxio.collections.Pair) UploadFileRequest(alluxio.hub.proto.UploadFileRequest) HubStatus(alluxio.hub.proto.HubStatus) ConfigurationUtils(alluxio.util.ConfigurationUtils) HubSslContextProvider(alluxio.hub.common.HubSslContextProvider) ProcessStatusChangeRequest(alluxio.hub.proto.ProcessStatusChangeRequest) WriteConfigurationSetRequest(alluxio.hub.proto.WriteConfigurationSetRequest) FileSystemContext(alluxio.client.file.FileSystemContext) ListFileRequest(alluxio.hub.proto.ListFileRequest) KubernetesClient(io.fabric8.kubernetes.client.KubernetesClient) VisibleForTesting(com.google.common.annotations.VisibleForTesting) ConfigBuilder(io.fabric8.kubernetes.client.ConfigBuilder) ListMountPointRequest(alluxio.hub.proto.ListMountPointRequest) Collections(java.util.Collections) SpeedTestParameter(alluxio.hub.proto.SpeedTestParameter) AgentShutdownResponse(alluxio.hub.proto.AgentShutdownResponse) AgentShutdownRequest(alluxio.hub.proto.AgentShutdownRequest) ByteString(com.google.protobuf.ByteString) AlluxioException(alluxio.exception.AlluxioException) IOException(java.io.IOException) InvalidPathException(alluxio.exception.InvalidPathException) FileDoesNotExistException(alluxio.exception.FileDoesNotExistException) AlluxioStatusException(alluxio.exception.status.AlluxioStatusException)

Aggregations

Test (org.junit.Test)35 IOException (java.io.IOException)23 File (java.io.File)17 ArrayList (java.util.ArrayList)17 HashMap (java.util.HashMap)15 FabricService (io.fabric8.api.FabricService)11 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)11 Map (java.util.Map)10 Container (io.fabric8.api.Container)9 PatchException (io.fabric8.patch.management.PatchException)9 Expectations (mockit.Expectations)9 Profile (io.fabric8.api.Profile)8 TreeMap (java.util.TreeMap)7 Version (io.fabric8.api.Version)6 KubernetesClient (io.fabric8.kubernetes.client.KubernetesClient)6 AuthConfig (io.fabric8.maven.docker.access.AuthConfig)6 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)6 Check (io.fabric8.karaf.checks.Check)5 KubernetesListBuilder (io.fabric8.kubernetes.api.model.KubernetesListBuilder)5 Patch (io.fabric8.patch.management.Patch)5