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

Hooks validation tests cannot pass #781

Open
nixpig opened this issue Nov 27, 2024 · 3 comments · May be fixed by #782
Open

Hooks validation tests cannot pass #781

nixpig opened this issue Nov 27, 2024 · 3 comments · May be fixed by #782

Comments

@nixpig
Copy link

nixpig commented Nov 27, 2024

Running the validation/hooks/hooks.t tests should pass, but they always fail.

For example, using runc:

RUNTIME=runc ./validation/hooks/hooks.t
TAP version 13
  ---
  {
    "error": "Hooks MUST be called in the listed order\nRefer to: https://github.com/opencontainers/runtime-spec/blob/v1.1.0/config.md#posix-platform-hooks\nThe runtime MUST run the user-specified program, as specified by `process`\nRefer to: https://github.com/opencontainers/runtime-spec/blob/v1.1.0/runtime.md#lifecycle"
  }
  ...
1..0

Seems to be two issues here:

  1. The bundle directory (where the output file is stored) is deleted (in RuntimeLifecycleValidate) before the output file is read for comparison:
    err := util.RuntimeLifecycleValidate(config)
    outputData, _ := os.ReadFile(output)
    Because of this:
    1. The content of outputData is always empty.
    2. We don't see the 'file not found' error from os.ReadFile because it's ignored.
  2. Even if outputData was populated per the specified hooks, the comparison of its content will always fail:
    if err == nil && string(outputData) != "pre-start1 called\npre-start2 called\npost-start1\npost-start2\npost-stop1\npost-stop2\n" {
    1. Actual content: pre-start1 called\npre-start2 called\npost-start1 called\npost-start2 called\npost-stop1 called\npost-stop2 called\n
    2. Asserted content: pre-start1 called\npre-start2 called\npost-start1\npost-start2\npost-stop1\npost-stop2\n
    3. Note the lack of called postfix for post-startx and post-stopx hooks.
@nixpig nixpig linked a pull request Nov 27, 2024 that will close this issue
@nixpig
Copy link
Author

nixpig commented Nov 27, 2024

PR with proposed fix: #782

@ghost
Copy link

ghost commented Dec 13, 2024

Running the validation/hooks/hooks.t tests should pass, but they always fail.

For example, using runc:

RUNTIME=runc ./validation/hooks/hooks.t
TAP version 13
  ---
  {
    "error": "Hooks MUST be called in the listed order\nRefer to: https://github.com/opencontainers/runtime-spec/blob/v1.1.0/config.md#posix-platform-hooks\nThe runtime MUST run the user-specified program, as specified by `process`\nRefer to: https://github.com/opencontainers/runtime-spec/blob/v1.1.0/runtime.md#lifecycle"
  }
  ...
1..0

Seems to be two issues here:

  1. The bundle directory (where the output file is stored) is deleted (in RuntimeLifecycleValidate) before the output file is read for comparison:

    err := util.RuntimeLifecycleValidate(config)
    outputData, _ := os.ReadFile(output)

    Because of this:

    1. The content of outputData is always empty.
    2. We don't see the 'file not found' error from os.ReadFile because it's ignored.
  2. Even if outputData was populated per the specified hooks, the comparison of its content will always fail:

    if err == nil && string(outputData) != "pre-start1 called\npre-start2 called\npost-start1\npost-start2\npost-stop1\npost-stop2\n" {

    1. Actual content: pre-start1 called\npre-start2 called\npost-start1 called\npost-start2 called\npost-stop1 called\npost-stop2 called\n
    2. Asserted content: pre-start1 called\npre-start2 called\npost-start1\npost-start2\npost-stop1\npost-stop2\n
    3. Note the lack of called postfix for post-startx and post-stopx hooks.

@ghost
Copy link

ghost commented Dec 13, 2024

#781 (comment)

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

Successfully merging a pull request may close this issue.

1 participant