小编use*_*872的帖子

Mesos 1.2.1和1.3.1 slave - docker job正常退出但报告为失败

我的mesos版本最近从0.28升级到1.2.1.

正在使用Chronos安排工作.我的docker作业正在被正确调用,但仍然获得TASK_FAILED错误事件,它以退出状态ZERO完成.

这是可重现的.我试过多个mesos版本,但仍然没有运气.想知道我是否遗漏了什么.

OS详细信息: -

Kernel  - 3.8.13-98.7.1.el7uek
OS - OL 7.3
Sanpshot - 7-2017.6.4
Run Code Online (Sandbox Code Playgroud)

因为,它不是最新的Kernal,我在Chronos Job环境变量中添加了以下内容,因为我无法安装最新的docker版本.

{
          "name":"DOCKER_API_VERSION",
          "value":"1.22"
      }
Run Code Online (Sandbox Code Playgroud)

使用标志启动'mesos-docker-executor'

'--container="mesos-81cb9c2a-d18b-4127-872b-2a5676dfb314-S0.97dc2c67-5d69-4a8c-b4e1-ba15807697cf" 
--docker="docker" 
--docker_socket="/var/run/docker.sock" 
--help="false" 
--initialize_driver_logging="true" 
--launcher_dir="/usr/libexec/mesos" --logbufsecs="0" 
--logging_level="INFO" 
--mapped_directory="/mnt/mesos/sandbox" 
--quiet="false" 
--sandbox_directory="/mesos-data/slave-1/slaves/81cb9c2a-d18b-4127-872b-2a5676dfb314-S0/docker/links/97dc2c67-5d69-4a8c-b4e1-ba15807697cf" 
--stop_timeout="0ns"'
Run Code Online (Sandbox Code Playgroud)

Mesos奴隶日志: -

    I0906 14:05:00.958442     9 slave.cpp:1625] Got assigned task 'ct:1504706700007:0:Job_Task_Test:' for framework 5175f6c9-0617-4145-ab46-3b7e64dc67ea-0000
I0906 14:05:00.958544     9 slave.cpp:6386] Checkpointing FrameworkInfo to '/mesos-data/slave-1/meta/slaves/81cb9c2a-d18b-4127-872b-2a5676dfb314-S0/frameworks/5175f6c9-0617-4145-ab46-3b7e64dc67ea-0000/framework.info'
I0906 14:05:00.958868     9 slave.cpp:6397] Checkpointing framework pid 'scheduler-766fa517-8ca6-430e-b044-7fa7e9b339b8@20.426.45.305:43144' to '/mesos-data/slave-1/meta/slaves/81cb9c2a-d18b-4127-872b-2a5676dfb314-S0/frameworks/5175f6c9-0617-4145-ab46-3b7e64dc67ea-0000/framework.pid'
I0906 14:05:00.959430     9 slave.cpp:1785] Launching task 'ct:1504706700007:0:Job_Task_Test:' for framework 5175f6c9-0617-4145-ab46-3b7e64dc67ea-0000
I0906 14:05:00.966035     9 paths.cpp:547] Trying …
Run Code Online (Sandbox Code Playgroud)

docker mesos mesosphere mesos-chronos

5
推荐指数
0
解决办法
466
查看次数

将 org.joda.time.Period 转换为 java.time.Period

我正在尝试用 java.time 替换 org.joda.time.Period 。

我们将以下值存储在数据库中。

P1M, P1Y, P1D, PT1H, PT1M
Run Code Online (Sandbox Code Playgroud)

只是为了解析这个值:

Period monthly = ISOPeriodFormat.standard().parsePeriod(<One of the above value from DB>);
Run Code Online (Sandbox Code Playgroud)

这很简单并且得到预期的周期。但是,现在换成java.time就麻烦了。

因为,P1D, P1M, P1Y应该使用以下代码进行解析:

java.time.Period period = java.time.Period.parse("P1M");
Run Code Online (Sandbox Code Playgroud)

并且,P1H and P1D应该使用下面的代码进行解析。

Duration dailyD = Duration.parse("P1D");
Run Code Online (Sandbox Code Playgroud)

所以,我可能还需要一些字符串检查,例如:

if(value.startsWith("PT")) {
   // Use java.time.Duration
} else {
   // Use java.time.Period
}
Run Code Online (Sandbox Code Playgroud)

这个逻辑有更好的代码吗?

另外,最后,我必须根据上面的 java.time.Period 或 java.time.Duration 查找从某个 startTime 到 截至日期 的出现次数。

就像,如果 startDateTime 是01/01/2015 08:30

LocalDateTime startDateTime = // the above startDateTime ..

    if(value.startsWith("PT")) { …
Run Code Online (Sandbox Code Playgroud)

java java-time

5
推荐指数
1
解决办法
2555
查看次数

带有数组元素的Java自定义注释

我有一个自定义注释如下.

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE, ElementType.METHOD })
@Documented
@Conditional(OnApiVersionConditional.class)
public @interface ConditionalOnApiVersion {

    int[] value() default 5;

    String property();
}
Run Code Online (Sandbox Code Playgroud)

OnApiVersionConditional是,

public class OnApiVersionConditional implements Condition {

  @Override
    public boolean matches(final ConditionContext context, final AnnotatedTypeMetadata metadata) {
        final MultiValueMap<String, Object> attributes = metadata.getAllAnnotationAttributes(ConditionalOnApiVersion.class.getName());

       attributes.get("value");


        final String inputVersion = context.getEnvironment().getProperty("userInputVersion");


    }
Run Code Online (Sandbox Code Playgroud)

在我的Bean注释中,

  @Bean
  @ConditionalOnApiVersion(value = {6, 7}, property = "userInputVersion")
Run Code Online (Sandbox Code Playgroud)

还有像单一版本匹配的bean

@Bean
@ConditionalOnApiVersion(value = 8, property = "userInputVersion")
Run Code Online (Sandbox Code Playgroud)

我想验证属性文件中的userInput版本到可用的Beans支持版本.不确定,如何获取值,迭代并与userInoutVersion进行比较.该值可以是8或{6,7}作为int数组.不确定,如何迭代该值以检查是否有任何值与输入版本匹配.

final List apiVersions = attributes.get("value").stream().collect(Collectors.toList());

题:

如何迭代attributes.get("value")并与userInputVersion进行比较?

attributes.get("value")返回一个Object列表.

我试过下面的代码,

final List<Object> apiVersions = …
Run Code Online (Sandbox Code Playgroud)

java spring java-8

5
推荐指数
1
解决办法
809
查看次数

Kubernetes码头工程量安装选项

我有一个docker图像,其中包含属性文件的选项,

CMD java -jar /opt/test/test-service.war 
--spring.config.location=file:/conf/application.properties
Run Code Online (Sandbox Code Playgroud)

-vdocker run命令中使用volume mount,如下所示.

-v /usr/xyz/props/application.properties:/conf/application.properties
Run Code Online (Sandbox Code Playgroud)

我不知道如何在Kubernetes中实现同样的目标.
我使用minikube在我的本地mac中运行kubernetes.

docker kubernetes minikube

5
推荐指数
1
解决办法
2999
查看次数

Kubernetes入口控制器-Traefik,Tectonic,Nginx

我正在探索入口,并遇到以下入口控制器:

  • 特拉菲克
  • 构造
  • Nginx的

我在Google上搜索了很多,但似乎没有太大的区别。您能帮我解决这三个方面与生产中最佳选择之间的区别吗?

注意:这适用于使用Linux VM的私有云。

谢谢。

kubernetes-ingress

5
推荐指数
0
解决办法
2228
查看次数

Kubernetes Ingress - 服务路由入口不起作用

我有一个像下面这样的入口。

kubectl get ing test-ingress -o yaml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{"kubernetes.io/ingress.class":"tectonic"},"name":"test-ingress","namespace":"nstest"},"spec":{"rules":[{"host":"test.nstest.k8s.privatecloud.com","http":{"paths":[{"backend":{"serviceName":"test","servicePort":8080},"path":"/"}]}}]}}
    kubernetes.io/ingress.class: tectonic
  creationTimestamp: 2018-03-27T17:57:02Z
  generation: 1
  name: test-ingress
  namespace: "nstest"
  resourceVersion: "19985087"
  selfLink: /apis/extensions/v1beta1/namespaces/nstest/ingresses/test-ingress
  uid: 4100bd04-31e8-11e8-8f7b-5cb9018ebebc
spec:
  rules:
  - host: test.nstest.k8s.privatecloud.com
    http:
      paths:
      - backend:
          serviceName: test
          servicePort: 8080
        path: /
status:
  loadBalancer: {}
Run Code Online (Sandbox Code Playgroud)

我的服务如下,

kubectl 获取 svc 测试 -o yaml

apiVersion: v1
kind: Service
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"test"},"name":"test","namespace":"nstest"},"spec":{"ports":[{"port":8080,"protocol":"TCP","targetPort":8080}],"selector":{"app":"test"}}}
  creationTimestamp: 2018-03-27T17:57:02Z
  labels:
    app: test
  name: test
  namespace: "nstest"
  resourceVersion: "19985067"
  selfLink: /api/v1/namespaces/nstest/services/test
  uid: …
Run Code Online (Sandbox Code Playgroud)

kubernetes kubernetes-ingress

5
推荐指数
1
解决办法
2万
查看次数

Kubernetes 部署 - 外部化日志文件

我有一个带有以下 docker 文件的 Spring Boot 应用程序。

FROM docker.com/base/jdk1.8:latest

MAINTAINER Application Engineering [ https://docker.com/ ]

RUN mkdir -p /opt/docker/svc

COPY application/weather-service.war /opt/docker/svc/

CMD java -jar /opt/docker/svc/weather-service.war --spring.config.location=file:/conf/application.properties -Dlogging.config=/conf/logback.xml
Run Code Online (Sandbox Code Playgroud)

我可以将 kubernetes configMap 或 secrets 用于 application.properties,并使用如下所示的卷挂载选项。

"spec": {
        "volumes": [
          {
            "name": "svc-prop",
            "configMap": {
              "name": "svc-app-config",
              "items": [
                {
                  "key": "application.properties",
                  "path": "application.properties"
                }
              ]
            }
          }
         ],
        "containers": [
          "volumeMounts": [
              {
                "name": "svc-prop",
                "mountPath": "/conf"
              }
         ]
Run Code Online (Sandbox Code Playgroud)

我如何才能为 logback.xml 实现相同的目标。在这种情况下,我是否需要将机密用作文件?

我不想将 logback.xml 文件与图像捆绑在一起,因为我们可能会在运行时更改日志级别。

还有其他更好的方法可以在 Kubernetes 中为 Spring Boot 应用程序保留 …

logback spring-boot kubernetes

5
推荐指数
2
解决办法
6898
查看次数

Kafka - org.apache.kafka.common.errors.NetworkException

我有一个kafka客户端代码连接到Kafka(服务器0.10.1和客户端是0.10.2)代理.代码中有2个主题和2个不同的消费者组,还有一个生产者.偶尔从生产者代码中获取NetworkException(一次在2天内,一次在5天内,......).我们看到消费者组(Re)在日志中加入了消费者组的信息,然后是生产者future.get()调用中的NetworkException.不知道为什么我们会收到此错误.

代码: -

final Future<RecordMetadata> futureResponse = 
producer.send(new ProducerRecord<>("ping_topic", "ping"));  
futureResponse.get();
Run Code Online (Sandbox Code Playgroud)

例外: -

org.apache.kafka.common.errors.NetworkException: The server disconnected before a response was received.
java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.NetworkException: The server disconnected before a response was received.
    at org.apache.kafka.clients.producer.internals.FutureRecordMetadata.valueOrError(FutureRecordMetadata.java:70)
    at org.apache.kafka.clients.producer.internals.FutureRecordMetadata.get(FutureRecordMetadata.java:57)
    at org.apache.kafka.clients.producer.internals.FutureRecordMetadata.get(FutureRecordMetadata.java:25)
Run Code Online (Sandbox Code Playgroud)

NetworkException的Kafka API定义,

"在发出请求时发生了与网络相关的错误IOException.这可能是因为客户端的元数据已经过时,它正在向一个现在已经死亡的节点发出请求."

谢谢

apache-kafka kafka-producer-api

5
推荐指数
1
解决办法
1429
查看次数

Spring Security Java - 多个身份验证管理器 - 找到2个bean错误

我的应用程序中有2个身份验证管理器.

@Configuration
@EnableWebMvcSecurity
@ComponentScan
@ImportResource("classpath:security-context.xml")
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    private AuthenticationEntryPoint webAuthenticationEntryPoint = null;

    private AuthenticationManager webAuthenticationManager = null;

    private final webPreAuthenticatedProcessingFilter webPreAuthenticatedProcessingFilter;


    public WebSecurityConfig() {
        super();
        webPreAuthenticatedProcessingFilter = new webPreAuthenticatedProcessingFilter();
        webPreAuthenticatedProcessingFilter.setAuthenticationManager(webAuthenticationManager);
        webPreAuthenticatedProcessingFilter.setInvalidateSessionOnPrincipalChange(true);
        webPreAuthenticatedProcessingFilter.setContinueFilterChainOnUnsuccessfulAuthentication(Boolean.FALSE);
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http.authorizeRequests()
            .antMatchers("/login", "/logoffUser", "/sessionExpired", "/error").permitAll()
            .anyRequest().authenticated().and().rememberMe().and().httpBasic()
            .authenticationEntryPoint(webAuthenticationEntryPoint).and()
            .addFilterAfter(webPreAuthenticatedProcessingFilter, webPreAuthenticatedProcessingFilter.class).csrf()
            .disable().logout().deleteCookies("JSESSIONID").logoutSuccessUrl("/logoff").invalidateHttpSession(true);
    }

    @Autowired
    @Qualifier("webAuthManager")
    public void setwebAuthenticationManager(AuthenticationManager webAuthenticationManager) {

        this.webAuthenticationManager = webAuthenticationManager;
        webPreAuthenticatedProcessingFilter.setAuthenticationManager(this.webAuthenticationManager);
    }

    @Autowired
    public void setwebAuthenticationEntryPoint(AuthenticationEntryPoint webAuthenticationEntryPoint) {

        this.webAuthenticationEntryPoint = webAuthenticationEntryPoint;
    }

}
Run Code Online (Sandbox Code Playgroud)

PreAuthenticatedFilter类, …

spring spring-security spring-boot

4
推荐指数
1
解决办法
1万
查看次数

处理多个时区的应用程序中的时间处理

我有来自多个时区的用户,并以 UTC 格式将时间存储在数据库中。单独遇到时间部分的问题。

按如下方式存储用户本周的工作时间。

ID 用户身份 时间 时间结束
1 1 0 10:00 18:00
2 1 1 10:00 18:00
3 1 2 10:00 18:00
4 1 3 10:00 18:00
5 1 4 10:00 18:00

日,0 表示星期日,1 表示星期一,...

此处,时间以 UTC 格式存储。UI 中的时间将根据浏览器时区进行转换。由于这里不需要日期部分,因此它在这里引起了问题。

例如,假设用户在 UI 中选择上午 7 点到下午 7 点,时间将转换为 UTC,即今天 15:00 到明天 02:00。因此,在数据库中,时间存储为

ID 用户身份 时间 时间结束
1 1 0 15:00 02:00
2 1 1 15:00 02:00
3 1 2 15:00 02:00
4 1 3 15:00 02:00
5 1 4 …

timezone datetime localization utc timezone-offset

4
推荐指数
1
解决办法
858
查看次数