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

actions: run: Check script exists during recipe verification #302

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

obbardc
Copy link
Member

@obbardc obbardc commented Jan 7, 2022

If a script doesn't exist or the permissions are wrong, the
recipe exits during execution. Let's check early if the
script exists on the host filesystem and that the file has
executable permission bit set.

Signed-off-by: Christopher Obbard chris.obbard@collabora.com

@obbardc obbardc force-pushed the wip/obbardc/fix-run-missing-mount branch from a8a574e to f4d49c5 Compare January 7, 2022 09:09
actions/run_action.go Outdated Show resolved Hide resolved
actions/run_action.go Outdated Show resolved Hide resolved
@sjoerdsimons
Copy link
Member

fwiw this would be a great change to start adding test for

@obbardc obbardc added this to the v1.1.2 milestone Oct 12, 2022
@obbardc obbardc self-assigned this Oct 27, 2022
@obbardc obbardc removed this from the v1.1.2 milestone Jul 26, 2023
@obbardc obbardc changed the title actions/run: Check script exists during recipe verification actions: run: Check script exists during recipe verification Jul 27, 2023
@obbardc obbardc force-pushed the wip/obbardc/fix-run-missing-mount branch 2 times, most recently from 27c3f44 to fb2c1c0 Compare July 27, 2023 12:38
@obbardc obbardc force-pushed the wip/obbardc/fix-run-missing-mount branch from fb2c1c0 to 8fd0ace Compare July 27, 2023 12:40
@obbardc obbardc force-pushed the wip/obbardc/fix-run-missing-mount branch from 8fd0ace to 8c6a800 Compare January 10, 2024 15:16
Rework the logic to extract the script path and arguments into one place
such that the code is more readable with less duplication.

Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
The label for the run action currently contains all of the arguments of a
script; change this to just show the base path of the script so we don't
pollute the log.

Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
If a script doesn't exist or the permissions are wrong, the recipe exits
during the recipe execution. Let's do some early checks in the Verify
stage to ensure the script exists on the host filesystem and a basic check
that the file has executable permission bit set. This check also follows
symlinks.

Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
Signed-off-by: Christopher Obbard <chris.obbard@collabora.com>
@obbardc obbardc force-pushed the wip/obbardc/fix-run-missing-mount branch from 8c6a800 to 5fe7313 Compare January 10, 2024 15:18
@obbardc obbardc added this to the v1.1.4 milestone Jan 10, 2024
@@ -120,7 +120,7 @@ func (run *RunAction) doRun(context debos.DebosContext) error {
}
cmdline = []string{run.scriptPath}
cmdline = append(cmdline, run.scriptArgs...)
label = path.Base(run.Script)
label = path.Base(run.scriptPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then you don't see the arguments to the script anymore, which is a loss.. Probably this doesn't belong in this PR (it doesn't help with your stated target i think) but preventing "pollution" we could do either by:

  • unify truncating the length like the Command handling does
  • printing what gets run first and then either not or only providing a minimal label on each line after

return err
}

if stat.IsDir() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather then checking if it's a Dir this should proably check if it's a regular file

}

/* Check the script is executable */
if stat.Mode()&0111 == 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

executable and readable ideally; though i don't think golang gives you nice helpers for that unfortunately :/

@@ -136,6 +136,8 @@ jobs:
test: { name: "arch", case: "arch" }
- backend: kvm
test: { name: "apertis", case: "apertis" }
- backend: kvm
test: { name: "run", case: "run" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kvm actually has the highest latency atm because of the runner setup; and really this should probably run on all types.. That said could you merge it with an existing tests so we don't need a new CI job for it ?

e.g. maybe merge it with the recipes test and the overlay test :)

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

Successfully merging this pull request may close these issues.

None yet

2 participants