Skip to content

Commit

Permalink
Avoid waiting 5 seconds for image pull secret on every k8s start
Browse files Browse the repository at this point in the history
Recent versions of Kubernetes do not automatically mount image pull
secrets to serviceaccounts, meaning that most workspace starts idle for
5 seconds waiting for something that is not going to happen. Instead we
scope the check for waiting for image pull secrets to only be performed
when running on OpenShift.

On OpenShift, there is a race between the controller and the cluster
API, where sometimes DWO creates a deployment that is immediately
updated with image pull secrets, slowing workspace start due to the
workspace pod needing to terminate.

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
  • Loading branch information
amisevsk committed Oct 28, 2022
1 parent 0593432 commit ac68a57
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions pkg/provision/workspace/pull_secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strings"
"time"

"github.com/devfile/devworkspace-operator/pkg/infrastructure"
"github.com/devfile/devworkspace-operator/pkg/provision/sync"
"k8s.io/apimachinery/pkg/types"

Expand Down Expand Up @@ -80,12 +81,14 @@ func PullSecrets(clusterAPI sync.ClusterAPI, serviceAccountName, namespace strin
}
}

if len(serviceAccount.ImagePullSecrets) == 0 && serviceAccount.CreationTimestamp.Add(pullSecretCreationTimeout).After(time.Now()) {
return PullSecretsProvisioningStatus{
ProvisioningStatus: ProvisioningStatus{
Requeue: true,
Message: "Waiting for image pull secrets",
},
if infrastructure.IsOpenShift() {
if len(serviceAccount.ImagePullSecrets) == 0 && serviceAccount.CreationTimestamp.Add(pullSecretCreationTimeout).After(time.Now()) {
return PullSecretsProvisioningStatus{
ProvisioningStatus: ProvisioningStatus{
Requeue: true,
Message: "Waiting for image pull secrets",
},
}
}
}

Expand Down

0 comments on commit ac68a57

Please sign in to comment.