Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make okteto up wait until original resource is awaken before starting…
… dev container (#3368) * Changes in the up command to wake the namespace up (if it is sleeping and it is an okteto context) and wait until the annotation dev.okteto.com/state-before-sleeping is not present in the original deployment before deploying the dev container Signed-off-by: Ignacio Fuertes <nacho@okteto.com> * Execute wake call within a goroutine, extracted status label to a constant and include some logic to wait the the deployment is already in dev mode but the namespace is sleeping Signed-off-by: Ignacio Fuertes <nacho@okteto.com> * If the dev container is an autocreate, we don't need to wait until it is up Signed-off-by: Ignacio Fuertes <nacho@okteto.com> * Addressed code review comments. Some renames, stop timers properly and print a warning instead of returning an error if the resource is not awaken after the timeout Signed-off-by: Ignacio Fuertes <nacho@okteto.com> --------- Signed-off-by: Ignacio Fuertes <nacho@okteto.com>
- Loading branch information
Showing
17 changed files
with
327 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package apps | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/okteto/okteto/pkg/okteto" | ||
"github.com/stretchr/testify/require" | ||
appsv1 "k8s.io/api/apps/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/kubernetes/fake" | ||
) | ||
|
||
func TestDeploymentGetDevCloneWithError(t *testing.T) { | ||
d := &appsv1.Deployment{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "test", | ||
Namespace: "test", | ||
}, | ||
} | ||
app := DeploymentApp{kind: okteto.Deployment, d: d} | ||
c := fake.NewSimpleClientset() | ||
ctx := context.Background() | ||
|
||
_, err := app.GetDevClone(ctx, c) | ||
|
||
require.Error(t, err) | ||
} | ||
|
||
func TestDeploymentGetDevCloneWithoutError(t *testing.T) { | ||
d := &appsv1.Deployment{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "test", | ||
Namespace: "test", | ||
}, | ||
} | ||
|
||
cloned := &appsv1.Deployment{ | ||
ObjectMeta: metav1.ObjectMeta{ | ||
Name: "test-okteto", | ||
Namespace: "test", | ||
Labels: map[string]string{ | ||
"dev.okteto.com/clone": "true", | ||
}, | ||
}, | ||
} | ||
|
||
app := DeploymentApp{kind: okteto.Deployment, d: d} | ||
c := fake.NewSimpleClientset(cloned) | ||
ctx := context.Background() | ||
expected := &DeploymentApp{kind: okteto.Deployment, d: cloned} | ||
|
||
result, err := app.GetDevClone(ctx, c) | ||
|
||
require.NoError(t, err) | ||
require.Equal(t, expected, result) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.