Skip to content

Conversation

camilamacedo86
Copy link
Contributor

@camilamacedo86 camilamacedo86 commented May 28, 2025

Checks if given paths exist and point to executable files or valid symlinks.
See that the execution of the new tests added can be checked via the CI job.

P.S.: Tested with previous releases as well. All worked fine.

/cherrypick release-4.19 release-4.18 release-4.17

@openshift-ci openshift-ci bot requested review from anik120 and tmshort May 28, 2025 17:36
@camilamacedo86 camilamacedo86 changed the title feat: add check for executable files in filesystem OPRUN-3869: feat: add check for executable files in filesystem May 28, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented May 28, 2025

@camilamacedo86: This pull request references OPRUN-3869 which is a valid jira issue.

In response to this:

Checks if given paths exist and point to executable files or valid symlinks.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 28, 2025
@camilamacedo86
Copy link
Contributor Author

c/c @joelanford wdyt?

@camilamacedo86 camilamacedo86 changed the title OPRUN-3869: feat: add check for executable files in filesystem OPRUN-3869: [Default Catalog Consistency Test]feat: add check for executable files in filesystem May 28, 2025
@camilamacedo86 camilamacedo86 changed the title OPRUN-3869: [Default Catalog Consistency Test]feat: add check for executable files in filesystem OPRUN-3869: [Default Catalog Consistency Test] (feat) add check for executable files in filesystem May 28, 2025
@camilamacedo86 camilamacedo86 changed the title OPRUN-3869: [Default Catalog Consistency Test] (feat) add check for executable files in filesystem OCPBUGS-56818, OPRUN-3869: [Default Catalog Consistency Test] (feat) add check for executable files in filesystem May 28, 2025
@openshift-ci-robot
Copy link

@camilamacedo86: An error was encountered updating to the POST state for bug OCPBUGS-56818 on the Jira server at https://issues.redhat.com/. No known errors were detected, please see the full error message for details.

Full error message. No response returned: Post "https://issues.redhat.com/rest/api/2/issue/17015461/transitions": POST https://issues.redhat.com/rest/api/2/issue/17015461/transitions giving up after 5 attempt(s)

Please contact an administrator to resolve this issue, then request a bug refresh with /jira refresh.

In response to this:

Checks if given paths exist and point to executable files or valid symlinks.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@camilamacedo86
Copy link
Contributor Author

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels May 28, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented May 28, 2025

@camilamacedo86: This pull request references Jira Issue OCPBUGS-56818, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.20.0) matches configured target version for branch (4.20.0)
  • bug is in the state New, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (bandrade@redhat.com), skipping review request.

The bug has been updated to refer to the pull request using the external bug tracker.

This pull request references OPRUN-3869 which is a valid jira issue.

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented May 28, 2025

@camilamacedo86: This pull request references Jira Issue OCPBUGS-56818, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.20.0) matches configured target version for branch (4.20.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (bandrade@redhat.com), skipping review request.

This pull request references OPRUN-3869 which is a valid jira issue.

In response to this:

Checks if given paths exist and point to executable files or valid symlinks.

/cherrypick release-4.19 release-4.18 release-4.17

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented May 28, 2025

@camilamacedo86: This pull request references Jira Issue OCPBUGS-56818, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.20.0) matches configured target version for branch (4.20.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (bandrade@redhat.com), skipping review request.

This pull request references OPRUN-3869 which is a valid jira issue.

In response to this:

Checks if given paths exist and point to executable files or valid symlinks.
See that the execution of the new tests added can be checked via the CI job:

https://prow.ci.openshift.org/view/gs/test-platform-results/pr-logs/pull/openshift_operator-framework-operator-controller/362/pull-ci-openshift-operator-framework-operator-controller-main-default-catalog-consistency/1927784226749419520

/cherrypick release-4.19 release-4.18 release-4.17

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@camilamacedo86 camilamacedo86 force-pushed the opm-path branch 2 times, most recently from 003f374 to 9cfb5dc Compare May 29, 2025 02:11
// We use the `os` package instead of fs.FS because fs.FS does not support Lstat or Readlink,
// which are needed to detect and resolve symlinks correctly.
// Therefore, we are looking to real file paths under the unpacked image (in tmpDir/fs).
Fn: func(_ context.Context, _ fs.FS, tmpDir string) error {
Copy link
Contributor Author

@camilamacedo86 camilamacedo86 May 29, 2025

Choose a reason for hiding this comment

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

@joelanford @bentito ^ see I hope that clarifies your previous comment.
The Go fs.FS doesn't support checking or following symlinks.

For all images we create a symlink for the opm.
I clarified it in the doc of the func as well.

Since we're working with a real unpacked image on disk, using `os.* functions' brings the correct result, I mean, do the check properly. As far as I see, we're not breaking any abstraction — we’re checking the actual filesystem, which includes symlinks.

See when we pass an invalid path.

 <check.Error>{
                  CheckName: "[FS]:FilesystemHasValidPathsOrLinks:([\"bin/invalid\" \"bin/registry/opm\"])",
                  Err: <*errors.joinError | 0x1400106b350>{
                      errs: [
                          <*fmt.wrapError | 0x14000452680>{
                              msg: "error stating \"bin/invalid\": lstat /var/folders/n4/j272tr6d7hq63mf7_skv6zr80000gn/T/oci-redhat-marketplace-index-353931148/fs/bin/invalid: no such file or directory",
                              err: <*fs.PathError | 0x140006f8cc0>{
                                  Op: "lstat",
                                  Path: "/var/folders/n4/j272tr6d7hq63mf7_skv6zr80000gn/T/oci-redhat-marketplace-index-353931148/fs/bin/invalid",
                                  Err: <syscall.Errno>0x2,
                              },
                          },
                      ],
                  },
              },
          ],

So, I think that is the best that we can do to verify this one

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe it would be clearer to just not take the abstract FS as a parameter?

Copy link
Contributor Author

@camilamacedo86 camilamacedo86 May 29, 2025

Choose a reason for hiding this comment

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

maybe it would be clearer to just not take the abstract FS as a parameter?

We need to keep the fs.FS parameter because this function follows a shared interface used by all the filesystem checks. This one doesn’t use it, but the others do — so we keep it for consistency.


if _, err := os.Stat(resolved); err != nil {
errs = append(errs, fmt.Errorf("symlink %q points to missing target %q: %w", rel, resolved, err))
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joelanford @bentito

Sadly, my fist try to check if is an executable did not work out:

$ ls -la /var/folders/n4/j272tr6d7hq63mf7_skv6zr80000gn/T/oci-community-operator-index-2618243349/fs/bin/registry/opm
-rw-------  1 camilam  staff  91558832 20 May 10:30 /var/folders/n4/j272tr6d7hq63mf7_skv6zr80000gn/T/oci-community-operator-index-2618243349/fs/bin/registry/opm

When we unpack the image we lose the permissions bits, see: https://github.com/openshift/operator-framework-operator-controller/blob/main/openshift/default-catalog-consistency/pkg/extract/extract.go#L181-L185

@camilamacedo86 camilamacedo86 requested a review from joelanford May 29, 2025 09:21
@openshift-ci-robot
Copy link

openshift-ci-robot commented May 29, 2025

@camilamacedo86: This pull request references Jira Issue OCPBUGS-56818, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.20.0) matches configured target version for branch (4.20.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

No GitHub users were found matching the public email listed for the QA contact in Jira (bandrade@redhat.com), skipping review request.

This pull request references OPRUN-3869 which is a valid jira issue.

In response to this:

Checks if given paths exist and point to executable files or valid symlinks.
See that the execution of the new tests added can be checked via the CI job.

P.S.: Tested with previous releases as well. All worked fine.

/cherrypick release-4.19 release-4.18 release-4.17

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@camilamacedo86 camilamacedo86 changed the title OCPBUGS-56818, OPRUN-3869: [Default Catalog Consistency Test] (feat) add check for executable files in filesystem OCPBUGS-56818, OPRUN-3869: [Default Catalog Consistency Test] (feat) add check for bin/opm files in filesystem May 30, 2025
// FilesystemHasValidPathsOrLinks checks that the given paths exist inside the extracted image filesystem.
// It supports regular files and symlinks:
// - If it's a regular file, we just check that it exists.
// - If it's a symlink, we check that the link target exists.
Copy link
Contributor

Choose a reason for hiding this comment

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

do we care if it points to a particular target or not? or only whether it exists?

Copy link
Contributor

Choose a reason for hiding this comment

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

at the same time, this feels a bit like testing implementation - should we rather just do something like execute opm --version and grep for some string (or something like that). I.e. it shouldn't really matter if its a symlink or not, just that it can be executed and that its opm...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do we care if it points to a particular target or not? or only whether it exists?

I know this isn’t a bulletproof check,
but if the image was built without the binary (using opm in binless mode), we won’t have the symlink at all — so this will catch that.

If the symlink exists but is broken (e.g., points to a non-existent target), we’ll also catch that here.
But it doesn’t go beyond that.

Still, it does reliably cover 100% of the cases where the pipeline uses the option that skips adding the binary with is what ofen would endup in the scenario that we want to avoid right?

at the same time, this feels a bit like testing implementation - should we rather just do something like execute opm --version and grep for some string (or something like that). I.e. it shouldn't really matter if its a symlink or not, just that it can be executed and that its opm...?

Yep, I started looking into options like that.
But on macOS, if we call bin/opm, it’s not built for darwin/arm64, so it won’t work at all.

That adds a lot of complexity for anyone on macOS trying to contribute — so it’s worth asking: is the value really worth the pain? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe doing something like: go version -m bin/opm ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 👍

…k for executable files in filesystem

Checks if given paths exist and point to executable files or valid symlinks.
hdr.Gid = os.Getgid()
if hdr.FileInfo().IsDir() {
hdr.Mode = 0700
hdr.Mode = 0755
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe just:

hdr.Mode = 0755

now that we're assigning the same mode for files and dirs?

@perdasilva
Copy link
Contributor

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 2, 2025
@camilamacedo86 camilamacedo86 requested a review from perdasilva June 2, 2025 16:38
@perdasilva
Copy link
Contributor

/approve

Copy link
Contributor

openshift-ci bot commented Jun 3, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86, perdasilva

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 3, 2025
Copy link
Contributor

openshift-ci bot commented Jun 3, 2025

@camilamacedo86: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 524ecb6 into openshift:main Jun 3, 2025
11 checks passed
@openshift-ci-robot
Copy link

@camilamacedo86: Jira Issue OCPBUGS-56818: All pull requests linked via external trackers have merged:

Jira Issue OCPBUGS-56818 has been moved to the MODIFIED state.

In response to this:

Checks if given paths exist and point to executable files or valid symlinks.
See that the execution of the new tests added can be checked via the CI job.

P.S.: Tested with previous releases as well. All worked fine.

/cherrypick release-4.19 release-4.18 release-4.17

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-cherrypick-robot

@camilamacedo86: new pull request created: #368

In response to this:

Checks if given paths exist and point to executable files or valid symlinks.
See that the execution of the new tests added can be checked via the CI job.

P.S.: Tested with previous releases as well. All worked fine.

/cherrypick release-4.19 release-4.18 release-4.17

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-bot
Copy link

[ART PR BUILD NOTIFIER]

Distgit: ose-olm-catalogd
This PR has been included in build ose-olm-catalogd-container-v4.20.0-202506031316.p0.g524ecb6.assembly.stream.el9.
All builds following this will include this PR.

@openshift-bot
Copy link

[ART PR BUILD NOTIFIER]

Distgit: ose-olm-operator-controller
This PR has been included in build ose-olm-operator-controller-container-v4.20.0-202506031316.p0.g524ecb6.assembly.stream.el9.
All builds following this will include this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/severity-important Referenced Jira bug's severity is important for the branch this PR is targeting. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants