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

Knife license comands and bootstrap updates #14559

Closed
wants to merge 21 commits into from

Conversation

ashiqueps
Copy link
Collaborator

Description

Added the following commands:

  • knife license
  • knife license list
  • knife license add

Bootstrap updates:

  • If the user doesn't have a license, the chef infra download will fall back to the old Omnitruck API and the user will get a warning after the bootstrap.
  • If the user has a valid license, the new Omnitruck APIs will be used to download the chef infra client.

Related Issue

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (non-breaking change that does not add functionality or fix an issue)

Checklist:

  • I have read the CONTRIBUTING document.
  • I have run the pre-merge tests locally and they pass.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • If Gemfile.lock has changed, I have used --conservative to do it and included the full output in the Description above.
  • All new and existing tests passed.
  • All commits have been signed-off for the Developer Certificate of Origin.

@ashiqueps ashiqueps requested review from a team as code owners August 13, 2024 08:37
@tpowell-progress
Copy link
Contributor

@ashiqueps Please fix lint and rebase on main to validate tests are passing.

@tpowell-progress tpowell-progress added the Status: Waiting on Contributor A pull request that has unresolved requested actions from the author. label Sep 3, 2024
@ashiqueps ashiqueps force-pushed the ashiqueps/license-bootstrap-only branch from 2eae3ec to fb71ac0 Compare September 5, 2024 09:39
Copy link
Contributor

@tpowell-progress tpowell-progress left a comment

Choose a reason for hiding this comment

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

Suggestions for more idiomatic Ruby, curiosity around the entitlement id, and more broadly: Should there be tests around the new commands for any potential failure modes?

@tpowell-progress tpowell-progress added Status: Waiting for Build Fix and removed Status: Waiting on Contributor A pull request that has unresolved requested actions from the author. labels Sep 19, 2024
@@ -0,0 1,776 @@
#!/bin/sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Upon discussion, this seems to be a duplication of https://github.com/chef/mixlib-install/blob/main/lib/mixlib/install/generator/bourne/scripts/helpers.sh.erb ? Why aren't we using mixlib-install? We should just modify mixlib-install that allows for an optional parameter to add any necessary functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

(If there are necessary breaking changes or high risk changes, we should bump version major or similar semantic communication)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hi @tpowell-progress,

When we started working on these changes, the install.sh endpoint was unavailable on the new download APIs. The architects suggested having a local copy of that file on the knife repo as a temporary solution.

Recently, the licensing team has added those endpoints and we thought of implementing it with the workstation licensing changes, But I've updated the code to use the new APIS.

To your second point, this is not a breaking or high-risk change. This will show a warning to the user to remind the necessity of getting a license and activating it, or otherwise, with Infra 19, things will not work as it is.

Please review and let me know your thoughts.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ashiqueps Ok, so I see that mixlib/install is not included in chef. Looks like it might be a little more work than the quick and dirty solution here @jaymzh

Copy link
Contributor

Choose a reason for hiding this comment

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

@ashiqueps looking at mixlic-install https://github.com/chef/mixlib-install/blob/main/lib/mixlib/install/generator/bourne.rb#L24 it looks like you can invoke one of the class methods or subclass/add a class method to generate what you want. This would save on duplication and prevent drift between the different scenarios.

Copy link
Contributor

@tpowell-progress tpowell-progress left a comment

Choose a reason for hiding this comment

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

Try adding mixlib-install and invoking the Mixlib::Install::Generator::Bourne.install_sh or similar method (or create your own that calls get_script("helpers.sh", context) to generate the helpers you need.

@ashiqueps
Copy link
Collaborator Author

Hey @tpowell-progress,

I've completely removed the install.sh script that was copied to the repo. Now it is being downloaded from the new download APIs based on the license type(https://chefdownload-trial.chef.io/install.sh in case of trial license). All the cases are handled in the latest download APIs.

I hope you requested this change because of the rewrite of the download script. Since that is handled now, I hope this will be fine. Please correct me if I am wrong.

@Stromweld
Copy link
Contributor

can you rebase on main to fix the vm tests?

if test -f /usr/bin/<%= ChefUtils::Dist::Infra::CLIENT %>; then
echo "-----> Existing <%= ChefUtils::Dist::Infra::PRODUCT %> installation detected"
else
echo "-----> Installing Chef Omnibus (<%= @config[:channel] %>/<%= version_to_install %>)"
do_download ${install_sh} $tmp_dir/install.sh
sh $tmp_dir/install.sh -P <%= @config[:bootstrap_product] %> -c <%= @config[:channel] %> -v <%= version_to_install %>
bash $tmp_dir/install.sh -P <%= @config[:bootstrap_product] %> -c <%= @config[:channel] %> -v <%= version_to_install %>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend leaving this as sh command as not all OS's like macos and freebsd default to or have bash shell installed.

Suggested change
bash $tmp_dir/install.sh -P <%= @config[:bootstrap_product] %> -c <%= @config[:channel] %> -v <%= version_to_install %>
sh $tmp_dir/install.sh -P <%= @config[:bootstrap_product] %> -c <%= @config[:channel] %> -v <%= version_to_install %>

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There is a bug in the new install.sh script which is preventing us from using the sh shell. I've created a ticket to address this, but I am not sure when they are going to pick it up. https://progresssoftware.atlassian.net/browse/CHEF-16349

Signed-off-by: Ashique Saidalavi <[email protected]>
Signed-off-by: Ashique Saidalavi <[email protected]>
Signed-off-by: Ashique Saidalavi <[email protected]>
Signed-off-by: Ashique Saidalavi <[email protected]>
Signed-off-by: Ashique Saidalavi <[email protected]>
Signed-off-by: Ashique Saidalavi <[email protected]>
Signed-off-by: Ashique Saidalavi <[email protected]>
Signed-off-by: Ashique Saidalavi <[email protected]>
Signed-off-by: Ashique Saidalavi <[email protected]>
@ashiqueps ashiqueps force-pushed the ashiqueps/license-bootstrap-only branch from ea75856 to 9f883a3 Compare October 8, 2024 08:18
Copy link
Collaborator

@jaymzh jaymzh left a comment

Choose a reason for hiding this comment

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

This seems way way way better, thanks for the cleanup!

Can you address Corey's feedback though?

Signed-off-by: Ashique Saidalavi <[email protected]>
Copy link

sonarcloud bot commented Oct 16, 2024

@ashiqueps
Copy link
Collaborator Author

Hey @tpowell-progress, @Stromweld , @jaymzh,

I've addressed all the comments. Could you please review this again?

@ashiqueps ashiqueps changed the base branch from main to chef-18 October 24, 2024 13:15
@ashiqueps ashiqueps requested a review from a team as a code owner October 24, 2024 13:15
@ashiqueps ashiqueps changed the base branch from chef-18 to main October 24, 2024 13:15
@ashiqueps
Copy link
Collaborator Author

Created #14669 to the chef-18 branch since these changes need to be released on the next Chef Infra 18 release. Closing this PR.

@ashiqueps ashiqueps closed this Oct 24, 2024
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