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

pkg/cli/admin/upgrade/channel: Add 'oc adm upgrade channel ...' #576

Merged
merged 2 commits into from Jul 7, 2021

Conversation

wking
Copy link
Member

@wking wking commented Sep 18, 2020

A new subcommand for conveniently managing channels. Example workflow, starting in a channel:

$ oc adm upgrade
Cluster version is 4.6.0-fc.3

Upstream: https://api.openshift.com/api/upgrades_info/v1/graph
Channel: candidate-4.6 (choices: candidate-4.6)
Updates:

VERSION    IMAGE
4.6.0-fc.4 quay.io/openshift-release-dev/ocp-release@sha256:960ec73733150827076cbb5fa2c1f5aaa9a94bfbce1b4897e46432a56ac976c1
4.6.0-fc.5 quay.io/openshift-release-dev/ocp-release@sha256:5883d0db15939484bd477147e6949c53fbc6f551ec20a0f1106b8a3acfb86ef8

Trying to change to the same channel is a no-op:

$ oc adm upgrade channel candidate-4.6
info: Cluster is already in candidate-4.6

Trying to change to an unrecognized channel gets a warning:

$ oc adm upgrade channel does-not-exist
error: the requested channel "does-not-exist" is not one of the available channels (candidate-4.6), you must pass --allow-explicit-channel to continue
$ oc adm upgrade channel --allow-explicit-channel does-not-exist
warning: The requested channel "does-not-exist" is not one of the available channels (candidate-4.6).  You have used --allow-explicit-channel to proceed anyway.
$ oc adm upgrade
Cluster version is 4.6.0-fc.3

Channel: does-not-exist
warning: Cannot display available updates:
  Reason: VersionNotFound
  Message: Unable to retrieve available updates: currently reconciling cluster version 4.6.0-fc.3 not found in the "does-not-exist" channel

When we have no known channels, changing requires no override:

$ oc adm upgrade channel does-not-exist-either
warning: No channels known to be compatible with the current version "4.6.0-fc.3"; unable to validate "does-not-exist-either".
$ oc adm upgrade channel candidate-4.6
warning: No channels known to be compatible with the current version "4.6.0-fc.3"; unable to validate "candidate-4.6".

Clearing a known channel needs an explicit override:

$ oc adm upgrade channel
error: the requested channel "" is not one of the available channels (candidate-4.6), you must pass --allow-explicit-channel to continue
$ oc adm upgrade channel --allow-explicit-channel
warning: Clearing channel "candidate-4.6"; cluster will no longer request available update recommendations.
$ oc adm upgrade
Cluster version is 4.6.0-fc.3

warning: Cannot display available updates:
  Reason: NoChannel
  Message: The update channel has not been configured.

Trying to re-clear the channel is a no-op:

$ oc adm upgrade channel
info: Cluster channel is already clear

And you can set any channel from a cleared channel without an override, because this is another case where we have no idea what the valid choices are:

$ oc adm upgrade channel candidate-4.6
warning: No channels known to be compatible with the current version "4.6.0-fc.3"; unable to validate "candidate-4.6".
$ oc adm upgrade
Cluster version is 4.6.0-fc.3

Upstream: https://api.openshift.com/api/upgrades_info/v1/graph
Channel: candidate-4.6 (choices: candidate-4.6)
Updates:

VERSION    IMAGE
4.6.0-fc.4 quay.io/openshift-release-dev/ocp-release@sha256:960ec73733150827076cbb5fa2c1f5aaa9a94bfbce1b4897e46432a56ac976c1
4.6.0-fc.5 quay.io/openshift-release-dev/ocp-release@sha256:5883d0db15939484bd477147e6949c53fbc6f551ec20a0f1106b8a3acfb86ef8

Clearing from an unknown channel does not require an override either:

$ oc adm upgrade channel --allow-explicit-channel does-not-exist
warning: The requested channel "does-not-exist" is not one of the available channels (candidate-4.6).  You have used --allow-explicit-channel to proceed anyway.
$ oc adm upgrade channel
warning: Clearing channel "does-not-exist"; cluster will no longer request available update recommendations.

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 18, 2020
@openshift-ci-robot openshift-ci-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 19, 2020
@openshift-ci-robot
Copy link

@wking: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-aws 170242c link /test e2e-aws
ci/prow/e2e-cmd 170242c link /test e2e-cmd

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

pkg/cli/admin/upgrade/upgrade.go Outdated Show resolved Hide resolved
o := NewOptions(streams)
cmd := &cobra.Command{
Use: "channel CHANNEL",
Short: "Set or clear the update channel",
Copy link
Member

Choose a reason for hiding this comment

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

oc adm upgrade channel candidate-4.6

Is not intuitive IMO. We need a verb or flag to make it intuitive e.g. oc adm upgrade channel --to candidate-4.6

Copy link
Member

Choose a reason for hiding this comment

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

I was trying to compile this PR to test the user experience but getting in to some error because I am using go 1.15.2

Copy link
Member Author

Choose a reason for hiding this comment

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

Rebased onto master, and it compiles in the CI presubmits. What error were you seeing?

/remove-lifecycle stale

Copy link
Member

Choose a reason for hiding this comment

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

I can compile the PR successfully now.

@openshift-merge-robot
Copy link
Contributor

@wking: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-agnostic-cmd 170242c link /test e2e-agnostic-cmd
ci/prow/e2e-aws-serial 170242c link /test e2e-aws-serial

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-bot
Copy link
Contributor

Issues go stale after 90d of inactivity.

Mark the issue as fresh by commenting /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.
Exclude this issue from closing by commenting /lifecycle frozen.

If this issue is safe to close now please do so with /close.

/lifecycle stale

@openshift-ci-robot openshift-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 4, 2021
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: wking
To complete the pull request process, please assign deads2k after the PR has been reviewed.
You can assign the PR to them by writing /assign @deads2k in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 8, 2021
Give folks some context about where the recommended updates, or lack
thereof, are coming from.

We don't need to print anything in the channel-unset case, because
that's already covered by the RetrievedUpdates condition handling:

  $ ~/src/openshift/oc/oc adm upgrade
  Cluster version is 4.6.0-fc.3

  warning: Cannot display available updates:
    Reason: NoChannel
    Message: The update channel has not been configured.

When a channel is configured:

  $ oc patch clusterversion version --type json -p '[{"op": "add", "path": "/spec/channel", "value": "candidate-4.6"}]'

output looks like:

  $ oc adm upgrade
  Cluster version is 4.6.0-fc.3

  Upstream: https://api.openshift.com/api/upgrades_info/v1/graph
  Channel: candidate-4.6 (available channels: candidate-4.6)
  Updates:

  VERSION    IMAGE
  4.6.0-fc.4 quay.io/openshift-release-dev/ocp-release@sha256:960ec73733150827076cbb5fa2c1f5aaa9a94bfbce1b4897e46432a56ac976c1
  4.6.0-fc.5 quay.io/openshift-release-dev/ocp-release@sha256:5883d0db15939484bd477147e6949c53fbc6f551ec20a0f1106b8a3acfb86ef8
A new subcommand for conveniently managing channels.  Example
workflow, starting in a channel:

  $ oc adm upgrade
  Cluster version is 4.6.0-fc.3

  Upstream: https://api.openshift.com/api/upgrades_info/v1/graph
  Channel: candidate-4.6 (available channels: candidate-4.6)
  Updates:

  VERSION    IMAGE
  4.6.0-fc.4 quay.io/openshift-release-dev/ocp-release@sha256:960ec73733150827076cbb5fa2c1f5aaa9a94bfbce1b4897e46432a56ac976c1
  4.6.0-fc.5 quay.io/openshift-release-dev/ocp-release@sha256:5883d0db15939484bd477147e6949c53fbc6f551ec20a0f1106b8a3acfb86ef8

Trying to change to the same channel is a no-op:

  $ oc adm upgrade channel candidate-4.6
  info: Cluster is already in candidate-4.6

Trying to change to an unrecognized channel gets a warning:

  $ oc adm upgrade channel does-not-exist
  error: the requested channel "does-not-exist" is not one of the available channels (candidate-4.6), you must pass --allow-explicit-channel to continue
  $ oc adm upgrade channel --allow-explicit-channel does-not-exist
  warning: The requested channel "does-not-exist" is not one of the available channels (candidate-4.6).  You have used --allow-explicit-channel to proceed anyway.
  $ oc adm upgrade
  Cluster version is 4.6.0-fc.3

  Channel: does-not-exist
  warning: Cannot display available updates:
    Reason: VersionNotFound
    Message: Unable to retrieve available updates: currently reconciling cluster version 4.6.0-fc.3 not found in the "does-not-exist" channel

When we have no known channels, changing requires no override:

  $ oc adm upgrade channel does-not-exist-either
  warning: No channels known to be compatible with the current version "4.6.0-fc.3"; unable to validate "does-not-exist-either".
  $ oc adm upgrade channel candidate-4.6
  warning: No channels known to be compatible with the current version "4.6.0-fc.3"; unable to validate "candidate-4.6".

Clearing a known channel needs an explicit override:

  $ oc adm upgrade channel
  error: the requested channel "" is not one of the available channels (candidate-4.6), you must pass --allow-explicit-channel to continue
  $ oc adm upgrade channel --allow-explicit-channel
  warning: Clearing channel "candidate-4.6"; cluster will no longer request available update recommendations.
  $ oc adm upgrade
  Cluster version is 4.6.0-fc.3

  warning: Cannot display available updates:
    Reason: NoChannel
    Message: The update channel has not been configured.

Trying to re-clear the channel is a no-op:

  $ oc adm upgrade channel
  info: Cluster channel is already clear

And you can set any channel from a cleared channel without an
override, because this is another case where we have no idea what the
valid choices are:

  $ oc adm upgrade channel candidate-4.6
  warning: No channels known to be compatible with the current version "4.6.0-fc.3"; unable to validate "candidate-4.6".
  $ oc adm upgrade
  Cluster version is 4.6.0-fc.3

  Upstream: https://api.openshift.com/api/upgrades_info/v1/graph
  Channel: candidate-4.6 (available channels: candidate-4.6)
  Updates:

  VERSION    IMAGE
  4.6.0-fc.4 quay.io/openshift-release-dev/ocp-release@sha256:960ec73733150827076cbb5fa2c1f5aaa9a94bfbce1b4897e46432a56ac976c1
  4.6.0-fc.5 quay.io/openshift-release-dev/ocp-release@sha256:5883d0db15939484bd477147e6949c53fbc6f551ec20a0f1106b8a3acfb86ef8

Clearing from an unknown channel does not require an override either:

  $ oc adm upgrade channel --allow-explicit-channel does-not-exist
  warning: The requested channel "does-not-exist" is not one of the available channels (candidate-4.6).  You have used --allow-explicit-channel to proceed anyway.
  $ oc adm upgrade channel
  warning: Clearing channel "does-not-exist"; cluster will no longer request available update recommendations.

Completions updated with:

  $ hack/update-generated-completions.sh
@sdodson
Copy link
Member

sdodson commented Jun 7, 2021

/refresh
/skip

@sdodson
Copy link
Member

sdodson commented Jun 8, 2021

/retest

@@ -328,6 +328,19 @@ func (o *Options) Run() error {
fmt.Fprintf(o.Out, "Upgradeable=False\n\n Reason: %s\n Message: %s\n\n", c.Reason, c.Message)
}

if cv.Spec.Channel != "" {
if cv.Spec.Upstream == "" {
fmt.Fprint(o.Out, "Upstream is unset, so the cluster will use an appropriate default.\n")
Copy link
Member

Choose a reason for hiding this comment

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

s/an appropriate default/ the default/ . Because we do not have multiple upstream options.

@LalatenduMohanty
Copy link
Member

I could reproduce this twice i.e. I am getting warning: No channels known to be compatible with the current version "4.7.12"; unable to validate "candidate-4.7". first time I set a channel. Even if it is a valid channel name.

$ ./oc patch clusterversion/version --patch '{"spec":{"upstream":"https://api.openshift.com/api/upgrades_info/v1/graph"}}' --type=merge
clusterversion.config.openshift.io/version patched

$ ./oc adm upgrade
Cluster version is 4.7.12

warning: Cannot display available updates:
  Reason: NoChannel
  Message: The update channel has not been configured.

$ ./oc adm upgrade channel candidate-4.7
warning: No channels known to be compatible with the current version "4.7.12"; unable to validate "candidate-4.7".

$ ./oc adm upgrade
Cluster version is 4.7.12

Upstream: https://api.openshift.com/api/upgrades_info/v1/graph
Channel: candidate-4.7 (available channels: candidate-4.7, candidate-4.8, fast-4.7, stable-4.7)
Updates:

VERSION IMAGE
4.7.13  quay.io/openshift-release-dev/ocp-release@sha256:783a2c963f35ccab38e82e6a8c7fa954c3a4551e07d2f43c06098828dd986ed4
4.7.14  quay.io/openshift-release-dev/ocp-release@sha256:10008b7c96c8c6a97fdba65db75e72840d07b2e43b6119585cac60aab70976f2

@LalatenduMohanty
Copy link
Member

/retest

Copy link
Member

@LalatenduMohanty LalatenduMohanty left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jul 7, 2021
@LalatenduMohanty
Copy link
Member

/approve

Copy link
Member

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

/approve

@soltysh
Copy link
Member

soltysh commented Jul 7, 2021

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 7, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LalatenduMohanty, soltysh, wking

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 7, 2021
@sdodson
Copy link
Member

sdodson commented Jul 7, 2021

/override ci/prow/e2e-aws-upgrade

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 7, 2021

@sdodson: Overrode contexts on behalf of sdodson: ci/prow/e2e-aws-upgrade

In response to this:

/override ci/prow/e2e-aws-upgrade

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 7, 2021

@wking: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/e2e-metal-ipi-ovn-ipv6 4b8f0fd link /test e2e-metal-ipi-ovn-ipv6

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@sdodson
Copy link
Member

sdodson commented Jul 7, 2021

/override ci/prow/e2e-aws
infra provisioning failure unlikely related to a net new oc command

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 7, 2021

@sdodson: Overrode contexts on behalf of sdodson: ci/prow/e2e-aws

In response to this:

/override ci/prow/e2e-aws
infra provisioning failure unlikely related to a net new oc command

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-merge-robot openshift-merge-robot merged commit c4d67a0 into openshift:master Jul 7, 2021
@wking wking deleted the channel-chooser branch July 7, 2021 19:11
wking added a commit to wking/openshift-docs that referenced this pull request Jul 27, 2021
I would prefer to configure this by clearing the 'upstream' setting,
which seems more intuitive for "there is no upstream" to me.  But
sadly, it seems that the CVO has been falling back to a default URI
when the ClusterVersion upstream is empty since way back [1,2], and
that this behavior is enshrined in the API [3].  Although the channel
docs also talk about defaults [4], the only channel defaulting in the
CVO is when creating a ClusterVersion object after the in-cluster copy
was (accidentally?)  deleted [5].  So maybe we could talk folks into
adjusting the CVO logic to return NoUpstream in the empty-upstream
case, but at the moment, clearing the channel is the best approach for
"the CVO keeps complaining that it can't hit the upstream, and I want
ot quiet it down [6]".

The 'oc adm upgrade channel' command just landed for 4.9 in [7].

[1]: https://github.com/openshift/cluster-version-operator/blame/2c4931dc283c551938be1a00fee290de0b79d99c/pkg/cvo/availableupdates.go#L27-L31
[2]: openshift/cluster-version-operator@ab4d84a#diff-78f2af341fa49292dd6930f378018867R24
[3]: https://github.com/openshift/api/blame/0422dc17083e9e8df18d029f3f34322e96e9c326/config/v1/types_cluster_version.go#L56-L57
[4]: https://github.com/openshift/api/blame/0422dc17083e9e8df18d029f3f34322e96e9c326/config/v1/types_cluster_version.go#L62-L63
[5]: https://github.com/openshift/cluster-version-operator/blob/2c4931dc283c551938be1a00fee290de0b79d99c/pkg/cvo/cvo.go#L602
[6]: https://bugzilla.redhat.com/show_bug.cgi?id=1827378
[7]: openshift/oc#576
openshift-cherrypick-robot pushed a commit to openshift-cherrypick-robot/openshift-docs that referenced this pull request Jul 27, 2021
I would prefer to configure this by clearing the 'upstream' setting,
which seems more intuitive for "there is no upstream" to me.  But
sadly, it seems that the CVO has been falling back to a default URI
when the ClusterVersion upstream is empty since way back [1,2], and
that this behavior is enshrined in the API [3].  Although the channel
docs also talk about defaults [4], the only channel defaulting in the
CVO is when creating a ClusterVersion object after the in-cluster copy
was (accidentally?)  deleted [5].  So maybe we could talk folks into
adjusting the CVO logic to return NoUpstream in the empty-upstream
case, but at the moment, clearing the channel is the best approach for
"the CVO keeps complaining that it can't hit the upstream, and I want
ot quiet it down [6]".

The 'oc adm upgrade channel' command just landed for 4.9 in [7].

[1]: https://github.com/openshift/cluster-version-operator/blame/2c4931dc283c551938be1a00fee290de0b79d99c/pkg/cvo/availableupdates.go#L27-L31
[2]: openshift/cluster-version-operator@ab4d84a#diff-78f2af341fa49292dd6930f378018867R24
[3]: https://github.com/openshift/api/blame/0422dc17083e9e8df18d029f3f34322e96e9c326/config/v1/types_cluster_version.go#L56-L57
[4]: https://github.com/openshift/api/blame/0422dc17083e9e8df18d029f3f34322e96e9c326/config/v1/types_cluster_version.go#L62-L63
[5]: https://github.com/openshift/cluster-version-operator/blob/2c4931dc283c551938be1a00fee290de0b79d99c/pkg/cvo/cvo.go#L602
[6]: https://bugzilla.redhat.com/show_bug.cgi?id=1827378
[7]: openshift/oc#576
emarcusRH pushed a commit to emarcusRH/openshift-docs that referenced this pull request Oct 28, 2021
I would prefer to configure this by clearing the 'upstream' setting,
which seems more intuitive for "there is no upstream" to me.  But
sadly, it seems that the CVO has been falling back to a default URI
when the ClusterVersion upstream is empty since way back [1,2], and
that this behavior is enshrined in the API [3].  Although the channel
docs also talk about defaults [4], the only channel defaulting in the
CVO is when creating a ClusterVersion object after the in-cluster copy
was (accidentally?)  deleted [5].  So maybe we could talk folks into
adjusting the CVO logic to return NoUpstream in the empty-upstream
case, but at the moment, clearing the channel is the best approach for
"the CVO keeps complaining that it can't hit the upstream, and I want
ot quiet it down [6]".

The 'oc adm upgrade channel' command just landed for 4.9 in [7].

[1]: https://github.com/openshift/cluster-version-operator/blame/2c4931dc283c551938be1a00fee290de0b79d99c/pkg/cvo/availableupdates.go#L27-L31
[2]: openshift/cluster-version-operator@ab4d84a#diff-78f2af341fa49292dd6930f378018867R24
[3]: https://github.com/openshift/api/blame/0422dc17083e9e8df18d029f3f34322e96e9c326/config/v1/types_cluster_version.go#L56-L57
[4]: https://github.com/openshift/api/blame/0422dc17083e9e8df18d029f3f34322e96e9c326/config/v1/types_cluster_version.go#L62-L63
[5]: https://github.com/openshift/cluster-version-operator/blob/2c4931dc283c551938be1a00fee290de0b79d99c/pkg/cvo/cvo.go#L602
[6]: https://bugzilla.redhat.com/show_bug.cgi?id=1827378
[7]: openshift/oc#576
wking added a commit to wking/oc that referenced this pull request Mar 16, 2022
Making it easier for folks to find the 'oc adm upgrade channel'
subcommand from 4b8f0fd (pkg/cli/admin/upgrade/channel: Add 'oc adm
upgrade channel ...', 2022-03-16, openshift#576), when they look at 'oc adm
--help'.
wking added a commit to wking/oc that referenced this pull request Mar 16, 2022
Making it easier for folks to find the 'oc adm upgrade channel'
subcommand from 4b8f0fd (pkg/cli/admin/upgrade/channel: Add 'oc adm
upgrade channel ...', 2022-03-16, openshift#576), when they look at 'oc adm
--help'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants