Skip to content

Commit

Permalink
Enable verbose logging through generate-manifest.sh (antrea-io#1142)
Browse files Browse the repository at this point in the history
This patch enables verbose logging for antrea-agent and
antrea-controller when generate manifest. This will help in
troubleshooting with increased log level.
  • Loading branch information
srikartati authored and GraysonWu committed Sep 18, 2020
1 parent 672732c commit 4f9419a
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 2 deletions.
2 changes: 2 additions & 0 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ spec:
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- antrea-controller
env:
Expand Down Expand Up @@ -1267,6 +1268,7 @@ spec:
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- antrea-agent
env:
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-eks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ spec:
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- antrea-controller
env:
Expand Down Expand Up @@ -1267,6 +1268,7 @@ spec:
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- antrea-agent
env:
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-gke.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,7 @@ spec:
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- antrea-controller
env:
Expand Down Expand Up @@ -1267,6 +1268,7 @@ spec:
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- antrea-agent
env:
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea-ipsec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,7 @@ spec:
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- antrea-controller
env:
Expand Down Expand Up @@ -1281,6 +1282,7 @@ spec:
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- antrea-agent
env:
Expand Down
2 changes: 2 additions & 0 deletions build/yamls/antrea.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1146,6 +1146,7 @@ spec:
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- antrea-controller
env:
Expand Down Expand Up @@ -1272,6 +1273,7 @@ spec:
- --alsologtostderr
- --log_file_max_size=100
- --log_file_max_num=4
- --v=0
command:
- antrea-agent
env:
Expand Down
2 changes: 1 addition & 1 deletion build/yamls/base/agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ spec:
cpu: "200m"
command: ["antrea-agent"]
# Log to both "/var/log/antrea/" and stderr (so "kubectl logs" can work).
args: ["--config", "/etc/antrea/antrea-agent.conf", "--logtostderr=false", "--log_dir=/var/log/antrea", "--alsologtostderr", "--log_file_max_size=100", "--log_file_max_num=4"]
args: ["--config", "/etc/antrea/antrea-agent.conf", "--logtostderr=false", "--log_dir=/var/log/antrea", "--alsologtostderr", "--log_file_max_size=100", "--log_file_max_num=4", "--v=0"]
env:
# Provide pod and node information for clusterinformation CRD.
- name: POD_NAME
Expand Down
2 changes: 1 addition & 1 deletion build/yamls/base/controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ spec:
cpu: "200m"
command: ["antrea-controller"]
# Log to both "/var/log/antrea/" and stderr (so "kubectl logs" can work).
args: ["--config", "/etc/antrea/antrea-controller.conf", "--logtostderr=false", "--log_dir=/var/log/antrea", "--alsologtostderr", "--log_file_max_size=100", "--log_file_max_num=4"]
args: ["--config", "/etc/antrea/antrea-controller.conf", "--logtostderr=false", "--log_dir=/var/log/antrea", "--alsologtostderr", "--log_file_max_size=100", "--log_file_max_num=4", "--v=0"]
env:
# Provide pod and node information for clusterinformation CRD.
- name: POD_NAME
Expand Down
11 changes: 11 additions & 0 deletions build/yamls/patches/dev/agentVerboseLog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: antrea-agent
spec:
template:
spec:
containers:
- name: antrea-agent
args: ["--config", "/etc/antrea/antrea-agent.conf", "--logtostderr=false", "--log_dir=/var/log/antrea", "--alsologtostderr", "--log_file_max_size=100", "--log_file_max_num=4", "--v=4"]

11 changes: 11 additions & 0 deletions build/yamls/patches/dev/controllerVerboseLog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: antrea-controller
spec:
template:
spec:
containers:
- name: antrea-controller
args: ["--config", "/etc/antrea/antrea-controller.conf", "--logtostderr=false", "--log_dir=/var/log/antrea", "--alsologtostderr", "--log_file_max_size=100", "--log_file_max_num=4", "--v=4"]

8 changes: 8 additions & 0 deletions docs/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ The Open vSwitch daemon logs for each `antrea-agent` Pod are also stored on the
persistent storage of the corresponding node (i.e. the node on which the Pod is
scheduled), under `/var/log/antrea/openvswitch`.

To increase the log level for the `antrea-agent` and the `antrea-controller`, you
can edit the `--v=0` arg in the Antrea manifest to a desired level.
Alternatively, you can generate an Antrea manifest with increased log level of
4 (maximum debug level) using `generate_manifest.sh`:
```
hack/generate-manifest.sh --mode dev --verbose-log
```

## Accessing the antrea-controller API

antrea-controller runs as a Deployment, exposes its API via a Service and
Expand Down
18 changes: 18 additions & 0 deletions hack/generate-manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Generate a YAML manifest for Antrea using Kustomize and print it to stdout.
--np Generate a manifest with ClusterNetworkPolicy and Antrea NetworkPolicy features enabled
--keep Debug flag which will preserve the generated kustomization.yml
--tun (geneve|vxlan|gre|stt) Choose encap tunnel type from geneve, gre, stt and vxlan (default is geneve)
--verbose-log Generate a manifest with increased log-level (level 4) for Antrea agent and controller.
This option will work only with 'dev' mode.
--help, -h Print this message and exit
In 'release' mode, environment variables IMG_NAME and IMG_TAG must be set.
Expand Down Expand Up @@ -58,6 +60,7 @@ KEEP=false
ENCAP_MODE=""
CLOUD=""
TUN_TYPE="geneve"
VERBOSE_LOG=false

while [[ $# -gt 0 ]]
do
Expand Down Expand Up @@ -100,6 +103,10 @@ case $key in
TUN_TYPE="$2"
shift 2
;;
--verbose-log)
VERBOSE_LOG=true
shift
;;
-h|--help)
print_usage
exit 0
Expand Down Expand Up @@ -135,6 +142,12 @@ if [ "$MODE" == "release" ] && [ -z "$IMG_TAG" ]; then
exit 1
fi

if [ "$MODE" == "release" ] && [ ! -z "$VERBOSE_LOG" ]; then
echoerr "--verbose-log works only with 'dev' mode"
print_help
exit 1
fi

# noEncap/policy-only mode works with antrea-proxy.
if [[ "$ENCAP_MODE" != "" ]] && [[ "$ENCAP_MODE" != "encap" ]]; then
PROXY=true
Expand Down Expand Up @@ -290,6 +303,11 @@ if [ "$MODE" == "dev" ]; then
$KUSTOMIZE edit set image antrea=antrea/antrea-ubuntu:latest
$KUSTOMIZE edit add patch agentImagePullPolicy.yml
$KUSTOMIZE edit add patch controllerImagePullPolicy.yml
if $VERBOSE_LOG; then
$KUSTOMIZE edit add patch agentVerboseLog.yml
$KUSTOMIZE edit add patch controllerVerboseLog.yml
fi

# only required because there is no good way at the moment to update the imagePullPolicy for all
# containers. See https://github.com/kubernetes-sigs/kustomize/issues/1493
if $IPSEC; then
Expand Down

0 comments on commit 4f9419a

Please sign in to comment.