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

cli: inconsistent precedence for registry flag #11144

Merged
merged 1 commit into from
Jul 28, 2023

Conversation

harsh020
Copy link
Contributor

@harsh020 harsh020 commented Jul 21, 2023

Fixes: #11115

Problem:
Commands jaeger install, multicluster link give precedence to LINKERD_DOCKER_REGISTRY env var, whereas commands install, upgrade and inject give preference to --register flag.

Solution:
Make the commands consitent by giving precedence to --register flag in all commands.

Tasks:

  • Make jaeger install give precedence to --register
  • Make multicluster link give precedence to --register

@harsh020
Copy link
Contributor Author

harsh020 commented Jul 21, 2023

@risingspiral @alpeb I have a few questions before I proceed,

  1. As the env variable is named EnvOverrideDockerRegistry it seems kind of unconventional that the --register flag would override the override. Should we rename the env variable or keep it as it is?
  2. Do the changes till now (I know they are small) seem good and am I in the right direction?
  3. I have not committed with the complete commit message as of now (no DCO and Validation). Do we follow force-push commits to override the commit messages here at linkered?
  4. Should I pull master and resolve the conflicts in next commit or conflicts are resolved when the maintainers queue the PRs to be merged?

@harsh020 harsh020 force-pushed the inconsitent-precedent-for-registry-cmd branch from 2274b2c to d837dc7 Compare July 24, 2023 12:19
@harsh020 harsh020 marked this pull request as ready for review July 24, 2023 12:20
@harsh020 harsh020 requested a review from a team as a code owner July 24, 2023 12:20
@harsh020 harsh020 force-pushed the inconsitent-precedent-for-registry-cmd branch from d837dc7 to 926ce87 Compare July 24, 2023 12:22
@harsh020
Copy link
Contributor Author

@risingspiral @alpeb Can you please review and let me know if something else need to be done here.

@adleong
Copy link
Member

adleong commented Jul 24, 2023

Hi @harsh020

Please take a look at the CI failure on this PR. It look like you may be missing a cmd import.

@harsh020 harsh020 force-pushed the inconsitent-precedent-for-registry-cmd branch from 926ce87 to 0962686 Compare July 25, 2023 07:43
@harsh020
Copy link
Contributor Author

@adleong Oh my! I think I changed pkgcmd to cmd by mistake.

  • But this time I did run test for jaeger/cmd and multicluster/cmd, and they seemed to be ok.
  • I also ran linter on both but it seems to be failing on import statements (I assume that not because of me)

@harsh020
Copy link
Contributor Author

harsh020 commented Jul 26, 2023

@adleong Hey, the multicluster install test just cancelled due to

Waiting for control plane to become available
Cannot find Linkerd: No running pods for "linkerd-destination"

I have made no changes in the install cmd. Please correct me if I'm wrong but the error does not seem to be because of my changes, right?

EDIT: Wait what just happened, suddenly the CI that was cancelled automatically passed! Am I missing something or the workflow was retriggered?

Copy link
Member

@adleong adleong left a comment

Choose a reason for hiding this comment

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

Looks great!

if override := os.Getenv(flags.EnvOverrideDockerRegistry); override != "" {
vals["webhook"].(map[string]interface{})["image"].(map[string]interface{})["name"] = pkgcmd.RegistryOverride(regOrig, override)
}
// CLI flag overrides env variable
if registry != "" {
vals["webhook"].(map[string]interface{})["image"].(map[string]interface{})["name"] = pkgcmd.RegistryOverride(regOrig, registry)
Copy link
Member

Choose a reason for hiding this comment

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

It appears that the env var stopped working for the linkerd jaeger install command:

$ LINKERD_DOCKER_REGISTRY=ENV bin/go-run cli jaeger install --ignore-cluster  | grep image: | sort | uniq
        image: cr.l5d.io/linkerd/jaeger-webhook:dev-09626867-alpeb
        image: jaegertracing/all-in-one:1.31
        image: otel/opentelemetry-collector:0.59.0

The reason is registry in this line will always be non-empty, holding its default value pkgcmd.DefaultDockerRegistry.

As for the previous CI failure, it was just a flake, I re-triggered the tests and they went through 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason is registry in this line will always be non-empty, holding its default value

Oh! I assumed that that was what we expected (I donno why I assumed it, makes no sense). I have updated the PR, can you please have a look and let me know if I need to take a different approach? Moreover, I'm kind of new to Go so, pls do let me know if I am not following any convention here.

As for the previous CI failure, it was just a flake, I re-triggered the tests and they went through 😉

Thanks a lot! I was just amused by the possibility of auto-re-triggers!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the quick turnaround 👍
Can you actually leave the default value for the --registry flag as it originally was? IMO those defaults should be static and independent of the environment. Maybe the same approach you had for multicluster/cmd/link.go can work here as well? Just using this at the beginning:

	if registry := os.Getenv(flags.EnvOverrideDockerRegistry); registry != "" {
		opts.dockerRegistry = registry
	}

and then inside render() leave vals["webhook"].(map[string]interface{})["image"].(map[string]interface{})["name"] = pkgcmd.RegistryOverride(regOrig, registry) regardless of registry's content...

Copy link
Contributor Author

@harsh020 harsh020 Jul 28, 2023

Choose a reason for hiding this comment

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

Hey @alpeb, I think I'm a bit confused here. When you say don't replace default value in flag do you mean the default variable pkgcmd.DefaultDockerRegistry (or specifically the value it holds) with some other variable. Because I am doing the same thing as I have done in multicluster/cmd/link.go, here I have just introduces a new variable deafultRegistry (in multicluster we had opts). Do you want me to not use this extra variable and replace the value in pkgcmd.DefaultDockerRegistry itself (I was a bit skeptical about this as maybe it could have messed the global state).

Copy link
Member

Choose a reason for hiding this comment

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

You're right, I take that back, you're doing the same for the link command. And it would require unwarranted added complexity to do it like I suggest.

@harsh020 harsh020 force-pushed the inconsitent-precedent-for-registry-cmd branch from 0962686 to 7c8b201 Compare July 27, 2023 19:08
@harsh020 harsh020 requested review from alpeb and adleong July 27, 2023 19:13
Problem:
Commands `jaeger install`, `multicluster link` give precedence to `LINKERD_DOCKER_REGISTRY` env var, whereas commands `install`, `upgrade` and `inject` give preference to `--register` flag.

Solution:
Make the commands consitent by giving precedence to `--register` flag in all commands.

Fixes: linkerd#11115

Signed-off-by: Harsh Soni <[email protected]>
@harsh020 harsh020 force-pushed the inconsitent-precedent-for-registry-cmd branch from 7c8b201 to a434737 Compare July 27, 2023 19:15
Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

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

Good job!

@alpeb alpeb merged commit 6f5ac2a into linkerd:main Jul 28, 2023
@hawkw hawkw added this to the stable-2.13.6 milestone Aug 8, 2023
hawkw pushed a commit that referenced this pull request Aug 9, 2023
Problem:
Commands `jaeger install`, `multicluster link` give precedence to `LINKERD_DOCKER_REGISTRY` env var, whereas commands `install`, `upgrade` and `inject` give preference to `--register` flag.

Solution:
Make the commands consitent by giving precedence to `--register` flag in all commands.

Fixes: #11115

Signed-off-by: Harsh Soni <[email protected]>
hawkw added a commit that referenced this pull request Aug 9, 2023
This stable release fixes a regression introduced in stable-2.13.0 which
resulted in proxies shedding load too aggressively while under moderate
request load to a single service ([#11055]). In addition, it updates the
base image for the `linkerd-cni` initcontainer to resolve a CVE in
`libdb` ([#11196]), fixes a race condition in the Destination controller
that could cause it to crash ([#11163]), as well as fixing a number of
other issues.

* Control Plane
  * Fixed a race condition in the destination controller that could
    cause it to panic ([#11169]; fixes [#11193])
  * Improved the granularity of logging levels in the control plane
    ([#11147])
  * Replaced incorrect `server_port_subscribers` gauge in the
    Destination controller's metrics with `server_port_subscribes` and
    `server_port_unsubscribes` counters ([#11206]; fixes [#10764])

* Proxy
  * Changed the default HTTP request queue capacities for the inbound
    and outbound proxies back to 10,000 requests ([#11198]; fixes
    [#11055])

* CLI
  * Updated extension CLI commands to prefer the `--registry` flag over
    the `LINKERD_DOCKER_REGISTRY` environment variable, making the
    precedence more consistent (thanks @harsh020!) (see [#11144])

* CNI
  * Updated `linkerd-cni` base image to resolve [CVE-2019-8457] in
    `libdb` ([#11196])
  * Changed the CNI plugin installer to always run in 'chained' mode;
    the plugin will now wait until another CNI plugin is installed
    before appending its configuration ([#10849])
  * Removed `hostNetwork: true` from linkerd-cni Helm chart templates
    ([#11158]; fixes [#11141]) (thanks @abhijeetgauravm!)

* Multicluster
  * Fixed the `linkerd multicluster check` command failing in the
    presence of lots of mirrored services ([#10764])

[#10764]: #10764
[#10849]: #10849
[#11055]: #11055
[#11141]: #11141
[#11144]: #11144
[#11147]: #11147
[#11158]: #11158
[#11163]: #11163
[#11169]: #11169
[#11196]: #11196
[#11198]: #11198
[#11206]: #11206
[CVE-2019-8457]: https://avd.aquasec.com/nvd/2019/cve-2019-8457/
@hawkw hawkw mentioned this pull request Aug 9, 2023
hawkw added a commit that referenced this pull request Aug 9, 2023
This stable release fixes a regression introduced in stable-2.13.0 which
resulted in proxies shedding load too aggressively while under moderate
request load to a single service ([#11055]). In addition, it updates the
base image for the `linkerd-cni` initcontainer to resolve a CVE in
`libdb` ([#11196]), fixes a race condition in the Destination controller
that could cause it to crash ([#11163]), as well as fixing a number of
other issues.

* Control Plane
  * Fixed a race condition in the destination controller that could
    cause it to panic ([#11169]; fixes [#11193])
  * Improved the granularity of logging levels in the control plane
    ([#11147])
  * Replaced incorrect `server_port_subscribers` gauge in the
    Destination controller's metrics with `server_port_subscribes` and
    `server_port_unsubscribes` counters ([#11206]; fixes [#10764])

* Proxy
  * Changed the default HTTP request queue capacities for the inbound
    and outbound proxies back to 10,000 requests ([#11198]; fixes
    [#11055])

* CLI
  * Updated extension CLI commands to prefer the `--registry` flag over
    the `LINKERD_DOCKER_REGISTRY` environment variable, making the
    precedence more consistent (thanks @harsh020!) (see [#11144])

* CNI
  * Updated `linkerd-cni` base image to resolve [CVE-2019-8457] in
    `libdb` ([#11196])
  * Changed the CNI plugin installer to always run in 'chained' mode;
    the plugin will now wait until another CNI plugin is installed
    before appending its configuration ([#10849])
  * Removed `hostNetwork: true` from linkerd-cni Helm chart templates
    ([#11158]; fixes [#11141]) (thanks @abhijeetgauravm!)

* Multicluster
  * Fixed the `linkerd multicluster check` command failing in the
    presence of lots of mirrored services ([#10764])

[#10764]: #10764
[#10849]: #10849
[#11055]: #11055
[#11141]: #11141
[#11144]: #11144
[#11147]: #11147
[#11158]: #11158
[#11163]: #11163
[#11169]: #11169
[#11196]: #11196
[#11198]: #11198
[#11206]: #11206
[CVE-2019-8457]: https://avd.aquasec.com/nvd/2019/cve-2019-8457/
hawkw added a commit that referenced this pull request Aug 9, 2023
This stable release fixes a regression introduced in stable-2.13.0 which
resulted in proxies shedding load too aggressively while under moderate
request load to a single service ([#11055]). In addition, it updates the
base image for the `linkerd-cni` initcontainer to resolve a CVE in
`libdb` ([#11196]), fixes a race condition in the Destination controller
that could cause it to crash ([#11163]), as well as fixing a number of
other issues.

* Control Plane
  * Fixed a race condition in the destination controller that could
    cause it to panic ([#11169]; fixes [#11193])
  * Improved the granularity of logging levels in the control plane
    ([#11147])

* Proxy
  * Changed the default HTTP request queue capacities for the inbound
    and outbound proxies back to 10,000 requests ([#11198]; fixes
    [#11055])

* CLI
  * Updated extension CLI commands to prefer the `--registry` flag over
    the `LINKERD_DOCKER_REGISTRY` environment variable, making the
    precedence more consistent (thanks @harsh020!) (see [#11144])

* CNI
  * Updated `linkerd-cni` base image to resolve [CVE-2019-8457] in
    `libdb` ([#11196])
  * Changed the CNI plugin installer to always run in 'chained' mode;
    the plugin will now wait until another CNI plugin is installed
    before appending its configuration ([#10849])
  * Removed `hostNetwork: true` from linkerd-cni Helm chart templates
    ([#11158]; fixes [#11141]) (thanks @abhijeetgauravm!)

* Multicluster
  * Fixed the `linkerd multicluster check` command failing in the
    presence of lots of mirrored services ([#10764])

[#10764]: #10764
[#10849]: #10849
[#11055]: #11055
[#11141]: #11141
[#11144]: #11144
[#11147]: #11147
[#11158]: #11158
[#11163]: #11163
[#11169]: #11169
[#11196]: #11196
[#11198]: #11198
[CVE-2019-8457]: https://avd.aquasec.com/nvd/2019/cve-2019-8457/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants