Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not write the log in chaos log path in container #61

Open
hchenxa opened this issue Jul 15, 2020 · 3 comments
Open

can not write the log in chaos log path in container #61

hchenxa opened this issue Jul 15, 2020 · 3 comments

Comments

@hchenxa
Copy link
Contributor

hchenxa commented Jul 15, 2020

refer the chaostoolkit-run pod log below, there have permission issue when writing logs in home path.

[root@hchenxa-inf kubernetes-crd]# oc logs -n chaostoolkit-run chaostoolkit-43yr5
Traceback (most recent call last):
  File "/usr/local/bin/chaos", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 1256, in invoke
    Command.invoke(self, ctx)
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/chaostoolkit/cli.py", line 68, in cli
    context_id=str(uuid.uuid4()))
  File "/usr/local/lib/python3.5/site-packages/chaostoolkit/logging.py", line 75, in configure_logger
    loglevel=logging.DEBUG)
  File "/usr/local/lib/python3.5/site-packages/logzero/__init__.py", line 416, in logfile
    rotating_filehandler = RotatingFileHandler(filename, mode=mode, maxBytes=maxBytes, backupCount=backupCount, encoding=encoding)
  File "/usr/local/lib/python3.5/logging/handlers.py", line 150, in __init__
    BaseRotatingHandler.__init__(self, filename, mode, encoding, delay)
  File "/usr/local/lib/python3.5/logging/handlers.py", line 57, in __init__
    logging.FileHandler.__init__(self, filename, mode, encoding, delay)
  File "/usr/local/lib/python3.5/logging/__init__.py", line 1014, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/local/lib/python3.5/logging/__init__.py", line 1043, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
PermissionError: [Errno 13] Permission denied: '/home/svc/chaostoolkit.log'
@hchenxa
Copy link
Contributor Author

hchenxa commented Jul 17, 2020

I think we can expose the log operations in Configmap

@dmartin35
Copy link
Contributor

sorry for late answer,

Do you use a custom docker image or the official chaostoolkit/chaostoolkit one ?

@dmartin35
Copy link
Contributor

@hchenxa Could you please add more details on how you ended up with that issue, if you still have it ?
I can't reproduce myself on a K8s cluster with RBAC/PSP/Network Policies.

I used the following command on a shell interpreter (within the container)
/usr/local/bin/chaos run ${EXPERIMENT_PATH-$EXPERIMENT_URL} && ls -la /home/svc && echo 'JOURNAL >>>' && cat /home/svc/journal.json && echo 'CTK LOG >>>' && cat /home/svc/chaostoolkit.log

and in the log, we can see, both journal & log files were created

$ k -n chaostoolkit-run logs chaostoolkit-m3119
[2020-10-15 16:29:05 INFO] Validating the experiment's syntax
[2020-10-15 16:29:05 INFO] Experiment looks valid
[2020-10-15 16:29:05 INFO] Running experiment: Hello world!
[2020-10-15 16:29:05 INFO] Steady-state strategy: default
[2020-10-15 16:29:05 INFO] Rollbacks strategy: default
[2020-10-15 16:29:05 INFO] No steady state hypothesis defined. That's ok, just exploring.
[2020-10-15 16:29:05 INFO] Playing your experiment's method now...
[2020-10-15 16:29:05 INFO] Action: say-hello
[2020-10-15 16:29:05 INFO] Let's rollback...
[2020-10-15 16:29:05 INFO] No declared rollbacks, let's move on.
[2020-10-15 16:29:05 INFO] Experiment ended with status: completed
total 24
drwxr-sr-x    1 svc      svc           4096 Oct 15 16:29 .
drwxr-xr-x    1 root     root          4096 Sep 11 11:56 ..
-rw-r--r--    1 svc      svc           3154 Oct 15 16:29 chaostoolkit.log
-rw-r--r--    1 root     root           279 Oct 15 16:28 experiment.json
-rw-r--r--    1 svc      svc           1189 Oct 15 16:29 journal.json
JOURNAL >>>
{
  "rollbacks": [],
  "start": "2020-10-15T16:29:05.108292",
  "steady_states": {
    "after": null,
    "before": null,
    "during": []
  },
  "end": "2020-10-15T16:29:05.174448",
  "status": "completed",
  "duration": 0.07079625129699707,
  "node": "chaostoolkit-m3119",
  "chaoslib-version": "1.15.0",
  "run": [
    {
      "start": "2020-10-15T16:29:05.110123",
      "activity": {
        "type": "action",
        "name": "say-hello",
        "provider": {
          "type": "process",
          "path": "echo",
          "arguments": "hello"
        }
      },
      "output": {
        "stdout": "hello\n",
        "stderr": "",
        "status": 0
      },
      "end": "2020-10-15T16:29:05.173815",
      "status": "succeeded",
      "duration": 0.063692
    }
  ],
  "deviated": false,
  "experiment": {
    "method": [
      {
        "type": "action",
        "name": "say-hello",
        "provider": {
          "type": "process",
          "path": "echo",
          "arguments": "hello"
        }
      }
    ],
    "description": "Say hello world.",
    "version": "1.0.0",
    "title": "Hello world!",
    "dry": false
  },
  "platform": "Linux-4.19.112+-x86_64-with"
}CTK LOG >>>
[2020-10-15 16:29:04 DEBUG] [cli:74] ###############################################################################
[2020-10-15 16:29:04 DEBUG] [cli:75] Running command 'run'
[2020-10-15 16:29:04 DEBUG] [cli:79] Using settings file '/home/svc/.chaostoolkit/settings.yaml'
[2020-10-15 16:29:05 DEBUG] [settings:27] The Chaos Toolkit settings file could not be found at '/home/svc/.chaostoolkit/settings.yaml'.
[2020-10-15 16:29:05 DEBUG] [__init__:355] No controls to apply on 'loader'
[2020-10-15 16:29:05 DEBUG] [__init__:355] No controls to apply on 'loader'
[2020-10-15 16:29:05 DEBUG] [caching:25] Building activity cache...
[2020-10-15 16:29:05 DEBUG] [caching:35] Cached 1 activities
[2020-10-15 16:29:05 INFO] [experiment:47] Validating the experiment's syntax
[2020-10-15 16:29:05 DEBUG] [configuration:54] Loading configuration...
[2020-10-15 16:29:05 DEBUG] [secret:74] Loading secrets...
[2020-10-15 16:29:05 DEBUG] [secret:89] Secrets loaded
[2020-10-15 16:29:05 INFO] [experiment:96] Experiment looks valid
[2020-10-15 16:29:05 DEBUG] [caching:42] Clearing activities cache
[2020-10-15 16:29:05 DEBUG] [caching:25] Building activity cache...
[2020-10-15 16:29:05 DEBUG] [caching:35] Cached 1 activities
[2020-10-15 16:29:05 DEBUG] [configuration:54] Loading configuration...
[2020-10-15 16:29:05 DEBUG] [secret:74] Loading secrets...
[2020-10-15 16:29:05 DEBUG] [secret:89] Secrets loaded
[2020-10-15 16:29:05 INFO] [run:320] Running experiment: Hello world!
[2020-10-15 16:29:05 DEBUG] [__init__:39] Initializing controls
[2020-10-15 16:29:05 INFO] [run:340] Steady-state strategy: default
[2020-10-15 16:29:05 INFO] [run:343] Rollbacks strategy: default
[2020-10-15 16:29:05 INFO] [run:349] No steady state hypothesis defined. That's ok, just exploring.
[2020-10-15 16:29:05 DEBUG] [__init__:355] No controls to apply on 'experiment'
[2020-10-15 16:29:05 INFO] [run:551] Playing your experiment's method now...
[2020-10-15 16:29:05 DEBUG] [__init__:355] No controls to apply on 'method'
[2020-10-15 16:29:05 DEBUG] [__init__:355] No controls to apply on 'activity'
[2020-10-15 16:29:05 INFO] [activity:161] Action: say-hello
[2020-10-15 16:29:05 DEBUG] [process:53] Running: /bin/echo hello
[2020-10-15 16:29:05 DEBUG] [__init__:124] Data encoding detected as 'ascii' with a confidence of 1.0
[2020-10-15 16:29:05 DEBUG] [activity:179]   => succeeded with '{'stdout': 'hello\n', 'stderr': '', 'status': 0}'
[2020-10-15 16:29:05 DEBUG] [__init__:355] No controls to apply on 'activity'
[2020-10-15 16:29:05 DEBUG] [__init__:355] No controls to apply on 'method'
[2020-10-15 16:29:05 INFO] [run:807] Let's rollback...
[2020-10-15 16:29:05 DEBUG] [__init__:355] No controls to apply on 'rollback'
[2020-10-15 16:29:05 INFO] [rollback:25] No declared rollbacks, let's move on.
[2020-10-15 16:29:05 DEBUG] [__init__:355] No controls to apply on 'rollback'
[2020-10-15 16:29:05 INFO] [run:419] Experiment ended with status: completed
[2020-10-15 16:29:05 DEBUG] [__init__:355] No controls to apply on 'experiment'
[2020-10-15 16:29:05 DEBUG] [__init__:72] Cleaning up controls
[2020-10-15 16:29:05 DEBUG] [caching:42] Clearing activities cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants