gyfora commented on code in PR #749: URL: https://github.com/apache/flink-kubernetes-operator/pull/749#discussion_r1444205943
########## flink-kubernetes-operator-api/src/main/java/org/apache/flink/kubernetes/operator/api/status/CommonCRStatus.java: ########## @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.kubernetes.operator.api.status; + +import io.fabric8.kubernetes.api.model.Condition; +import io.fabric8.kubernetes.api.model.ConditionBuilder; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** Status of CR. */ +public class CommonCRStatus { Review Comment: This is a very confusing class name. We already have `CommonStatus` which is actually part of the status (superclass). This class here is just a utility class for creating `Condition` objects. So maybe `FlinkConditions` or `ConditionUtils` would be a better name. ########## flink-kubernetes-operator-api/src/main/java/org/apache/flink/kubernetes/operator/api/status/CommonCRStatus.java: ########## @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.kubernetes.operator.api.status; + +import io.fabric8.kubernetes.api.model.Condition; +import io.fabric8.kubernetes.api.model.ConditionBuilder; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** Status of CR. */ +public class CommonCRStatus { + + public static Condition crReadyTrueCondition(final String message) { + return crCondition("Ready", "True", message, "Ready"); + } + + public static Condition crReadyFalseCondition(final String message) { + return crCondition("Ready", "False", message, "Progressing"); + } + + public static Condition crErrorCondition(final String message) { + return crCondition("Error", "True", message, "UnhandledException"); + } + + public static Condition crCondition( Review Comment: I think if we rename the class we can also rename this methods simply to: `neady` / `notReady` / `error` ########## flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/controller/FlinkDeploymentController.java: ########## @@ -227,4 +235,28 @@ private boolean validateDeployment(FlinkResourceContext<FlinkDeployment> ctx) { } return true; } + + private void setCRStatus(FlinkDeployment flinkApp) { Review Comment: Instead of having to call `setCrStatus` can we move this logic to within the actual `CommonStatus` or `FlinkDeploymentStatus` so that it's computed automatically like the `ResourceLifecycleState`? Also I think we could actually compute this directly from the resource lifecycle state instead of adding arbitrary new logic here ########## flink-kubernetes-operator-api/src/main/java/org/apache/flink/kubernetes/operator/api/status/CommonCRStatus.java: ########## @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.kubernetes.operator.api.status; + +import io.fabric8.kubernetes.api.model.Condition; +import io.fabric8.kubernetes.api.model.ConditionBuilder; + +import java.text.SimpleDateFormat; +import java.util.Date; + +/** Status of CR. */ +public class CommonCRStatus { + + public static Condition crReadyTrueCondition(final String message) { + return crCondition("Ready", "True", message, "Ready"); + } + + public static Condition crReadyFalseCondition(final String message) { + return crCondition("Ready", "False", message, "Progressing"); + } + + public static Condition crErrorCondition(final String message) { + return crCondition("Error", "True", message, "UnhandledException"); Review Comment: Why is the message `UnhandledException `? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org