Skip to content

Commit

Permalink
Revert "istioctl: fix istioctl operator remove fail when a revision w…
Browse files Browse the repository at this point in the history
…as not specified (istio#42160)" (istio#42500)

This reverts commit defc1cb.
  • Loading branch information
zirain authored Dec 17, 2022
1 parent 8fed2d5 commit b0ea177
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 44 deletions.
2 changes: 1 addition & 1 deletion operator/cmd/mesh/operator-common.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const (
// isControllerInstalled reports whether an operator deployment exists in the given namespace.
func isControllerInstalled(cs kubernetes.Interface, operatorNamespace string, revision string) (bool, error) {
orn := operatorResourceName
if revision != "" && revision != "default" {
if revision != "" {
orn += "-" + revision
}
return deploymentExists(cs, operatorNamespace, orn)
Expand Down
4 changes: 0 additions & 4 deletions operator/cmd/mesh/operator-init.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ func operatorInit(args *RootArgs, oiArgs *operatorInitArgs, l clog.Logger) {
if err != nil {
l.LogAndFatal(err)
}

if oiArgs.common.revision == "default" {
oiArgs.common.revision = ""
}
// Error here likely indicates Deployment is missing. If some other K8s error, we will hit it again later.
already, _ := isControllerInstalled(kubeClient.Kube(), oiArgs.common.operatorNamespace, oiArgs.common.revision)
if already {
Expand Down
8 changes: 0 additions & 8 deletions releasenotes/notes/42160.yaml

This file was deleted.

35 changes: 4 additions & 31 deletions tests/integration/operator/switch_cr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,53 +113,26 @@ func TestController(t *testing.T) {
"--manifests=" + ManifestPath,
"--revision=" + "v2",
}
// install other operator deployment with different revision
// install second operator deployment with different revision
istioCtl.InvokeOrFail(t, initCmd)
t.TrackResource(&operatorDumper{rev: "v2"})
installWithCRFile(t, t, cs, istioCtl, "default", "v2")
installWithCRFile(t, t, cs, istioCtl, "default", "")
installWithCRFile(t, t, cs, istioCtl, "default", "v3")
installWithCRFile(t, t, cs, istioCtl, "default", "v4")

// istio control plane resources expected to be deleted after deleting CRs
cleanupInClusterCRs(t, cs)

// test operator remove command
scopes.Framework.Infof("checking operator remove command by revision")
removeCmddefault := []string{
"operator", "remove",
"--skip-confirmation",
}
istioCtl.InvokeOrFail(t, removeCmddefault)

removeCmdv2 := []string{
"operator", "remove",
"--skip-confirmation",
"--revision", "v2",
}
istioCtl.InvokeOrFail(t, removeCmdv2)

retry.UntilSuccessOrFail(t, func() error {
for _, n := range []string{"istio-operator", "istio-operator-v2"} {
if svc, _ := cs.Kube().CoreV1().Services(OperatorNamespace).Get(context.TODO(), n, metav1.GetOptions{}); svc.Name != "" {
return fmt.Errorf("got operator service: %s from cluster, expected to be removed", svc.Name)
}
if dp, _ := cs.Kube().AppsV1().Deployments(OperatorNamespace).Get(context.TODO(), n, metav1.GetOptions{}); dp.Name != "" {
return fmt.Errorf("got operator deployment %s from cluster, expected to be removed", dp.Name)
}
}
return nil
}, retry.Timeout(retryTimeOut), retry.Delay(retryDelay))

scopes.Framework.Infof("checking operator remove command by purge")
scopes.Framework.Infof("checking operator remove command")
removeCmd := []string{
"operator", "remove",
"--skip-confirmation",
"--purge",
}
istioCtl.InvokeOrFail(t, removeCmd)

retry.UntilSuccessOrFail(t, func() error {
for _, n := range []string{"istio-operator-v3", "istio-operator-v4"} {
for _, n := range []string{"istio-operator", "istio-operator-v2"} {
if svc, _ := cs.Kube().CoreV1().Services(OperatorNamespace).Get(context.TODO(), n, metav1.GetOptions{}); svc.Name != "" {
return fmt.Errorf("got operator service: %s from cluster, expected to be removed", svc.Name)
}
Expand Down

0 comments on commit b0ea177

Please sign in to comment.