Skip to content

Commit

Permalink
hubble: fix deployment of hubble with unreleased Cilium versions
Browse files Browse the repository at this point in the history
If Cilium image is set to a tag that can't be represented as a semver we
will fallback to the base version set by --base-version available as a
flag to the hubble enable command.

Signed-off-by: André Martins <[email protected]>
  • Loading branch information
aanm authored and tklauser committed Apr 12, 2022
1 parent aad7a72 commit 5049e04
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
17 changes: 6 additions & 11 deletions hubble/hubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,10 @@ func (k *K8sHubble) disableHubble(ctx context.Context) error {
}

func (k *K8sHubble) Disable(ctx context.Context) error {
var err error
k.ciliumVersion, err = k.client.GetRunningCiliumVersion(ctx, k.params.Namespace)
if err != nil {
return err
}

// Ignore the GetRunningCiliumVersion error since it doesn't work for
// unreleased versions, and we will fall back to the --base-version
k.ciliumVersion, _ = k.client.GetRunningCiliumVersion(ctx, k.params.Namespace)
k.semVerCiliumVersion = k.getCiliumVersion()

cm, err := k.client.GetConfigMap(ctx, k.params.Namespace, defaults.ConfigMapName, metav1.GetOptions{})
Expand Down Expand Up @@ -435,12 +433,9 @@ func (k *K8sHubble) Enable(ctx context.Context) error {
return err
}

var err error
k.ciliumVersion, err = k.client.GetRunningCiliumVersion(ctx, k.params.Namespace)
if err != nil {
return err
}

// Ignore the GetRunningCiliumVersion error since it doesn't work for
// unreleased versions, and we will fall back to the --base-version
k.ciliumVersion, _ = k.client.GetRunningCiliumVersion(ctx, k.params.Namespace)
k.semVerCiliumVersion = k.getCiliumVersion()

caSecret, created, err := k.certManager.GetOrCreateCASecret(ctx, defaults.CASecretName, k.params.CreateCA)
Expand Down
9 changes: 3 additions & 6 deletions hubble/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,9 @@ func (k *K8sHubble) generateRelayCertificate(name string) (corev1.Secret, error)
}

func (k *K8sHubble) PortForwardCommand(ctx context.Context) error {
var err error
k.ciliumVersion, err = k.client.GetRunningCiliumVersion(ctx, k.params.Namespace)
if err != nil {
return err
}

// Ignore the GetRunningCiliumVersion error since it doesn't work for
// unreleased versions, and we will fall back to the --base-version
k.ciliumVersion, _ = k.client.GetRunningCiliumVersion(ctx, k.params.Namespace)
k.semVerCiliumVersion = k.getCiliumVersion()

cm, err := k.client.GetConfigMap(ctx, k.params.Namespace, defaults.ConfigMapName, metav1.GetOptions{})
Expand Down

0 comments on commit 5049e04

Please sign in to comment.