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

NETOBSERV-2019: Make sure the required yq version is installed #140

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

msherif1234
Copy link
Contributor

@msherif1234 msherif1234 commented Dec 16, 2024

Description

make sure the required YQ is available for the cli scripts to work

Dependencies

n/a

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
    • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
    • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
    • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
    • Standard QE validation, with pre-merge tests unless stated otherwise.
    • Regression tests only (e.g. refactoring with no user-facing change).
    • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Dec 16, 2024

@msherif1234: This pull request references NETOBSERV-2019 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.19.0" version, but no target version was set.

In response to this:

Description

make sure the required YQ is available for the cli scripts to work

Dependencies

n/a

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
  • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
  • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
  • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

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.

@msherif1234 msherif1234 force-pushed the use_specific_yq branch 2 times, most recently from 41ed464 to d991299 Compare December 16, 2024 22:10
@msherif1234
Copy link
Contributor Author

/ok-to-test

Copy link

New image:
quay.io/netobserv/network-observability-cli:24e73b9

It will expire after two weeks.

To use this build, update your commands using:

USER=netobserv VERSION=24e73b9 make commands

or download the updated commands.

Copy link

codecov bot commented Dec 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 22.66%. Comparing base (d541d19) to head (c32649e).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #140   +/-   ##
=======================================
  Coverage   22.66%   22.66%           
=======================================
  Files          10       10           
  Lines        1337     1337           
=======================================
  Hits          303      303           
  Misses       1015     1015           
  Partials       19       19           
Flag Coverage Δ
unittests 22.66% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@msherif1234
Copy link
Contributor Author

to test this running locally
1- I install older version of yq
GOFLAGS="" go install github.com/mikefarah/yq/[email protected]
2- run the binary build by this PR
./test_commands packets --log-level=trace --protocol=TCP --port=6443

Installing yq version v4.43.1 is required. Found v4.40.3.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 9716k  100 9716k    0     0  13.7M      0 --:--:-- --:--:-- --:--:-- 23.1M
Successfully downloaded yq version v4.43.1.
Setting up... 
Error from server (NotFound): the server could not find the requested resource (get users.user.openshift.io ~)
creating netobserv-cli namespace
namespace/netobserv-cli created
creating service account
serviceaccount/netobserv-cli created
clusterrole.rbac.authorization.k8s.io/netobserv-cli unchanged
clusterrolebinding.rbac.authorization.k8s.io/netobserv-cli unchanged
creating collector service
service/collector created
creating packet-capture agents
opt: log_level, evalue: trace
opt: filter_protocol, evalue: TCP
opt: filter_port, evalue: 6443
daemonset.apps/netobserv-cli created
Waiting for daemon set "netobserv-cli" rollout to finish: 0 of 2 updated pods are available...
^CRunning network-observability-cli get-packets... 
pod/collector created
pod/collector condition met
Starting network-observability-cli:
=====
Build version: main-24e73b9
Build date: 2024-12-16 22:18

commands/netobserv Outdated Show resolved Hide resolved
commands/netobserv Outdated Show resolved Hide resolved
commands/netobserv Outdated Show resolved Hide resolved
@jpinsonneau jpinsonneau mentioned this pull request Dec 17, 2024
10 tasks
@msherif1234 msherif1234 force-pushed the use_specific_yq branch 2 times, most recently from 9f5f1ac to f4fcc21 Compare December 17, 2024 13:44
@msherif1234
Copy link
Contributor Author

/ok-to-test

Copy link

New image:
quay.io/netobserv/network-observability-cli:c18479c

It will expire after two weeks.

To use this build, update your commands using:

USER=netobserv VERSION=c18479c make commands

or download the updated commands.

@@ -0,0 +1,65 @@
#!/usr/bin/env bash

set -e
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
set -e

YQ_BIN=$(which yq 2>/dev/null)
if [ -z "$YQ_BIN" ]; then
echo "Error: 'yq' is not installed or not in PATH."
install_yq
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
install_yq
install_yq "$2"

for arch in $supported_archs; do
echo "Attempting to download yq version $required_yq_version for $OS/$arch..."
DOWNLOAD_URL="https://github.com/mikefarah/yq/releases/download/$required_yq_version/yq_${OS}_${arch}"
if ! curl -Lo "$YQ_BIN" "$DOWNLOAD_URL" && chmod +x "$YQ_BIN"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ! curl -Lo "$YQ_BIN" "$DOWNLOAD_URL" && chmod +x "$YQ_BIN"
if curl -Lo "$YQ_BIN" "$DOWNLOAD_URL" && chmod +x "$YQ_BIN"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ugh was trying to fix linter and I broke it :(

function install_yq() {
OS=$(uname | tr '[:upper:]' '[:lower:]') # Get the OS type (linux or darwin)
supported_archs="$1"
YQ_BIN="./yq"
Copy link
Contributor

Choose a reason for hiding this comment

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

That's a bit dirty 🤔

Is there a way to put it in /tmp folder for all envs ?
Or maybe alongside oc-netobserv command but renamming yq to something else

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, each time the script runs, it redownload the yq binary. We need to check if that path exists at the top of this script and use it if available prior to the one returned by which yq

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put it in /tmp

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Dec 18, 2024

@msherif1234: This pull request references NETOBSERV-2019 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.19.0" version, but no target version was set.

In response to this:

Description

make sure the required YQ is available for the cli scripts to work

Dependencies

n/a

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
  • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
  • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
  • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

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.

@jpinsonneau
Copy link
Contributor

Took the opportunity to improve the display e2e41ca

Everything is working fine 👌 thanks @msherif1234 !

@msherif1234
Copy link
Contributor Author

@memodi will give this a try ?
/ok-to-test

Copy link

New image:
quay.io/netobserv/network-observability-cli:e7139e2

It will expire after two weeks.

To use this build, update your commands using:

USER=netobserv VERSION=e7139e2 make commands

or download the updated commands.

@memodi
Copy link

memodi commented Dec 18, 2024

sure @msherif1234 , I upgraded my yq since , let me see if I can downgrade and give it a try, cc @Amoghrd you may want to try as well.

Copy link

@memodi memodi left a comment

Choose a reason for hiding this comment

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

tested, it works! thanks @msherif1234

@@ -72,7 +72,11 @@ function packets() {
esac
}

case "$1" in
required_yq_version="v0.0.0"
Copy link

Choose a reason for hiding this comment

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

@msherif1234 - qq , where do you set the required version here?

Copy link
Contributor Author

@msherif1234 msherif1234 Dec 18, 2024

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

ah, I see it, the YQ_VERSION env var value already exists in main.

@Amoghrd
Copy link

Amoghrd commented Dec 18, 2024

/label qe-approved
Works as expected!

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Dec 18, 2024

@msherif1234: This pull request references NETOBSERV-2019 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.19.0" version, but no target version was set.

In response to this:

Description

make sure the required YQ is available for the cli scripts to work

Dependencies

n/a

Checklist

If you are not familiar with our processes or don't know what to answer in the list below, let us know in a comment: the maintainers will take care of that.

  • Is this PR backed with a JIRA ticket? If so, make sure it is written as a title prefix (in general, PRs affecting the NetObserv/Network Observability product should be backed with a JIRA ticket - especially if they bring user facing changes).
  • Does this PR require product documentation?
  • If so, make sure the JIRA epic is labelled with "documentation" and provides a description relevant for doc writers, such as use cases or scenarios. Any required step to activate or configure the feature should be documented there, such as new CRD knobs.
  • Does this PR require a product release notes entry?
  • If so, fill in "Release Note Text" in the JIRA.
  • Is there anything else the QE team should know before testing? E.g: configuration changes, environment setup, etc.
  • If so, make sure it is described in the JIRA ticket.
  • QE requirements (check 1 from the list):
  • Standard QE validation, with pre-merge tests unless stated otherwise.
  • Regression tests only (e.g. refactoring with no user-facing change).
  • No QE (e.g. trivial change with high reviewer's confidence, or per agreement with the QE team).

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.

@msherif1234
Copy link
Contributor Author

/approve

Copy link

openshift-ci bot commented Dec 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: msherif1234

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

@msherif1234 msherif1234 merged commit 082d6f3 into netobserv:main Dec 18, 2024
10 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants