You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/09/06 11:27:09 UTC
[GitHub] [flink-kubernetes-operator] morhidi opened a new pull request, #363: [FLINK-29194] Add logging for ResourceListener
morhidi opened a new pull request, #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363
## What is the purpose of the change
Being able to tell what status updates and events are being sent via the ResourceListener interfaces. It allow to easily tail/grep related messages reported under a specific resource.
## Brief change log
- Added `Unified logging for StatusRecorder/EventRecorder`
- Added `description for ResourceLifecycleState`
- Minor fix in EventRecorded to avoid creating redundant `ctx` objects if multiple ResourceListeners are registered.
## Verifying this change
Manual verification:
```
2022-09-06 13:19:47,920 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Status | Info | UPGRADING | The resource is being upgraded
2022-09-06 13:19:48,030 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Event | Info | Submit | Starting deployment
2022-09-06 13:19:48,672 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Status | Info | DEPLOYED | The resource is deployed/submitted to Kubernetes, but it’s not yet considered to be stable and might be rolled back in the future
2022-09-06 13:19:52,700 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Status | Info | DEPLOYED | The resource is deployed/submitted to Kubernetes, but it’s not yet considered to be stable and might be rolled back in the future
2022-09-06 13:20:02,857 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Event | Info | StatusChanged | Job status changed from RECONCILING to RUNNING
2022-09-06 13:20:02,927 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Status | Info | STABLE | The resource deployment is considered to be stable and won’t be rolled back
```
## Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API, i.e., is any changes to the `CustomResourceDescriptors`: no
- Core observer or reconciler logic that is regularly executed: no
## Documentation
- Does this pull request introduce a new feature? no
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] SteNicholas commented on a diff in pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
SteNicholas commented on code in PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363#discussion_r964311481
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/listener/AuditUtils.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.listener;
+
+import org.apache.flink.kubernetes.operator.crd.AbstractFlinkResource;
+import org.apache.flink.kubernetes.operator.crd.status.CommonStatus;
+
+import io.fabric8.kubernetes.api.model.Event;
+import lombok.NonNull;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Responsible for logging resource event/status updates. */
+public class AuditUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(AuditUtils.class);
+
+ public static <R extends AbstractFlinkResource<?, S>, S extends CommonStatus<?>>
+ void logContext(FlinkResourceListener.StatusUpdateContext<R, S> ctx) {
+ LOG.info(format(ctx.getNewStatus()));
+ }
+
+ public static <R extends AbstractFlinkResource<?, ?>> void logContext(
+ FlinkResourceListener.ResourceEventContext<R> ctx) {
+ LOG.info(format(ctx.getEvent()));
+ }
+
+ private static String format(@NonNull CommonStatus<?> status) {
+ return String.format(
+ ">>> Status | %-7s | %-15s | %s ",
+ StringUtils.isEmpty(status.getError()) ? "Info" : "Error",
+ status.getLifecycleState(),
+ StringUtils.isEmpty(status.getError())
+ ? status.getLifecycleState().getDescription()
+ : status.getError());
+ }
+
+ private static String format(@NonNull Event event) {
+ return String.format(
+ ">>> Event | %-7s | %-15s | %s",
+ event.getType().equals("Normal") ? "Info" : event.getType(),
+ event.getReason(),
Review Comment:
```suggestion
event.getReason().toUpperCase(),
```
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] morhidi commented on a diff in pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
morhidi commented on code in PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363#discussion_r963621972
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/StatusRecorder.java:
##########
@@ -196,6 +197,7 @@ public Instant getTimestamp() {
listener.onSessionJobStatusUpdate(ctx);
}
});
+ ListenerUtils.logContext(ctx);
Review Comment:
We're not simply logging for debugging purposes, I added extra logic to reflect the content users would normally see
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] mbalassi merged pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
mbalassi merged PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gaborgsomogyi commented on a diff in pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
gaborgsomogyi commented on code in PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363#discussion_r963607902
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/EventRecorder.java:
##########
@@ -69,34 +70,35 @@ public static EventRecorder create(
KubernetesClient client, Collection<FlinkResourceListener> listeners) {
BiConsumer<AbstractFlinkResource<?, ?>, Event> biConsumer =
- (resource, event) ->
- listeners.forEach(
- listener -> {
- var ctx =
- new FlinkResourceListener.ResourceEventContext() {
- @Override
- public Event getEvent() {
- return event;
- }
-
- @Override
- public AbstractFlinkResource<?, ?>
- getFlinkResource() {
- return resource;
- }
-
- @Override
- public KubernetesClient getKubernetesClient() {
- return client;
- }
- };
-
- if (resource instanceof FlinkDeployment) {
- listener.onDeploymentEvent(ctx);
- } else {
- listener.onSessionJobEvent(ctx);
- }
- });
+ (resource, event) -> {
+ var ctx =
+ new FlinkResourceListener.ResourceEventContext() {
+ @Override
+ public Event getEvent() {
+ return event;
+ }
+
+ @Override
+ public AbstractFlinkResource<?, ?> getFlinkResource() {
+ return resource;
+ }
+
+ @Override
+ public KubernetesClient getKubernetesClient() {
+ return client;
+ }
+ };
+ listeners.forEach(
+ listener -> {
+ if (resource instanceof FlinkDeployment) {
Review Comment:
Unrelated: instead of this `instanceof` I would personally add event specific function implementations.
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/StatusRecorder.java:
##########
@@ -196,6 +197,7 @@ public Instant getTimestamp() {
listener.onSessionJobStatusUpdate(ctx);
}
});
+ ListenerUtils.logContext(ctx);
Review Comment:
Not sure why we need to add this to `ListenerUtils`. If @gyfora pointed this out in the jira then +1 to inline it here :)
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/listener/ListenerUtils.java:
##########
@@ -134,4 +138,32 @@ private static Set<Tuple2<String, String>> findEnabledListeners(Configuration co
}
return result;
}
+
+ public static <R extends AbstractFlinkResource<?, S>, S extends CommonStatus<?>>
+ void logContext(FlinkResourceListener.StatusUpdateContext<R, S> ctx) {
+ LOG.info(format(ctx.getNewStatus()));
+ }
+
+ public static <R extends AbstractFlinkResource<?, ?>> void logContext(
+ FlinkResourceListener.ResourceEventContext<R> ctx) {
+ LOG.info(format(ctx.getEvent()));
+ }
+
+ private static String format(@NonNull CommonStatus<?> status) {
+ return String.format(
+ ">>> Status | %-7s | %-15s | %s ",
+ StringUtils.isEmpty(status.getError()) ? "Info" : "Error",
+ status.getLifecycleState(),
+ StringUtils.isEmpty(status.getError())
+ ? status.getLifecycleState().getDescription()
+ : status.getError());
+ }
+
+ private static String format(@NonNull Event event) {
+ return String.format(
+ ">>> Event | %-7s | %-15s | %s",
+ event.getType().equals("Normal") ? "Info" : event.getType(),
Review Comment:
Nit: printing a custom String w/ fixed length may end-up in truncate.
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] morhidi commented on a diff in pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
morhidi commented on code in PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363#discussion_r964381172
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/listener/AuditUtils.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.listener;
+
+import org.apache.flink.kubernetes.operator.crd.AbstractFlinkResource;
+import org.apache.flink.kubernetes.operator.crd.status.CommonStatus;
+
+import io.fabric8.kubernetes.api.model.Event;
+import lombok.NonNull;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Responsible for logging resource event/status updates. */
+public class AuditUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(AuditUtils.class);
+
+ public static <R extends AbstractFlinkResource<?, S>, S extends CommonStatus<?>>
+ void logContext(FlinkResourceListener.StatusUpdateContext<R, S> ctx) {
+ LOG.info(format(ctx.getNewStatus()));
+ }
+
+ public static <R extends AbstractFlinkResource<?, ?>> void logContext(
+ FlinkResourceListener.ResourceEventContext<R> ctx) {
+ LOG.info(format(ctx.getEvent()));
+ }
+
+ private static String format(@NonNull CommonStatus<?> status) {
+ return String.format(
+ ">>> Status | %-7s | %-15s | %s ",
+ StringUtils.isEmpty(status.getError()) ? "Info" : "Error",
+ status.getLifecycleState(),
+ StringUtils.isEmpty(status.getError())
+ ? status.getLifecycleState().getDescription()
+ : status.getError());
+ }
+
+ private static String format(@NonNull Event event) {
+ return String.format(
+ ">>> Event | %-7s | %-15s | %s",
+ event.getType().equals("Normal") ? "Info" : event.getType(),
+ event.getReason(),
Review Comment:
it feels prettier :) fixed
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] SteNicholas commented on a diff in pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
SteNicholas commented on code in PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363#discussion_r964311032
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/listener/AuditUtils.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.listener;
+
+import org.apache.flink.kubernetes.operator.crd.AbstractFlinkResource;
+import org.apache.flink.kubernetes.operator.crd.status.CommonStatus;
+
+import io.fabric8.kubernetes.api.model.Event;
+import lombok.NonNull;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/** Responsible for logging resource event/status updates. */
+public class AuditUtils {
+ private static final Logger LOG = LoggerFactory.getLogger(AuditUtils.class);
+
+ public static <R extends AbstractFlinkResource<?, S>, S extends CommonStatus<?>>
+ void logContext(FlinkResourceListener.StatusUpdateContext<R, S> ctx) {
+ LOG.info(format(ctx.getNewStatus()));
+ }
+
+ public static <R extends AbstractFlinkResource<?, ?>> void logContext(
+ FlinkResourceListener.ResourceEventContext<R> ctx) {
+ LOG.info(format(ctx.getEvent()));
+ }
+
+ private static String format(@NonNull CommonStatus<?> status) {
+ return String.format(
+ ">>> Status | %-7s | %-15s | %s ",
+ StringUtils.isEmpty(status.getError()) ? "Info" : "Error",
+ status.getLifecycleState(),
+ StringUtils.isEmpty(status.getError())
+ ? status.getLifecycleState().getDescription()
+ : status.getError());
+ }
+
+ private static String format(@NonNull Event event) {
+ return String.format(
+ ">>> Event | %-7s | %-15s | %s",
+ event.getType().equals("Normal") ? "Info" : event.getType(),
+ event.getReason(),
Review Comment:
```suggestion
event.getReason().toUpperCase(),
```
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] morhidi commented on a diff in pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
morhidi commented on code in PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363#discussion_r963702047
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/StatusRecorder.java:
##########
@@ -196,6 +197,7 @@ public Instant getTimestamp() {
listener.onSessionJobStatusUpdate(ctx);
}
});
+ ListenerUtils.logContext(ctx);
Review Comment:
Moved the logging to a new `AuditUtils` class which makes more sense agree :)
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] morhidi commented on a diff in pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
morhidi commented on code in PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363#discussion_r963621189
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/StatusRecorder.java:
##########
@@ -196,6 +197,7 @@ public Instant getTimestamp() {
listener.onSessionJobStatusUpdate(ctx);
}
});
+ ListenerUtils.logContext(ctx);
Review Comment:
With this approach we have a nice and aligned table on these logs, when I grep it is easier to grep on ListenerUtils.
```
2022-09-06 13:19:47,920 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Status | Info | UPGRADING | The resource is being upgraded
2022-09-06 13:19:48,030 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Event | Info | Submit | Starting deployment
2022-09-06 13:19:48,672 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Status | Info | DEPLOYED | The resource is deployed/submitted to Kubernetes, but it’s not yet considered to be stable and might be rolled back in the future
2022-09-06 13:19:52,700 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Status | Info | DEPLOYED | The resource is deployed/submitted to Kubernetes, but it’s not yet considered to be stable and might be rolled back in the future
2022-09-06 13:20:02,857 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Event | Info | StatusChanged | Job status changed from RECONCILING to RUNNING
2022-09-06 13:20:02,927 o.a.f.k.o.l.ListenerUtils [INFO ] [default.basic-example] >>> Status | Info | STABLE | The resource deployment is considered to be stable and won’t be rolled back
```
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] morhidi commented on a diff in pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
morhidi commented on code in PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363#discussion_r963622773
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/StatusRecorder.java:
##########
@@ -196,6 +197,7 @@ public Instant getTimestamp() {
listener.onSessionJobStatusUpdate(ctx);
}
});
+ ListenerUtils.logContext(ctx);
Review Comment:
This should tell a nice story to the user.
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] morhidi commented on a diff in pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
morhidi commented on code in PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363#discussion_r963647252
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/EventRecorder.java:
##########
@@ -69,34 +70,35 @@ public static EventRecorder create(
KubernetesClient client, Collection<FlinkResourceListener> listeners) {
BiConsumer<AbstractFlinkResource<?, ?>, Event> biConsumer =
- (resource, event) ->
- listeners.forEach(
- listener -> {
- var ctx =
- new FlinkResourceListener.ResourceEventContext() {
- @Override
- public Event getEvent() {
- return event;
- }
-
- @Override
- public AbstractFlinkResource<?, ?>
- getFlinkResource() {
- return resource;
- }
-
- @Override
- public KubernetesClient getKubernetesClient() {
- return client;
- }
- };
-
- if (resource instanceof FlinkDeployment) {
- listener.onDeploymentEvent(ctx);
- } else {
- listener.onSessionJobEvent(ctx);
- }
- });
+ (resource, event) -> {
+ var ctx =
+ new FlinkResourceListener.ResourceEventContext() {
+ @Override
+ public Event getEvent() {
+ return event;
+ }
+
+ @Override
+ public AbstractFlinkResource<?, ?> getFlinkResource() {
+ return resource;
+ }
+
+ @Override
+ public KubernetesClient getKubernetesClient() {
+ return client;
+ }
+ };
+ listeners.forEach(
+ listener -> {
+ if (resource instanceof FlinkDeployment) {
Review Comment:
Don't want to touch this part in this PR
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] gaborgsomogyi commented on a diff in pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
gaborgsomogyi commented on code in PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363#discussion_r963664493
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/utils/StatusRecorder.java:
##########
@@ -196,6 +197,7 @@ public Instant getTimestamp() {
listener.onSessionJobStatusUpdate(ctx);
}
});
+ ListenerUtils.logContext(ctx);
Review Comment:
I agree w/ you basically. If I understand correctly this is mainly for user and tracks history.
Can we rename `ListenerUtils` to something more meaningful?
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [flink-kubernetes-operator] morhidi commented on a diff in pull request #363: [FLINK-29194] Add logging for ResourceListener
Posted by GitBox <gi...@apache.org>.
morhidi commented on code in PR #363:
URL: https://github.com/apache/flink-kubernetes-operator/pull/363#discussion_r963646703
##########
flink-kubernetes-operator/src/main/java/org/apache/flink/kubernetes/operator/listener/ListenerUtils.java:
##########
@@ -134,4 +138,32 @@ private static Set<Tuple2<String, String>> findEnabledListeners(Configuration co
}
return result;
}
+
+ public static <R extends AbstractFlinkResource<?, S>, S extends CommonStatus<?>>
+ void logContext(FlinkResourceListener.StatusUpdateContext<R, S> ctx) {
+ LOG.info(format(ctx.getNewStatus()));
+ }
+
+ public static <R extends AbstractFlinkResource<?, ?>> void logContext(
+ FlinkResourceListener.ResourceEventContext<R> ctx) {
+ LOG.info(format(ctx.getEvent()));
+ }
+
+ private static String format(@NonNull CommonStatus<?> status) {
+ return String.format(
+ ">>> Status | %-7s | %-15s | %s ",
+ StringUtils.isEmpty(status.getError()) ? "Info" : "Error",
+ status.getLifecycleState(),
+ StringUtils.isEmpty(status.getError())
+ ? status.getLifecycleState().getDescription()
+ : status.getError());
+ }
+
+ private static String format(@NonNull Event event) {
+ return String.format(
+ ">>> Event | %-7s | %-15s | %s",
+ event.getType().equals("Normal") ? "Info" : event.getType(),
Review Comment:
We have Info/Error/Warning there, should be fine
--
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-unsubscribe@flink.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org