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

chore: Update devfile API dependency to current main branch #797

Merged
merged 2 commits into from
Mar 21, 2022
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export PROJECT_CLONE_IMG ?= quay.io/devfile/project-clone:next
export PULL_POLICY ?= Always
export DEFAULT_ROUTING ?= basic
export KUBECONFIG ?= ${HOME}/.kube/config
export DEVWORKSPACE_API_VERSION ?= 089a48011460cbd9f06f200bad5452137a25f34b
export DEVWORKSPACE_API_VERSION ?= 664e02df4202a8d4a9fdc30f25b445546e0c1acf

# Enable using Podman instead of Docker
export DOCKER ?= docker
Expand Down
201 changes: 193 additions & 8 deletions deploy/bundle/manifests/workspace.devfile.io_devworkspaces.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

537 changes: 521 additions & 16 deletions deploy/deployment/kubernetes/combined.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

537 changes: 521 additions & 16 deletions deploy/deployment/openshift/combined.yaml

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deploy/generate-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ if $USE_DEFAULT_ENV; then
export PROJECT_CLONE_IMG=${PROJECT_CLONE_IMG:-"quay.io/devfile/project-clone:next"}
export PULL_POLICY=Always
export DEFAULT_ROUTING=basic
export DEVWORKSPACE_API_VERSION=089a48011460cbd9f06f200bad5452137a25f34b
export DEVWORKSPACE_API_VERSION=664e02df4202a8d4a9fdc30f25b445546e0c1acf
export ROUTING_SUFFIX='""'
export FORCE_DEVWORKSPACE_CRDS_UPDATE=true
fi
Expand Down
18 changes: 0 additions & 18 deletions docs/additional-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,24 +122,6 @@ data:

Note: As for automatically mounting secrets, it is necessary to apply the `controller.devfile.io/watch-secret` label to git credentials secrets

## Applying labels and annotations to the workspace deployment
In some cases, it is useful to apply additional labels or annotations to the deployment that is created for a DevWorkspace. This is supported by setting attributes `controller.devfile.io/deployment-labels` and `controller.devfile.io/deployment-annotations` in the DevWorkspace's attributes field. The value of these attributes should be specified as a string map, as it is for regular metadata labels and annotations. For example:
```
kind: DevWorkspace
apiVersion: workspace.devfile.io/v1alpha2
metadata:
name: my-workspace
spec:
template:
attributes:
controller.devfile.io/deployment-labels:
my-label: foo
my-other-label: bar
controller.devfile.io/deployment-annotations:
my-attribute: foo
my-other-attribute: bar
```

## Debugging a failing workspace
Normally, when a workspace fails to start, the deployment will be scaled down and the workspace will be stopped in a `Failed` state. This can make it difficult to debug misconfiguration errors, so the annotation `controller.devfile.io/debug-start: "true"` can be applied to DevWorkspaces to leave resources for failed workspaces on the cluster. This allows viewing logs from workspace containers.

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/devfile/devworkspace-operator
go 1.16

require (
github.com/devfile/api/v2 v2.0.0-20210917193329-089a48011460
github.com/devfile/api/v2 v2.0.0-20220317194725-664e02df4202
github.com/go-git/go-git/v5 v5.2.0
github.com/go-logr/logr v0.4.0
github.com/google/go-cmp v0.5.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/daviddengcn/go-colortext v0.0.0-20160507010035-511bcaf42ccd/go.mod h1:dv4zxwHi5C/8AeI+4gX4dCWOIvNi7I6JCSX0HvlKPgE=
github.com/devfile/api/v2 v2.0.0-20210917193329-089a48011460 h1:cmd+3poyUwevcWchYdvE02YT1nQU4SJpA5/wrdLrpWE=
github.com/devfile/api/v2 v2.0.0-20210917193329-089a48011460/go.mod h1:kLX/nW93gigOHXK3NLeJL2fSS/sgEe+OHu8bo3aoOi4=
github.com/devfile/api/v2 v2.0.0-20220317194725-664e02df4202 h1:IbghWEZHOmoTnVp9J3AsVoOGheIxw9OVx6dg1FF2oQU=
github.com/devfile/api/v2 v2.0.0-20220317194725-664e02df4202/go.mod h1:kLX/nW93gigOHXK3NLeJL2fSS/sgEe+OHu8bo3aoOi4=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
Expand Down
8 changes: 0 additions & 8 deletions pkg/constants/attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ const (
// will not be cloned into the workspace on start.
ProjectCloneAttribute = "controller.devfile.io/project-clone"

// DeployLabelsAttribute is an DevWorkspace attribute used in .spec.attributes that defines additional labels
// that should be applied to the workspace deployment. Value should be a map[string]string
DeployLabelsAttribute = "controller.devfile.io/deployment-labels"

// DeployAnnotationsAttribute is an DevWorkspace attribute used in .spec.attributes that defines additional annotations
// that should be applied to the workspace deployment. Value should be a map[string]string
DeployAnnotationsAttribute = "controller.devfile.io/deployment-annotations"

// PluginSourceAttribute is an attribute added to components, commands, and projects in a flattened
// DevWorkspace representation to signify where the respective component came from (i.e. which plugin
// or parent imported it)
Expand Down
44 changes: 21 additions & 23 deletions pkg/provision/workspace/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,12 @@ func getSpecDeployment(
podAdditions.InitContainers[idx].VolumeMounts = append(podAdditions.InitContainers[idx].VolumeMounts, podAdditions.VolumeMounts...)
}

labels, annotations, err := getAdditionalLabelsAndAttributes(workspace)
if err != nil {
return nil, err
}
labels := map[string]string{}
labels[constants.DevWorkspaceIDLabel] = workspace.Status.DevWorkspaceId
labels[constants.DevWorkspaceNameLabel] = workspace.Name

annotations, err := getAdditionalAnnotations(workspace)

deployment := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: common.DeploymentName(workspace.Status.DevWorkspaceId),
Expand Down Expand Up @@ -460,6 +459,24 @@ func needsPVCWorkaround(podAdditions *v1alpha1.PodAdditions) (needs bool, pvcNam
return false, ""
}

func getAdditionalAnnotations(workspace *dw.DevWorkspace) (map[string]string, error) {
annotations := map[string]string{}

for _, component := range workspace.Spec.Template.Components {
if component.Container == nil || component.Container.Annotation == nil || component.Container.Annotation.Deployment == nil {
continue
}
for k, v := range component.Container.Annotation.Deployment {
if currValue, exists := annotations[k]; exists && v != currValue {
return nil, fmt.Errorf("conflicting annotations found on container components for key %s", k)
}
annotations[k] = v
}
}

return annotations, nil
}

func checkPodEvents(pod *corev1.Pod, workspaceID string, clusterAPI sync.ClusterAPI) (msg string, err error) {
evs := &corev1.EventList{}
selector, err := fields.ParseSelector(fmt.Sprintf("involvedObject.name=%s", pod.Name))
Expand Down Expand Up @@ -516,22 +533,3 @@ func checkIfUnrecoverableEventIgnored(reason string) (ignored bool) {
}
return false
}

// getAdditionalLabelsAndAttributes reads attributes on the DevWorkspace and returns the additional labels and
// attributes that should be applied to the DevWorkspace. Returns an error if attributes cannot be deserialized
// into a map[string]string. If attributes are not defined, returns an empty map.
func getAdditionalLabelsAndAttributes(workspace *dw.DevWorkspace) (labels, annotations map[string]string, err error) {
labels = map[string]string{}
annotations = map[string]string{}
if workspace.Spec.Template.Attributes.Exists(constants.DeployLabelsAttribute) {
if err := workspace.Spec.Template.Attributes.GetInto(constants.DeployLabelsAttribute, &labels); err != nil {
return nil, nil, fmt.Errorf("failed to process %s attribute: %w", constants.DeployLabelsAttribute, err)
}
}
if workspace.Spec.Template.Attributes.Exists(constants.DeployAnnotationsAttribute) {
if err := workspace.Spec.Template.Attributes.GetInto(constants.DeployAnnotationsAttribute, &annotations); err != nil {
return nil, nil, fmt.Errorf("failed to process %s attribute: %w", constants.DeployAnnotationsAttribute, err)
}
}
return labels, annotations, nil
}