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

Chef 11677/chef 12498/lbaker erlang upgrade #3877

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .expeditor/automate_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export HAB_STUDIO_SECRET_HAB_FEAT_IGNORE_LOCAL=false
export HAB_FEAT_IGNORE_LOCAL=false
export HAB_STUDIO_HOST_ARCH=x86_64-linux
export HAB_FEAT_OFFLINE_INSTALL=true
export HAB_BLDR_CHANNEL: "LTS-2024"
export HAB_STUDIO_SECRET_HAB_FALLBACK_CHANNEL: "LTS-2024"
export HAB_FALLBACK_CHANNEL: "LTS-2024"

curl https://raw.githubusercontent.com/habitat-sh/habitat/main/components/hab/install.sh | sudo bash

Expand Down
13 changes: 13 additions & 0 deletions .expeditor/build.habitat.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
---
env:
HAB_BLDR_CHANNEL: "LTS-2024"
HAB_STUDIO_SECRET_HAB_FALLBACK_CHANNEL: "LTS-2024"
HAB_FALLBACK_CHANNEL: "LTS-2024"

origin: chef
smart_build: false
studio_secrets:
HAB_BLDR_CHANNEL:
value: "LTS-2024"
HAB_STUDIO_SECRET_HAB_FALLBACK_CHANNEL:
value: "LTS-2024"
HAB_FALLBACK_CHANNEL:
value: "LTS-2024"


1 change: 1 addition & 0 deletions .expeditor/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,4 @@ artifact_channels:
- unstable
- current
- stable
- LTS-2024
2 changes: 1 addition & 1 deletion .expeditor/create_manifest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_latest(channel, origin, name)
def get_hab_deps_latest()
ret = {}
["hab", "hab-sup", "hab-launcher"].each do |name|
d = get_latest("stable", "core", name)
d = get_latest("LTS-2024", "core", name)
ret[name] = "#{d["origin"]}/#{d["name"]}/#{d["version"]}/#{d["release"]}"
end
ret
Expand Down
2 changes: 1 addition & 1 deletion .license_scout.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ habitat:
- origin: chef
channel: unstable
- origin: core
channel: stable
channel: LTS-2024

allowed_licenses:
- Apache-1.0
Expand Down
2 changes: 1 addition & 1 deletion oc-chef-pedant/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

# If you want to load debugging tools into the bundle exec sandbox,
# # add these additional dependencies into Gemfile.local
eval(IO.read(__FILE__ + '.local'), binding) if File.exists?(__FILE__ + '.local')
eval(IO.read(__FILE__ + '.local'), binding) if File.exist?(__FILE__ + '.local')

Check failure

Code scanning / CodeQL

Use of `Kernel.open` or `IO.read` or similar sinks with a non-constant value Critical

Call to IO.read with a non-constant value. Consider replacing it with File.read.

Copilot Autofix AI 2 days ago

To fix the problem, we need to replace the usage of IO.read with File.read. This change will ensure that the file is read without the risk of executing arbitrary shell commands. The functionality of the code will remain the same, as File.read and IO.read both read the contents of a file.

The specific change required is in the oc-chef-pedant/Gemfile file, where we need to replace IO.read(__FILE__ + '.local') with File.read(__FILE__ + '.local').

Suggested changeset 1
oc-chef-pedant/Gemfile

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/oc-chef-pedant/Gemfile b/oc-chef-pedant/Gemfile
--- a/oc-chef-pedant/Gemfile
+++ b/oc-chef-pedant/Gemfile
@@ -19,3 +19,3 @@
 # # add these additional dependencies into Gemfile.local
-eval(IO.read(__FILE__ + '.local'), binding) if File.exist?(__FILE__ + '.local')
+eval(File.read(__FILE__ + '.local'), binding) if File.exist?(__FILE__ + '.local')
 
EOF
@@ -19,3 +19,3 @@
# # add these additional dependencies into Gemfile.local
eval(IO.read(__FILE__ + '.local'), binding) if File.exist?(__FILE__ + '.local')
eval(File.read(__FILE__ + '.local'), binding) if File.exist?(__FILE__ + '.local')

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options

instance_eval(ENV['GEMFILE_MOD']) if ENV['GEMFILE_MOD']
24 changes: 13 additions & 11 deletions oc-chef-pedant/spec/api/stats_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,18 @@
"pg_stat_seq_scan" => "COUNTER",
}

MNESIA_RESPONSE_TYPE_MAP = {
"erlang_mnesia_held_locks" => "GAUGE",
"erlang_mnesia_lock_queue" => "GAUGE",
"erlang_mnesia_transaction_participants" => "GAUGE",
"erlang_mnesia_transaction_coordinators" => "GAUGE",
"erlang_mnesia_failed_transactions" => "COUNTER",
"erlang_mnesia_committed_transactions" => "GAUGE",
"erlang_mnesia_logged_transactions" => "COUNTER",
"erlang_mnesia_restarted_transactions" => "COUNTER"
}
# pedant test failures here after upgrading to erlang 26x
#
#MNESIA_RESPONSE_TYPE_MAP = {
# "erlang_mnesia_held_locks" => "GAUGE",
# "erlang_mnesia_lock_queue" => "GAUGE",
# "erlang_mnesia_transaction_participants" => "GAUGE",
# "erlang_mnesia_transaction_coordinators" => "GAUGE",
# "erlang_mnesia_failed_transactions" => "COUNTER",
# "erlang_mnesia_committed_transactions" => "GAUGE",
# "erlang_mnesia_logged_transactions" => "COUNTER",
# "erlang_mnesia_restarted_transactions" => "COUNTER"
#}

CHEF_INDEX_TYPE_MAP_ES = {
"chef_elasticsearch_update_count" => "COUNTER",
Expand Down Expand Up @@ -168,7 +170,7 @@

SHARED_TYPE_MAP = ERLANG_RESPONSE_TYPE_MAP.merge(CHEF_INDEX_TYPE_MAP)
RESPONSE_TYPE_MAP = SHARED_TYPE_MAP.merge(CHEF_INDEX_JSON_TYPE_MAP)
PROMETHEUS_RESPONSE_TYPE_MAP = SHARED_TYPE_MAP.merge(MNESIA_RESPONSE_TYPE_MAP).merge(CHEF_INDEX_PROMETHEUS_TYPE_MAP)
PROMETHEUS_RESPONSE_TYPE_MAP = SHARED_TYPE_MAP.merge(CHEF_INDEX_PROMETHEUS_TYPE_MAP)

if Pedant::Config.chef_pgsql_collector
RESPONSE_TYPE_MAP = RESPONSE_TYPE_MAP.merge(PGSTATS_RESPONSE_TYPE_MAP)
Expand Down
95 changes: 95 additions & 0 deletions omnibus/config/software/sqitch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#
# Copyright 2014 Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

name "sqitch"
default_version "1.4.1"

skip_transitive_dependency_licensing true

license "MIT"
license_file "https://raw.githubusercontent.com/theory/sqitch/master/README.md"

dependency "perl"
dependency "cpanminus"

# install a LGPL-licensed version of libintl-perl:
dependency "libintl-perl"

# version_list: url=https://github.com/theory/#{name}/releases/download/v#{version}/ filter=app-sqitch-*.tar.gz
version("1.4.1") { source sha256: "caf31cc8f772e3a4c9d4b3ff3a8f684a6eb5b1b3c261f4ddc0f90a88c36007c6" }
version("1.4.0") { source sha256: "b0db387031f77562662e003bc55d7a102a26380b4ad7fdb9a8a3bad5769e501c" }
version("1.3.1") { source sha256: "f5e768d298cd4047ee2ae42319782e8c2cda312737bcbdbfaf580bd47efe8b94" }
version("1.3.0") { source sha256: "7d07635ec77a7faf3c50281c76ec833c68702f14470996cb2203a8bc6abc5bf2" }
version("1.2.1") { source sha256: "020835a13429effd8fda12d5627604ecf99293775918f4f8ba9ccc5ed796e5e7" }
version("1.1.0") { source sha256: "ee146cd75d6300837e6ca559bb0bde247d42123c96b2c5d4b2800f38d3e3d1ab" }
version("0.9999") { source sha256: "f5bfa80206738ab8a70358a3b0557661c7459e11ec07dece23ecafa1f34372b3" }
version("0.973") { source sha256: "95fc7f18fff786c5d2579133e2e3ac56779e54bb3a06a1af1117054e9f49ab32" }

if version >= "1.1.0"
source url: "https://github.com/theory/#{name}/releases/download/v#{version}/app-sqitch-v#{version}.tar.gz"
internal_source url: "#{ENV["ARTIFACTORY_REPO_URL"]}/#{name}/#{name}-#{version}.tar.gz",
authorization: "X-JFrog-Art-Api:#{ENV["ARTIFACTORY_TOKEN"]}"
relative_path "App-Sqitch-v#{version}"
else
source url: "https://github.com/theory/#{name}/releases/download/v#{version}/app-sqitch-#{version}.tar.gz"
internal_source url: "#{ENV["ARTIFACTORY_REPO_URL"]}/#{name}/#{name}-#{version}.tar.gz",
authorization: "X-JFrog-Art-Api:#{ENV["ARTIFACTORY_TOKEN"]}"
relative_path "App-Sqitch-#{version}"
end

# See https://github.com/theory/sqitch for more
build do
env = with_standard_compiler_flags(with_embedded_path)
# Lists-MoreUtils-XS does not build on RHEL 5 or SUSE 11 currently.
# This option is used by the Lists-MoreUtils build configuration to
# decide whether to use the -XS package or a pure perl
# implementation.
env["PERL_MM_OPT"] = "PUREPERL_ONLY=1"
command "perl Build.PL", env: env
command "./Build installdeps --cpan_client 'cpanm -v --notest'", env: env
command "./Build", env: env
command "./Build install", env: env

# Here is another licensing fun. Some of the dependencies of sqitch
# unfortunately have GPL3 and LGPL3 licenses which are requiring us to remove
# them from our packages after installing sqitch. Here we are uninstalling
# them without breaking the licensing information collection.
%w{Test-MockModule}.each do |package_name|
module_name = package_name.gsub("-", "::")

# Here we run cpanm --uninstall with a different PERL_CPANM_HOME. The reason
# for this is to keep the licensing information for sqitch intact. The way
# license_scout works is to look into PERL_CPANM_HOME/latest-build (by
# default ~/.cpanm/latest-build) which contains the modules installed during
# the last install. This directory is a symlink that points to the directory
# contains the information about the latest build. Without changing
# PERL_CPANM_HOME we would overwrite the link and will not be able to
# collect the dependencies installed to our package while doing the actual
# sqitch install.
Dir.mktmpdir do |tmpdir|
command "cpanm --force --uninstall #{module_name}", env: env.merge({
"PERL_CPANM_HOME" => tmpdir,
})
end

# Here we are removing the problematic package from the original
# PERL_CPANM_HOME cache directory. This ensures that we do not add
# licensing information about these components to our package.
cpanm_root = File.expand_path("~/.cpanm/latest-build")
delete "#{cpanm_root}/#{package_name}*"
end

end
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@
converge_by "Deploying schema from #{new_resource.name}" do
execute "sqitch_deploy_#{new_resource.name}" do
command <<-EOM.gsub(/\s+/, ' ').strip!
sqitch --engine pg
--db-name #{new_resource.database}
sqitch --db-name #{new_resource.database}
--db-host #{new_resource.hostname}
--db-port #{new_resource.port}
--db-user #{new_resource.username}
--top-dir #{new_resource.name}
--chdir #{new_resource.name}
deploy #{target} --verify
EOM
environment 'PERL5LIB' => "/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/embedded/lib", # force us to use omnibus perl
Expand Down
5 changes: 2 additions & 3 deletions omnibus/partybus/lib/partybus/migration_api/v1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ def run_command(command, options={})
def run_sqitch(target, service, opts = {})
options = default_opts_for_service(service).merge(opts)
command = <<-EOM.gsub(/\s+/," ").strip!
sqitch --engine pg
--db-name #{options[:database]}
sqitch --db-name #{options[:database]}
--db-host #{Partybus.config.postgres['vip']}
--db-port #{Partybus.config.postgres['port']}
--db-user #{options[:username]}
--top-dir /opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/embedded/service/#{options[:path]}
--chdir /opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/embedded/service/#{options[:path]}
deploy #{target} --verify
EOM
run_command(command, env: {"PGPASSWORD" => options[:password]})
Expand Down
4 changes: 2 additions & 2 deletions omnibus_overrides.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# When updating this, check doc/FrequentTasks.md for checklists to ensure all
# the various usages are updated in lockstep
#
override :erlang, version: "24.3.2"
override :erlang, version: "26.2.5.2"
override :'omnibus-ctl', version: "main"
override :chef, version: "v17.10.0"
override :ohai, version: "v16.17.0"
override :ruby, version: "3.0.1"
override :perl, version: "5.34.0"
override :redis, version: "5.0.14"
override :runit, version: "2.1.1" #standalone upgrade is failing, Needs to be reverted to 2.1.2 after fixing the umbrella
override :sqitch, version: "0.973"
# override :sqitch, version: "1.4.0"

override :logrotate, version: "3.19.0"

Expand Down
6 changes: 3 additions & 3 deletions scripts/bk_tests/bk_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ cp /workdir/scripts/bk_tests/pb_hba.conf /etc/postgresql/13/main/pg_hba.conf
# the erlang software definition lives in: /omnibus-software/config/software/erlang.rb

# this is needed until the erlang version is installed in the docker container
echo "Installing erlang 24.3.2"
asdf install erlang 24.3.2
asdf local erlang 24.3.2
echo "Installing erlang 26.2.5.2"
asdf install erlang 26.2.5.2
asdf local erlang 26.2.5.2
erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell

echo "Installing Bundler"
Expand Down
2 changes: 1 addition & 1 deletion scripts/bk_tests/chef_zero-Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ gem 'chef-zero', github: 'chef/chef-zero', tag: 'v15.0.11'

# If you want to load debugging tools into the bundle exec sandbox,
# # add these additional dependencies into Gemfile.local
eval(IO.read(__FILE__ + '.local'), binding) if File.exists?(__FILE__ + '.local')
eval(IO.read(__FILE__ + '.local'), binding) if File.exist?(__FILE__ + '.local')

instance_eval(ENV['GEMFILE_MOD']) if ENV['GEMFILE_MOD']
Binary file modified scripts/elvis
Binary file not shown.
4 changes: 2 additions & 2 deletions src/bookshelf/elvis.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
{elvis_style, no_if_expression},
{elvis_style, no_debug_call, #{ignore => [bksw_app]}},
{elvis_style, no_nested_try_catch},
{elvis_style, no_tabs},
{elvis_style, no_trailing_whitespace},
{elvis_text_style, no_tabs},
{elvis_text_style, no_trailing_whitespace},
{elvis_style, operator_spaces},
{elvis_style, used_ignored_variable},
{elvis_style, variable_naming_convention}
Expand Down
2 changes: 1 addition & 1 deletion src/bookshelf/habitat/config/database-migrations.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ createdb $PG_ARGS $DB "bookshelf"
psql $PG_ARGS --command 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp"' $DB

cd "{{pkg.path}}/schema" || exit
sqitch --quiet --engine pg deploy "db:pg://${USER}:${PASS}@${HOST}/$DB"
sqitch --quiet deploy "db:pg://${USER}:${PASS}@${HOST}/$DB"
5 changes: 3 additions & 2 deletions src/bookshelf/habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ pkg_origin=chef
pkg_license=('Apache-2.0')
pkg_maintainer="The Chef Server Maintainers <support@chef.io>"
pkg_deps=(
core/erlang24
core/erlang26
core/cacerts
core/coreutils
core/gcc-libs
core/sqitch_pg
core/sqitch
core/postgresql-client
)
pkg_build_deps=(core/make core/git core/gcc)
pkg_bin_dirs=(bin)
Expand Down
9 changes: 4 additions & 5 deletions src/bookshelf/rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 ft=erlang et

{require_otp_vsn, "24.3.2"}.
{require_otp_vsn, "26.2.5.2"}.

{erl_dep_retries, 10}.

Expand All @@ -16,10 +16,8 @@
{git, "https://github.com/chef/chef_secrets", {branch, "main"}}},
{envy, ".*",
{git, "https://github.com/markan/envy", {branch, "master"}}},
{eper, ".*",
{git, "https://github.com/massemanet/eper", {branch, "master"}}},
{erlcloud, ".*",
{git, "https://github.com/chef/erlcloud", {branch, "lbaker/presigned-headers"}}},
{git, "https://github.com/chef/erlcloud", {branch, "CHEF-11677/CHEF-12498/lbaker"}}},
{erlsom, ".*",
{git, "https://github.com/chef/erlsom", {branch, "integer_long_string_probs2"}}},
{erlware_commons, ".*",
Expand Down Expand Up @@ -56,6 +54,8 @@

{plugins, [pc]}.

{dialyzer, [{warnings, [no_unknown]}]}.

{xref_checks,
[undefined_function_calls,
undefined_functions,
Expand Down Expand Up @@ -132,7 +132,6 @@
{mixer, load},
syntax_tools,
compiler,
eper,
observer_cli,
{pooler, load},
{sqerl, load}
Expand Down
Loading
Loading