Git Product home page Git Product logo

Comments (12)

saschagrunert avatar saschagrunert commented on September 28, 2024 3

The hooks of the runtime spec are implemented by runc / crun, while OCI hooks are a thing supported by CRI-O itself.

from cri-o.

sohankunkerkar avatar sohankunkerkar commented on September 28, 2024 2

@ChucklesDroid Thank you for raising this issue. Upon reviewing the crio logs, it appears that the following error occurred:

level=error msg="Failed loading hooks for /usr/share/containers/oci/hooks.d/hooks.json: parsing hook \"/usr/share/containers/oci/hooks.d/hooks.json\": 1.0.0: json: cannot unmarshal string into Go struct field When.when.always of type bool" file="hooks/monitor.go:55"

It seems like the value of always in the hooks.json file needs to be a boolean. Please consider updating it accordingly. I believe this adjustment should address the issue.

from cri-o.

kwilczynski avatar kwilczynski commented on September 28, 2024 1

@ChucklesDroid, try running CRI-O with the the debug log level set.

Perhaps you can spot something in the more verbose output.

That said, you can also update your script such that there is some logging added. For example:

#!/usr/bin/env bash
exec 1> /tmp/hook.log 2>&1
set -ex

env

KUBEARMOR_LOG_FILE="/tmp/kubearmor.log"
echo "create-container-executed": $(date -I) $(date +%T) >> $KUBEARMOR_LOG_FILE

However, just looking at your original script, I am sure that the $USER variable might be set to a different user that you expect (or even unset in some cases as there is no guarantee for it to be present), since it's CRI-O that would run this script in the end, and you might have no permission to write to the location where the directory is pointing to (also, I assume that there is no /home/root on your file system at the moment). You have no error control enabled in your script (the set -e), as such, it will fail silently.

from cri-o.

kwilczynski avatar kwilczynski commented on September 28, 2024 1

@ChucklesDroid, now that you have things working, can we close this issue?

from cri-o.

ChucklesDroid avatar ChucklesDroid commented on September 28, 2024 1

yes lets close this @kwilczynski. Thank you everyone for your help, I appreciate that

from cri-o.

ChucklesDroid avatar ChucklesDroid commented on September 28, 2024

Hi I was able to get log data using journalctl -u crio. I have added the data in this gist file: https://gist.github.com/ChucklesDroid/d3285f7ef1dd262223b2044918aeec01

from cri-o.

ChucklesDroid avatar ChucklesDroid commented on September 28, 2024

That definitley helped out. However I am still unable to run the script. So after I changed it to boolean value. It complained about missing property hook:path. So I had to update json to the following:

{
  "version": "1.0.0",
  "hook": {
    "path": "/usr/share/containers/oci/hooks.d/create-container.sh"
  },
  "when": {
    "always": true
  },
  "stages": ["createContainer"]
}

  • So a question arises is this outdated or am I understanding it wrong ? I have also referenced this hooks schema
  • Also I can now see that hooks.json was accepted however my script still didnt run:
Feb 18 03:22:59 minikube crio[714]: time="2024-02-18 03:22:59.057434927Z" level=debug msg="hook hooks.json matched; adding to stages [createContainer]" file="hooks/hooks.go:111"

The pod was created using kubectl run pd-a --image=k8s.gcr.io/pause
Also 0755 permissions were given to the bash script specified above, is there something wrong with the bash script used?
Also this is the update gist
Your help has been amazing so far 🙌🙌

from cri-o.

kwilczynski avatar kwilczynski commented on September 28, 2024

@ChucklesDroid, some documentation around hooks can be found at the following:

Would this help?

from cri-o.

ChucklesDroid avatar ChucklesDroid commented on September 28, 2024

Hi @kwilczynski , Thanks for responding !
I have gone through both of those resources and found 2 conflicting docs which mentioned about the schema related to hooks. posix-platform-hooks and the hooks schema like I mentioned in my previous comment.

Looking at the logs the hooks.json seem to be accepted as noted by this line in the log:

Feb 18 03:22:59 minikube crio[714]: time="2024-02-18 03:22:59.057434927Z" level=debug msg="hook hooks.json matched; adding to stages [createContainer]" file="hooks/hooks.go:111"

However the bash script didn't run.(The bash script can be found above specified in the issue). So I am a bit confused what might be going wrong on my end with the script

from cri-o.

ChucklesDroid avatar ChucklesDroid commented on September 28, 2024

I am in tears Thank you for your help @kwilczynski it finally works !! You were right about $USER variable. I found this in the log file:

+ export KUBEARMOR_LOG_FILE=/home//kubearmor.log
+ KUBEARMOR_LOG_FILE=/home//kubearmor.log

Just one more thing I need to clarify. Whats the difference between posix-platform-hooks and hooks-schema?

from cri-o.

sohankunkerkar avatar sohankunkerkar commented on September 28, 2024

Just one more thing I need to clarify. Whats the difference between posix-platform-hooks and hooks-schema?

Yeah, this is an interesting question. CRI-O follows the hooks-schema in containers/common to execute OCI hooks in Kubernetes. The schema details haven't changed for more than four years now. I suspect there might be a slight divergence from OpenContainers/runtime-spec concerning the hooks aspect, at least.

@cri-o/cri-o-maintainers Any idea here?

from cri-o.

kwilczynski avatar kwilczynski commented on September 28, 2024

/assign kwilczynski
/assign sohankunkerkar

from cri-o.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.