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

etcd: set ETCD_UNSUPPORTED_ARCH for Arm64, because while it builds on… #76995

Merged
merged 1 commit into from
May 11, 2021

Conversation

areese
Copy link
Contributor

@areese areese commented May 10, 2021

… Arm, it's not explicitly supported on m1 yet

  • Have you followed the guidelines for contributing?
  • Have you checked that there aren't other open pull requests for the same formula update/change?
  • Have you built your formula locally with brew install --build-from-source <formula>, where <formula> is the name of the formula you're submitting?
  • Is your test running fine brew test <formula>, where <formula> is the name of the formula you're submitting?
  • Does your build pass brew audit --strict <formula> (after doing brew install <formula>)?

etcd isn't officially supported on m1, so this sets the flag for it.
Not sure how you want to handle this.

The upstream issue seems to be: etcd-io/etcd#10318

@BrewTestBot BrewTestBot added go Go use is a significant feature of the PR or issue no ARM bottle Formula has no ARM bottle labels May 10, 2021
Copy link
Member

@carlocab carlocab left a comment

Choose a reason for hiding this comment

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

Why do we need to set ETCD_UNSUPPORTED_ARCH?

Formula/etcd.rb Outdated
@@ -42,6 +59,7 @@ def plist
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
#{plist_unsupported_platformenv}
Copy link
Member

@carlocab carlocab May 10, 2021

Choose a reason for hiding this comment

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

Doesn't this break the plist, since the array [*] below is now a value with no key?

[*] This one:

<array>
  <string>#{opt_bin}/etcd</string>
</array>

I think this also sets the environment variable for an entirely separate process, which is probably not what we want here.

The correct entry to add to the plist is probably (from man launchd.plist):

     EnvironmentVariables <dictionary of strings>
     This optional key is used to specify additional environmental variables to be set before running the job. Each
     key in the dictionary is the name of an environment variable, with the corresponding value being a string repre-
     senting the desired value.  NOTE: Values other than strings will be ignored.

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 I might have broken the plist.
Lemme see if I can figure that out.

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've not used plists much.
I'll fix it to add that instead.

@areese
Copy link
Contributor Author

areese commented May 10, 2021

@carlocab etcd won't start without that var.
Here is brew test without:

% brew install etcd --build-from-source
==> Cloning https://github.com/etcd-io/etcd.git
Updating Library/Caches/Homebrew/etcd--git
==> Checking out tag v3.4.15
HEAD is now at aa71268 version: 3.4.15
HEAD is now at aa71268 version: 3.4.15
==> go mod vendor
==> go build -mod=vendor -ldflags -s -w -X main.version=3.4.15 -o /opt/homebrew/Cellar/etcd/3.4.15/bin/etcd
==> go build -mod=vendor -ldflags -s -w -X main.version=3.4.15 -o /opt/homebrew/Cellar/etcd/3.4.15/bin/etcdctl etcdctl/main.go
==> Caveats
To have launchd start etcd now and restart at login:
  brew services start etcd
Or, if you don't want/need a background service you can just run:
  etcd
==> Summary
🍺  /opt/homebrew/Cellar/etcd/3.4.15: 8 files, 36.6MB, built in 6 seconds
% brew test etcd                     
==> Testing etcd
etcd on unsupported platform without ETCD_UNSUPPORTED_ARCH=arm64 set
==> curl --silent -L http://127.0.0.1:2379/v2/keys/brew_test -XPUT -d value=Hello from brew test!
Last 15 lines from Library/Logs/Homebrew/etcd/test.01.curl:
2021-05-10 16:13:54 -0700

curl
--silent
-L
http://127.0.0.1:2379/v2/keys/brew_test
-XPUT
-d
value=Hello from brew test!

Error: etcd: failed
An exception occurred within a child process:
  BuildError: Failed executing: curl --silent -L http://127.0.0.1:2379/v2/keys/brew_test -XPUT -d value=Hello\ from\ brew\ test!
/opt/homebrew/Library/Homebrew/formula.rb:2163:in `block in system'
/opt/homebrew/Library/Homebrew/formula.rb:2099:in `open'
/opt/homebrew/Library/Homebrew/formula.rb:2099:in `system'
/opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula/etcd.rb:70:in `block in <class:Etcd>'
/opt/homebrew/Library/Homebrew/formula.rb:1963:in `block (3 levels) in run_test'
/opt/homebrew/Library/Homebrew/utils.rb:558:in `with_env'
/opt/homebrew/Library/Homebrew/formula.rb:1962:in `block (2 levels) in run_test'
/opt/homebrew/Library/Homebrew/formula.rb:924:in `with_logging'
/opt/homebrew/Library/Homebrew/formula.rb:1961:in `block in run_test'
/opt/homebrew/Library/Homebrew/mktemp.rb:63:in `block in run'
/opt/homebrew/Library/Homebrew/mktemp.rb:63:in `chdir'
/opt/homebrew/Library/Homebrew/mktemp.rb:63:in `run'
/opt/homebrew/Library/Homebrew/formula.rb:2212:in `mktemp'
/opt/homebrew/Library/Homebrew/formula.rb:1955:in `run_test'
/opt/homebrew/Library/Homebrew/test.rb:43:in `block in <main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `block in catch'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:108:in `timeout'
/opt/homebrew/Library/Homebrew/test.rb:48:in `<main>'
% 

@carlocab carlocab added the CI-force-arm [DEPRECATED] Don't pass --skip-unbottled-arm to brew test-bot. label May 10, 2021
@areese
Copy link
Contributor Author

areese commented May 10, 2021

I'll rebase and commit with the fixed plist:

% plutil  -p ./Cellar/etcd/3.4.15/homebrew.mxcl.etcd.plist
{
  "EnvironmentVariables" => {
    "ETCD_UNSUPPORTED_ARCH" => "arm64"
  }
  "KeepAlive" => {
    "SuccessfulExit" => 0
  }
  "Label" => "homebrew.mxcl.etcd"
  "ProgramArguments" => [
    0 => "/opt/homebrew/opt/etcd/bin/etcd"
  ]
  "RunAtLoad" => 1
  "WorkingDirectory" => "/opt/homebrew/var"
}
% brew services start etcd

==> Successfully started `etcd` (label: homebrew.mxcl.etcd)

@areese
Copy link
Contributor Author

areese commented May 10, 2021

@carlocab lemme know what you think of that. ty.

@carlocab
Copy link
Member

The new service blocks might make conditionally setting environment variables a lot simpler here.

See, for example:

service do
run [opt_sbin/"php-fpm", "--nodaemonize"]
run_type :immediate
keep_alive true
error_log_path var/"log/php-fpm.log"
working_dir var
end

or

service do
run [opt_bin/"httpd", "-D", "FOREGROUND"]
environment_variables PATH: std_service_path_env
run_type :immediate
end

@areese
Copy link
Contributor Author

areese commented May 10, 2021

That is far better, and it might fix the issue where it etcd complains.
If you spawn etcd directly it still gets upset, lemme take a shot at doing the service instead.

@carlocab
Copy link
Member

I think you should just be able to do

environment_variables ETCD_UNSUPPORTED_ARCH: "arm64" if Hardware::CPU.arm?

in a service block.

Formula/etcd.rb Outdated
keep_alive true
working_dir var
end

def plist
Copy link
Member

Choose a reason for hiding this comment

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

You need to delete the plist method when using a service block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol I was wondering that ty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed plist section
Tested out service and it seems to work:"

% /opt/homebrew/bin/etcdctl put foo bar
OK
% /opt/homebrew/bin/etcdctl get foo    
foo
bar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually, not happy with that.

The problem is, the way it is, we're not supporting arm at all, and I only looked specifically at arm on macOS.
updating to catch that specific.

Copy link
Member

Choose a reason for hiding this comment

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

Homebrew doesn't support arm in Linux so that would be fine like this

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’m still fighting with the service block
Last night it was complaining about plist
I’ll paste the error here soon

@areese
Copy link
Contributor Author

areese commented May 11, 2021

@carlocab should the plist section stick around if adding a service?
98a2011

I left the plist section, but I think it should be removed looking at some of the other examples.
I need to test this out and make sure the service works.

… Arm, it's not explicitly supported on m1 yet

Use a service block for etcd

remove plist section
@areese
Copy link
Contributor Author

areese commented May 11, 2021

@carlocab I think I've gotten somewhere with this.
lmk what you want to do.

% brew audit --strict etcd
% 

@areese
Copy link
Contributor Author

areese commented May 11, 2021

Correction, I don't think it's officially supported on MacOS arm64

This pr looks like it's supporting arm64, but as far as I can tell it's graviton
etcd-io/etcd#12929

Comment on lines +42 to +49
on_macos do
if Hardware::CPU.arm?
# etcd isn't officially supported on arm64
# https://github.com/etcd-io/etcd/issues/10318
# https://github.com/etcd-io/etcd/issues/10677
ENV["ETCD_UNSUPPORTED_ARCH"]="arm64"
end
end
Copy link
Member

Choose a reason for hiding this comment

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

If they don't support ARM at all, maybe we don't need this in an on_macos block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They seem to be about to support arm on Linux

Copy link
Member

@carlocab carlocab left a comment

Choose a reason for hiding this comment

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

Thanks, @areese. Will dispatch a bottle build separately.

@carlocab carlocab merged commit ba2212a into Homebrew:master May 11, 2021
@areese
Copy link
Contributor Author

areese commented May 11, 2021

@carlocab This is what I was seeing last night that I don't fully understand:

 % brew reinstall --build-from-source etcd
==> Cloning https://github.com/etcd-io/etcd.git
Updating Library/Caches/Homebrew/etcd--git
==> Checking out tag v3.4.15
HEAD is now at aa71268 version: 3.4.15
HEAD is now at aa71268 version: 3.4.15
==> Reinstalling etcd 
==> go mod vendor
==> go build -mod=vendor -ldflags -s -w -X main.version=3.4.15 -o /opt/homebrew/Cellar/etcd/3.4.15/bin/etcd
==> go build -mod=vendor -ldflags -s -w -X main.version=3.4.15 -o /opt/homebrew/Cellar/etcd/3.4.15/bin/etcdctl etcdctl/main.go
Error: Failed to install plist file
🍺  /opt/homebrew/Cellar/etcd/3.4.15: 7 files, 36.6MB, built in 5 seconds
 % brew audit --strict etcd               
 % 

The service is working fine.

@areese areese deleted the m1-support/etcd branch May 11, 2021 15:09
@carlocab
Copy link
Member

Oh, huh. So, to be sure, you see an error about the plist file, but are able to use the service anyway? That's weird.

CC @SMillerDev in case you know what's going on there.

@carlocab
Copy link
Member

Bottled in a331500.

@areese
Copy link
Contributor Author

areese commented May 11, 2021

Yeah that’s what confused me
I’m trying to set up a case sensitive install of macOS
But I’m going to poke it again

i had tested the service and ran audit and then rebuilt after adding the on macos and noticed this
It’s been there since I added the service block but I’ll poke around more

@areese
Copy link
Contributor Author

areese commented May 11, 2021

I left this part of the patch on my desk some how, but given the conversation the only relevant part is
etcd-io/etcd#12929

I'm going to reproduce the plist complaint I had

diff --git a/Formula/etcd.rb b/Formula/etcd.rb
index 5df7ce5f653..8734516ca1f 100644
--- a/Formula/etcd.rb
+++ b/Formula/etcd.rb
@@ -29,7 +29,13 @@ class Etcd < Formula
   plist_options manual: "etcd"
 
   service do
-    environment_variables ETCD_UNSUPPORTED_ARCH: "arm64" if Hardware::CPU.arm?
+    # etcd isn't officially supported on MacOS arm64
+    # https://github.com/etcd-io/etcd/issues/10318
+    # https://github.com/etcd-io/etcd/issues/10677
+    # https://github.com/etcd-io/etcd/pull/12929
+    on_macos do
+      environment_variables ETCD_UNSUPPORTED_ARCH: "arm64" if Hardware::CPU.arm?
+    end
     run [opt_bin/"etcd"]
     run_type :immediate
     keep_alive true
@@ -44,6 +50,7 @@ class Etcd < Formula
           # etcd isn't officially supported on arm64
           # https://github.com/etcd-io/etcd/issues/10318
           # https://github.com/etcd-io/etcd/issues/10677
+          # https://github.com/etcd-io/etcd/pull/12929
           ENV["ETCD_UNSUPPORTED_ARCH"]="arm64"
         end
       end

@carlocab
Copy link
Member

Hm, I'm not sure on_macos blocks work inside service blocks. That might be where the error is coming from. You can try to get more detail out of it with --verbose --debug.

@areese
Copy link
Contributor Author

areese commented May 11, 2021

I bet that's what the problem is, as I just pulled master and don't see the error, and I don't have the on_macos in master.

@github-actions github-actions bot added the outdated PR was locked due to age label Jun 11, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI-force-arm [DEPRECATED] Don't pass --skip-unbottled-arm to brew test-bot. go Go use is a significant feature of the PR or issue no ARM bottle Formula has no ARM bottle outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants