Skip to content

Update devfile/api dependency and message with info about failures #270

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

Merged
merged 10 commits into from
Feb 22, 2021
Merged
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export ROUTING_SUFFIX ?= 192.168.99.100.nip.io
export PULL_POLICY ?= Always
export DEFAULT_ROUTING ?= basic
export KUBECONFIG ?= ${HOME}/.kube/config
export DEVWORKSPACE_API_VERSION ?= aeda60d4361911da85103f224644bfa792498499
export DEVWORKSPACE_API_VERSION ?= 283b0c54946e9fea9872c25e1e086c303688f0e8

#internal params
DEVWORKSPACE_CTRL_SA=devworkspace-controller-serviceaccount
Expand Down Expand Up @@ -110,7 +110,7 @@ endif
##### Rules for dealing with devfile/api
### update_devworkspace_api: update version of devworkspace crds in go.mod
update_devworkspace_api:
go mod edit --require github.com/devfile/api@$(DEVWORKSPACE_API_VERSION)
go mod edit --require github.com/devfile/api/v2@$(DEVWORKSPACE_API_VERSION)
go mod download
go mod tidy

Expand Down
2 changes: 1 addition & 1 deletion apis/controller/v1alpha1/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package v1alpha1

import (
devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
)

// Description of a devfile component's workspace additions
Expand Down
2 changes: 1 addition & 1 deletion apis/controller/v1alpha1/component_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package v1alpha1

import (
devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion apis/controller/v1alpha1/workspacerouting_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package v1alpha1

import (
devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion apis/controller/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

"github.com/devfile/devworkspace-operator/pkg/common"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
controllerv1alpha1 "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
"github.com/devfile/devworkspace-operator/pkg/config"
corev1 "k8s.io/api/core/v1"
Expand Down
4 changes: 2 additions & 2 deletions controllers/controller/workspacerouting/solvers/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
package solvers

import (
"github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
controllerv1alpha1 "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
"github.com/devfile/devworkspace-operator/pkg/common"
"github.com/devfile/devworkspace-operator/pkg/config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
maputils "github.com/devfile/devworkspace-operator/internal/map"
"sigs.k8s.io/controller-runtime/pkg/client"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
controllerv1alpha1 "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
"github.com/devfile/devworkspace-operator/pkg/common"
"github.com/devfile/devworkspace-operator/pkg/config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"net/url"
"strings"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
controllerv1alpha1 "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
"github.com/devfile/devworkspace-operator/pkg/config"
)
Expand Down
2 changes: 1 addition & 1 deletion controllers/workspace/devworkspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
)

type currentStatus struct {
Expand Down
2 changes: 1 addition & 1 deletion controllers/workspace/finalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

storagelib "github.com/devfile/devworkspace-operator/pkg/library/storage"

"github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/devworkspace-operator/controllers/workspace/provision"
"github.com/devfile/devworkspace-operator/internal/images"
"github.com/devfile/devworkspace-operator/pkg/common"
Expand Down
2 changes: 1 addition & 1 deletion controllers/workspace/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package controllers

import (
"github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"k8s.io/apimachinery/pkg/api/equality"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/predicate"
Expand Down
2 changes: 1 addition & 1 deletion controllers/workspace/provision/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (

"github.com/devfile/devworkspace-operator/pkg/common"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
"github.com/devfile/devworkspace-operator/controllers/workspace/env"
"github.com/devfile/devworkspace-operator/pkg/config"
Expand Down
2 changes: 1 addition & 1 deletion controllers/workspace/provision/pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package provision

import (
devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/devworkspace-operator/pkg/config"
"github.com/go-logr/logr"
corev1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion controllers/workspace/provision/rbac.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package provision

import (
devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/devworkspace-operator/pkg/config"
"github.com/go-logr/logr"
rbacv1 "k8s.io/api/rbac/v1"
Expand Down
2 changes: 1 addition & 1 deletion controllers/workspace/provision/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"fmt"
"strings"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
maputils "github.com/devfile/devworkspace-operator/internal/map"
"github.com/devfile/devworkspace-operator/pkg/config"
Expand Down
2 changes: 1 addition & 1 deletion controllers/workspace/provision/serviceaccount.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package provision
import (
"context"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/devworkspace-operator/pkg/common"
"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1"
Expand Down
2 changes: 1 addition & 1 deletion controllers/workspace/restapis/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package restapis
import (
"strings"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
controllerv1alpha1 "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
"github.com/devfile/devworkspace-operator/pkg/common"
"github.com/devfile/devworkspace-operator/pkg/config"
Expand Down
2 changes: 1 addition & 1 deletion controllers/workspace/restapis/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"context"
"encoding/json"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
"github.com/devfile/devworkspace-operator/controllers/workspace/provision"
"github.com/devfile/devworkspace-operator/pkg/common"
Expand Down
2 changes: 1 addition & 1 deletion controllers/workspace/restapis/devfilev1.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"path"
"strings"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
workspaceApi "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
"github.com/devfile/devworkspace-operator/pkg/config"
)
Expand Down
21 changes: 20 additions & 1 deletion controllers/workspace/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/go-logr/logr"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
"github.com/devfile/devworkspace-operator/controllers/workspace/provision"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -79,6 +79,8 @@ func (r *DevWorkspaceReconciler) updateWorkspaceStatus(workspace *devworkspace.D
sort.SliceStable(workspace.Status.Conditions, func(i, j int) bool {
return strings.Compare(string(workspace.Status.Conditions[i].Type), string(workspace.Status.Conditions[j].Type)) > 0
})
infoMessage := getInfoMessage(workspace, status.Conditions)
workspace.Status.Message = infoMessage

err := r.Status().Update(context.TODO(), workspace)
if err != nil {
Expand Down Expand Up @@ -138,3 +140,20 @@ func getIdeUrl(exposedEndpoints map[string]v1alpha1.ExposedEndpointList) string
}
return ""
}

func getInfoMessage(workspace *devworkspace.DevWorkspace, conditions map[devworkspace.WorkspaceConditionType]string) string {
var failedStartMsg string
for conditionType, conditionMessage := range conditions {
switch conditionType {
// Take error condition message as overriding failed start message
case devworkspace.WorkspaceError:
return conditionMessage
case devworkspace.WorkspaceFailedStart:
failedStartMsg = conditionMessage
}
}
if failedStartMsg != "" {
return failedStartMsg
}
return workspace.Status.IdeUrl
Copy link
Member

Choose a reason for hiding this comment

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

Should we return IdeURL when it's not ready yet?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's what we currently do -- personally I like it because I can copy it and refresh a few times to load a workspace, rather than repeatedly using kubectl get, but I'm happy to do it either way (and with your suggestion above of reporting latest condition, it makes sense to not put ideURL until it's started anyways)

Copy link
Member

Choose a reason for hiding this comment

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

Probably it's another issue, but I saw we return outdated URL, after routing class is changed but workspace is stopped.

and with proposal to report the latest condition, I just wondered how we can avoid confusion we got when workspace is started but not started, because Che Routing is not available yet.

There we may also report finalizing a workspace, currently the way is to check removal timestamp )

}
2 changes: 1 addition & 1 deletion controllers/workspace/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ package controllers
import (
"fmt"

devworkspace "github.com/devfile/api/pkg/apis/workspaces/v1alpha2"
devworkspace "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
"github.com/devfile/devworkspace-operator/pkg/config"
"github.com/devfile/devworkspace-operator/pkg/webhook"
)
Expand Down
Loading