mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 07:19:41 +02:00
feat(edge): kubernetes WaitForStatus support (#85)
This commit is contained in:
parent
fd2b00bf3b
commit
6bc52dd39c
6 changed files with 34 additions and 8 deletions
|
@ -113,7 +113,7 @@ func aggregateStatuses(services []service) (libstack.Status, string) {
|
|||
|
||||
}
|
||||
|
||||
func (wrapper *PluginWrapper) WaitForStatus(ctx context.Context, name string, status libstack.Status) <-chan libstack.WaitResult {
|
||||
func (wrapper *PluginWrapper) WaitForStatus(ctx context.Context, name string, status libstack.Status, _ string) <-chan libstack.WaitResult {
|
||||
waitResultCh := make(chan libstack.WaitResult)
|
||||
waitResult := libstack.WaitResult{
|
||||
Status: status,
|
||||
|
@ -200,6 +200,7 @@ func (wrapper *PluginWrapper) WaitForStatus(ctx context.Context, name string, st
|
|||
|
||||
log.Debug().
|
||||
Str("project_name", name).
|
||||
Str("required_status", string(status)).
|
||||
Str("status", string(aggregateStatus)).
|
||||
Msg("waiting for status")
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ func TestComposeProjectStatus(t *testing.T) {
|
|||
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
status, statusMessage, err := waitForStatus(w, ctx, projectName, libstack.StatusRunning)
|
||||
status, statusMessage, err := waitForStatus(w, ctx, projectName, libstack.StatusRunning, "")
|
||||
if err != nil {
|
||||
t.Fatalf("[test: %s] Failed to get compose project status: %v", testCase.TestName, err)
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ func TestComposeProjectStatus(t *testing.T) {
|
|||
|
||||
time.Sleep(20 * time.Second)
|
||||
|
||||
status, statusMessage, err = waitForStatus(w, ctx, projectName, libstack.StatusRemoved)
|
||||
status, statusMessage, err = waitForStatus(w, ctx, projectName, libstack.StatusRemoved, "")
|
||||
if err != nil {
|
||||
t.Fatalf("[test: %s] Failed to get compose project status: %v", testCase.TestName, err)
|
||||
}
|
||||
|
@ -102,11 +102,11 @@ func TestComposeProjectStatus(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func waitForStatus(deployer libstack.Deployer, ctx context.Context, stackName string, requiredStatus libstack.Status) (libstack.Status, string, error) {
|
||||
func waitForStatus(deployer libstack.Deployer, ctx context.Context, stackName string, requiredStatus libstack.Status, stackFileLocation string) (libstack.Status, string, error) {
|
||||
ctx, cancel := context.WithTimeout(ctx, 1*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
statusCh := deployer.WaitForStatus(ctx, stackName, requiredStatus)
|
||||
statusCh := deployer.WaitForStatus(ctx, stackName, requiredStatus, stackFileLocation)
|
||||
result := <-statusCh
|
||||
if result.ErrorMsg == "" {
|
||||
return result.Status, "", nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue