kubernetes-sigs / cluster-api

Home for Cluster API, a subproject of sig-cluster-lifecycle
https://cluster-api.sigs.k8s.io
Apache License 2.0
3.52k stars 1.3k forks source link

clusterctl version empty after Homebrew install #4802

Closed gnadaban closed 3 years ago

gnadaban commented 3 years ago

What steps did you take and what happened:

homebrew install clusterctl

Output:

clusterctl version: &version.Info{Major:"", Minor:"", GitVersion:"", GitCommit:"", GitTreeState:"", BuildDate:"", GoVersion:"go1.16.4", Compiler:"gc", Platform:"darwin/arm64"}
Error: unable to verify clusterctl version: unable to semver parse clusterctl GitVersion: strconv.ParseUint: parsing "": invalid syntax

What did you expect to happen:

clusterctl version to output current version.

Anything else you would like to add: N/A

Environment:

/kind bug [One or more /area label. See https://github.com/kubernetes-sigs/cluster-api/labels?q=area for the list of labels]

vincepri commented 3 years ago

@ludusrusso @fabriziopandini How does brew build clusterctl?

Running make clusterctl locally correctly calls hack/version.sh to set the -ldflags which then brings in the version

vincepri commented 3 years ago

Tried to run brew install clusterctl --build-bottle locally and it seems it also didn't get the version information

vincepri commented 3 years ago

Further info: Seems that the tar downloaded from github (https://github.com/kubernetes-sigs/cluster-api/archive/refs/tags/v0.3.19.tar.gz) doesn't contain .git directory or any git information, which makes hack/version.sh to fail to understand which version is it.

ludusrusso commented 3 years ago

@vincepri uhm! How do you suggest to fix this? I think we need to change the hack/version.ah in some way to get the version!

karuppiah7890 commented 3 years ago

I see that kubectl uses git URL https://github.com/Homebrew/homebrew-core/blob/master/Formula/kubernetes-cli.rb . If we want to use git to detect the version, I think that's the way to go? 🤔

I see that we are currently using tar ball directly https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/clusterctl.rb

karuppiah7890 commented 3 years ago

If we still want to go with hack/version.sh (which totally uses git) but without depending on git, I think the popular way to go about it is simply override everything that's getting computed using git by passing some environment variables. But then that could be considered a very hacky thing considering all the stuff that the hack/version.sh script does

vincepri commented 3 years ago

Can Homebrew be configured to get the release binaries instead? We could publish for more platforms if that's needed

karuppiah7890 commented 3 years ago

I see this - https://docs.brew.sh/Acceptable-Formulae#we-dont-like-binary-formulae

Looking at CLI tools present in Cask - https://github.com/Homebrew/homebrew-cask/search?p=2&q=cli , I found concourse fly CLI using Cask https://github.com/Homebrew/homebrew-cask/blob/9b1e4b11e0e909d33306e2caf309d78b3d701833/Casks/fly.rb

vincepri commented 3 years ago

Let's ask the homebrew maintainers what's the proper way to go?

@dawidd6 Any thoughts?

dawidd6 commented 3 years ago

Just change to git URL.

vincepri commented 3 years ago

Anyone has time to look at the above?

/kind bug /priority important-soon /milestone v0.4

fabriziopandini commented 3 years ago

/help

k8s-ci-robot commented 3 years ago

@fabriziopandini: This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed by commenting with the /remove-help command.

In response to [this](https://github.com/kubernetes-sigs/cluster-api/issues/4802): >/help Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
karuppiah7890 commented 3 years ago

This seems like a good first issue for new contributors. I'll try to pair with someone who is new and help them raise a PR, or I'll raise it myself

vibhorrawat commented 3 years ago

/assign

vibhorrawat commented 3 years ago

Observations-

I will update the Homebrew PR details soon.

@karuppiah7890 Thank you so much for your help with this one. You are fab! 🎉

vibhorrawat commented 3 years ago

Homebrew PR submitted for this issue.

karuppiah7890 commented 3 years ago

This issue can be closed 🚀 😄

https://github.com/Homebrew/homebrew-core/pull/82138 has been merged (using an automation). Commit - https://github.com/Homebrew/homebrew-core/commit/d9ad7fbdc9a70d612c0318bbdc5fd66222044b16

I tried a brew update and installed and it worked


$ brew remove clusterctl
Uninstalling /usr/local/Cellar/clusterctl/0.4.0... (5 files, 50.6MB)

$ brew update
Updated 5 taps (hashicorp/tap, homebrew/core, homebrew/cask, vmware-tanzu/carvel and vmware/internal).
==> New Formulae
notcurses                                                  sql-lint
==> Updated Formulae
awscli ✔                               forge                                  php@7.4
hashicorp/tap/nomad ✔                  hashicorp/tap/terraform-ls             phpstan
hugo ✔                                 jupyterlab                             pspg
nomad ✔                                khal                                   pulumi
vmware-tanzu/carvel/imgpkg ✔           ktlint                                 qalculate-gtk
angular-cli                            libqalculate                           sceptre
apache-arrow                           libstatgrab                            snapcraft
apache-arrow-glib                      mill                                   terraform-ls
apache-geode                           node                                   tfsec
cdktf                                  node-build                             vault
clusterctl                             node@12                                vmware/internal/puzzle
cubejs-cli                             node@14                                whistle
dolt                                   pdm                                    xplr
exploitdb                              php
==> New Casks
clock-signal                                               memory-cleaner
==> Updated Casks
a-better-finder-attributes             gramps                                 plex-media-server
airtool                                integrity                              portfolioperformance
anki                                   lagrange                               raycast
azure-data-studio                      lark                                   renpy
calibre                                lastpass                               sentinel
chirp                                  lingon-x                               simplenote
chromedriver                           lx-music                               smultron
chromium                               maltego                                snipaste
dmm-player                             marginnote                             spitfire-audio
dmm-player-for-chrome                  microsoft-azure-storage-explorer       swinsian
downie                                 microsoft-edge                         tencent-meeting
dteoh-devdocs                          modern-csv                             transmit
duplicacy                              museeks                                typeface
feishu                                 origin                                 yinxiangbiji
goland                                 phpstorm

You have 9 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.

$ brew info clusterctl
clusterctl: stable 0.4.0 (bottled), HEAD
Home for the Cluster Management API work, a subproject of sig-cluster-lifecycle
https://cluster-api.sigs.k8s.io
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/clusterctl.rb
License: Apache-2.0
==> Dependencies
Build: go ✔
==> Options
--HEAD
    Install HEAD version
==> Analytics
install: 58 (30 days), 216 (90 days), 336 (365 days)
install-on-request: 58 (30 days), 216 (90 days), 336 (365 days)
build-error: 0 (30 days)

$ brew install clusterctl
==> Downloading https://ghcr.io/v2/homebrew/core/clusterctl/manifests/0.4.0_1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/clusterctl/blobs/sha256:78f9971863e00fac134bb9aa6f9f4d27828917b8d502
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:78f9971863e00fac134bb9aa6f9f4d27
######################################################################## 100.0%
==> Pouring clusterctl--0.4.0_1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/clusterctl/0.4.0_1: 5 files, 50.6MB

$ clusterctl 
Get started with Cluster API using clusterctl to create a management cluster,
install providers, and create templates for your workload cluster.

Usage:
  clusterctl [command]

Available Commands:
  alpha       Commands for features in alpha.
  completion  Output shell completion code for the specified shell (bash or zsh)
  config      Display clusterctl configuration.
  delete      Delete one or more providers from the management cluster.
  describe    Describe workload clusters.
  generate    Generate yaml using clusterctl yaml processor.
  get         Get info from a management or a workload cluster
  help        Help about any command
  init        Initialize a management cluster.
  move        Move Cluster API objects and all dependencies between management clusters.
  upgrade     Upgrade core and provider components in a management cluster.
  version     Print clusterctl version.

Flags:
      --config $HOME/.cluster-api/clusterctl.yaml   Path to clusterctl configuration (default is $HOME/.cluster-api/clusterctl.yaml) or to a remote location (i.e. https://example.com/clusterctl.yaml)
  -h, --help                                        help for clusterctl
  -v, --v int                                       Set the log level verbosity. This overrides the CLUSTERCTL_LOG_LEVEL environment variable.

Use "clusterctl [command] --help" for more information about a command.

$ clusterctl version
clusterctl version: &version.Info{Major:"0", Minor:"4", GitVersion:"v0.4.0", GitCommit:"7f879be68d15737e335b6cb39d380d1d163e06e6", GitTreeState:"clean", BuildDate:"", GoVersion:"go1.16.6", Compiler:"gc", Platform:"darwin/amd64"}

@gnadaban you could try a brew update and then brew upgrade clusterctl and it should work I think. Let us know!

vincepri commented 3 years ago

/close

Thank you so much folks! Great work

k8s-ci-robot commented 3 years ago

@vincepri: Closing this issue.

In response to [this](https://github.com/kubernetes-sigs/cluster-api/issues/4802#issuecomment-889959419): >/close > >Thank you so much folks! Great work Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.