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

Consider maintenance window when migrating master pods #2810

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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 pkg/cluster/majorversionupgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (c *Cluster) majorVersionUpgrade() error {
return nil
}

if !isInMainternanceWindow(c.Spec.MaintenanceWindows) {
if !IsInMainternanceWindow(c.Spec.MaintenanceWindows) {
c.logger.Infof("skipping major version upgrade, not in maintenance window")
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ func parseResourceRequirements(resourcesRequirement v1.ResourceRequirements) (ac
return resources, nil
}

func isInMainternanceWindow(specMaintenanceWindows []acidv1.MaintenanceWindow) bool {
func IsInMainternanceWindow(specMaintenanceWindows []acidv1.MaintenanceWindow) bool {
if len(specMaintenanceWindows) == 0 {
return true
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cluster/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ func TestIsInMaintenanceWindow(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
cluster.Spec.MaintenanceWindows = tt.windows
if isInMainternanceWindow(cluster.Spec.MaintenanceWindows) != tt.expected {
if IsInMainternanceWindow(cluster.Spec.MaintenanceWindows) != tt.expected {
t.Errorf("Expected isInMainternanceWindow to return %t", tt.expected)
}
})
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ func (c *Controller) attemptToMoveMasterPodsOffNode(node *v1.Node) error {
for pod, cl := range masterPods {
podName := util.NameFromMeta(pod.ObjectMeta)

if !cluster.IsInMainternanceWindow(cl.Spec.MaintenanceWindows) {
c.logger.Infof("skipping master pod migration, not in maintenance window")
continue
}

if err := cl.MigrateMasterPod(podName); err != nil {
c.logger.Errorf("could not move master pod %q: %v", podName, err)
} else {
Expand Down
Loading