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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -215,7 +215,7 @@ func (r *DevWorkspaceReconciler) Reconcile(req ctrl.Request) (reconcileResult ct
reconcileStatus.Conditions[devworkspace.WorkspaceFailedStart] = fmt.Sprintf("Error processing devfile for Theia: %s", err)
return reconcile.Result{}, nil
}
reconcileStatus.Conditions[devworkspace.WorkspaceReady] = ""
reconcileStatus.Conditions[devworkspace.WorkspaceComponentsReady] = ""
timing.SetTime(timingInfo, timing.ComponentsReady)

// Only add che rest apis if Theia editor is present in the devfile
Expand Down
8 changes: 7 additions & 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 Expand Up @@ -63,6 +63,12 @@ func (r *DevWorkspaceReconciler) finalize(ctx context.Context, log logr.Logger,
if !hasFinalizer(workspace) {
return reconcile.Result{}, nil
}
workspace.Status.Message = "Cleaning up resources for deletion"
err := r.Client.Status().Update(ctx, workspace)
if err != nil && !k8sErrors.IsConflict(err) {
return reconcile.Result{}, err
}

// Need to make sure Deployment is cleaned up before starting job to avoid mounting issues for RWO PVCs
wait, err := provision.DeleteWorkspaceDeployment(ctx, workspace, r.Client)
if err != nil {
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
37 changes: 36 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,10 @@ 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)
if workspace.Status.Message != infoMessage {
workspace.Status.Message = infoMessage
}

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

func getInfoMessage(workspace *devworkspace.DevWorkspace, conditions map[devworkspace.WorkspaceConditionType]string) string {
// Check for errors and failure
if msg, ok := conditions[devworkspace.WorkspaceError]; ok {
return msg
}
if msg, ok := conditions[devworkspace.WorkspaceFailedStart]; ok {
return msg
}
switch workspace.Status.Phase {
case devworkspace.WorkspaceStatusRunning:
return workspace.Status.IdeUrl
case devworkspace.WorkspaceStatusStopped, devworkspace.WorkspaceStatusStopping:
return string(workspace.Status.Phase)
}

// Check for progress
if _, ok := conditions[devworkspace.WorkspaceReady]; ok {
return "Waiting on editor to start"
}
if _, ok := conditions[devworkspace.WorkspaceServiceAccountReady]; ok {
return "Waiting for deployment to be ready"
}
if _, ok := conditions[devworkspace.WorkspaceRoutingReady]; ok {
return "Waiting for workspace serviceaccount"
}
if _, ok := conditions[devworkspace.WorkspaceComponentsReady]; ok {
return "Waiting for workspace routing objects"
}
return "Processing DevWorkspace components"
}
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