-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Skip module updates requiring maintenance windows when not acti…
…ve (#2206) * feat: Skip module updates requiring maintenance windows when no such active * fix linting * fix mw e2e-test setup * fix e2e test label * configure MW Resolving to use ongoing windows with at least 20 min duration * fix e2e test region label * fix linting * extend e2e test * fix linting * fix e2e test * return not found error * fix tests * add e2e test for regular modules * fix channel * don't wait for image rebuild * fix channel switch * only support MRM scenarios * fix tests * fix e2e test ++ * fix e2e tests * fix e2e test * fix e2e test * fix e2e test * fix e2e test * split to seperate tests * fix if * fix test prep * adapt test naming * align test names * fix channel in initial installation * test change * fix test names * fix setup * fix lint * revert to wait image build
- Loading branch information
Showing
16 changed files
with
717 additions
and
99 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
71 changes: 71 additions & 0 deletions
71
pkg/templatelookup/moduletemplateinfolookup/with_maintenance_window_decorator.go
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,71 @@ | ||
package moduletemplateinfolookup | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/kyma-project/lifecycle-manager/api/v1beta2" | ||
"github.com/kyma-project/lifecycle-manager/pkg/templatelookup" | ||
) | ||
|
||
var ( | ||
ErrWaitingForNextMaintenanceWindow = errors.New("waiting for next maintenance window to update module version") | ||
ErrFailedToDetermineIfMaintenanceWindowIsActive = errors.New("failed to determine if maintenance window is active") | ||
) | ||
|
||
type MaintenanceWindow interface { | ||
IsRequired(moduleTemplate *v1beta2.ModuleTemplate, kyma *v1beta2.Kyma) bool | ||
IsActive(kyma *v1beta2.Kyma) (bool, error) | ||
} | ||
|
||
type WithMaintenanceWindowDecorator struct { | ||
maintenanceWindow MaintenanceWindow | ||
decorated ModuleTemplateInfoLookupStrategy | ||
} | ||
|
||
func NewWithMaintenanceWindowDecorator(maintenanceWindow MaintenanceWindow, decorated ModuleTemplateInfoLookupStrategy) WithMaintenanceWindowDecorator { | ||
return WithMaintenanceWindowDecorator{ | ||
maintenanceWindow: maintenanceWindow, | ||
decorated: decorated, | ||
} | ||
} | ||
|
||
func (p WithMaintenanceWindowDecorator) IsResponsible(moduleInfo *templatelookup.ModuleInfo, moduleReleaseMeta *v1beta2.ModuleReleaseMeta) bool { | ||
return p.decorated.IsResponsible(moduleInfo, moduleReleaseMeta) | ||
} | ||
|
||
func (p WithMaintenanceWindowDecorator) Lookup(ctx context.Context, | ||
moduleInfo *templatelookup.ModuleInfo, | ||
kyma *v1beta2.Kyma, | ||
moduleReleaseMeta *v1beta2.ModuleReleaseMeta, | ||
) templatelookup.ModuleTemplateInfo { | ||
moduleTemplateInfo := p.decorated.Lookup(ctx, | ||
moduleInfo, | ||
kyma, | ||
moduleReleaseMeta) | ||
|
||
// decorated returns an error case => return immediately | ||
if moduleTemplateInfo.ModuleTemplate == nil || moduleTemplateInfo.Err != nil { | ||
return moduleTemplateInfo | ||
} | ||
|
||
if !p.maintenanceWindow.IsRequired(moduleTemplateInfo.ModuleTemplate, kyma) { | ||
return moduleTemplateInfo | ||
} | ||
|
||
active, err := p.maintenanceWindow.IsActive(kyma) | ||
if err != nil { | ||
moduleTemplateInfo.Err = fmt.Errorf("%w: %w", ErrFailedToDetermineIfMaintenanceWindowIsActive, err) | ||
moduleTemplateInfo.ModuleTemplate = nil | ||
return moduleTemplateInfo | ||
} | ||
|
||
if !active { | ||
moduleTemplateInfo.Err = ErrWaitingForNextMaintenanceWindow | ||
moduleTemplateInfo.ModuleTemplate = nil | ||
return moduleTemplateInfo | ||
} | ||
|
||
return moduleTemplateInfo | ||
} |
Oops, something went wrong.