Repository navigation
deal with excessive attempts on failing snapshots #13743
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package com.cloud.event.dao; | ||
|
|
||
| import com.cloud.event.Event; | ||
| import com.cloud.event.EventVO; | ||
| import com.cloud.utils.db.Filter; | ||
| import com.cloud.utils.db.SearchCriteria; | ||
| import org.junit.Assert; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import org.mockito.ArgumentCaptor; | ||
| import org.mockito.InjectMocks; | ||
| import org.mockito.Spy; | ||
| import org.mockito.junit.MockitoJUnitRunner; | ||
| import org.springframework.test.util.ReflectionTestUtils; | ||
|
|
||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.Mockito.doReturn; | ||
| import static org.mockito.Mockito.verify; | ||
|
|
||
| @RunWith(MockitoJUnitRunner.class) | ||
| public class EventDaoImplTest { | ||
|
|
||
| @Spy | ||
| @InjectMocks | ||
| EventDaoImpl eventDaoImpl = new EventDaoImpl(); | ||
|
|
||
| @Test | ||
| public void listLatestOutcomeEventsByResourceQueriesOutcomesByResourceAndTypeExcludingArchived() { | ||
| List<EventVO> expected = Collections.singletonList(new EventVO()); | ||
| doReturn(expected).when(eventDaoImpl).listBy(any(SearchCriteria.class), any(Filter.class)); | ||
|
|
||
| List<EventVO> result = eventDaoImpl.listLatestOutcomeEventsByResource(1L, "Volume", "SNAPSHOT.CREATE", 3); | ||
|
|
||
| Assert.assertSame(expected, result); | ||
|
|
||
| ArgumentCaptor<SearchCriteria> scCaptor = ArgumentCaptor.forClass(SearchCriteria.class); | ||
| ArgumentCaptor<Filter> filterCaptor = ArgumentCaptor.forClass(Filter.class); | ||
| verify(eventDaoImpl).listBy(scCaptor.capture(), filterCaptor.capture()); | ||
|
|
||
| SearchCriteria<EventVO> sc = scCaptor.getValue(); | ||
| String whereClause = sc.getWhereClause(); | ||
| for (String predicate : List.of("event.resource_id = ?", "event.resource_type = ?", "event.type = ?", "event.state IN (?,?)", "event.archived = ?")) { | ||
| Assert.assertTrue("missing predicate: " + predicate, whereClause.contains(predicate)); | ||
| } | ||
| @SuppressWarnings("unchecked") | ||
| Map<String, Object[]> params = (Map<String, Object[]>) ReflectionTestUtils.getField(sc, "_params"); | ||
| Assert.assertArrayEquals(new Object[]{1L}, params.get("resourceId")); | ||
| Assert.assertArrayEquals(new Object[]{"Volume"}, params.get("resourceType")); | ||
| Assert.assertArrayEquals(new Object[]{"SNAPSHOT.CREATE"}, params.get("type")); | ||
| Assert.assertArrayEquals(new Object[]{Event.State.Created, Event.State.Completed}, params.get("state")); | ||
| Assert.assertArrayEquals(new Object[]{false}, params.get("archived")); | ||
|
|
||
| Filter filter = filterCaptor.getValue(); | ||
| Assert.assertEquals(" ORDER BY event.created DESC , event.id DESC ", filter.getOrderBy()); | ||
| Assert.assertEquals(Long.valueOf(0L), filter.getOffset()); | ||
| Assert.assertEquals(Long.valueOf(3L), filter.getLimit()); | ||
| } | ||
|
|
||
| @Test | ||
| public void listLatestOutcomeEventsByResourceReturnsEmptyListWhenNoneFound() { | ||
| doReturn(Collections.emptyList()).when(eventDaoImpl).listBy(any(SearchCriteria.class), any(Filter.class)); | ||
|
|
||
| List<EventVO> result = eventDaoImpl.listLatestOutcomeEventsByResource(1L, "Volume", "SNAPSHOT.CREATE", 3); | ||
|
|
||
| Assert.assertTrue(result.isEmpty()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ | |
| // under the License. | ||
| package com.cloud.storage.snapshot; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import com.cloud.user.Account; | ||
| import com.cloud.hypervisor.Hypervisor; | ||
| import com.cloud.storage.StoragePool; | ||
|
|
@@ -53,6 +55,18 @@ public interface SnapshotManager extends Configurable { | |
| public static final ConfigKey<Integer> BackupRetryInterval = new ConfigKey<Integer>(Integer.class, "backup.retry.interval", "Advanced", "300", | ||
| "Time in seconds between retries in backing up snapshot to secondary", false, ConfigKey.Scope.Global, null); | ||
|
|
||
| ConfigKey<Integer> SnapshotRecurringMaxFailures = new ConfigKey<>(Integer.class, "snapshot.recurring.max.failures", "Snapshots", "3", | ||
| "Maximum number of consecutive failed attempts allowed for a recurring snapshot before it is left until its next regularly scheduled run and a failure event is logged. Set to 0 to retry indefinitely.", | ||
| true, List.of(ConfigKey.Scope.Account, ConfigKey.Scope.Domain, ConfigKey.Scope.Zone), null); | ||
|
|
||
| ConfigKey<Integer> SnapshotRecurringRetryInterval = new ConfigKey<>(Integer.class, "snapshot.recurring.retry.interval", "Snapshots", "300", | ||
| "Time in seconds to wait before retrying a failed recurring snapshot attempt.", | ||
| true, List.of(ConfigKey.Scope.Account, ConfigKey.Scope.Domain, ConfigKey.Scope.Zone), null); | ||
|
|
||
| ConfigKey<Boolean> SnapshotSkipIfVmNotRunning = new ConfigKey<>(Boolean.class, "snapshot.skip.if.vm.not.running", "Snapshots", "false", | ||
| "For recurring snapshots, skip taking a new snapshot of a volume (and log a skipped event instead) when the VM it is attached to has not been running since the last snapshot was taken, since nothing on the volume could have changed.", | ||
| true, List.of(ConfigKey.Scope.Account, ConfigKey.Scope.Domain, ConfigKey.Scope.Zone), null); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @DaanHoogland are these configs applicable for vmware / xen as well?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems so, pls confirm
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are for snapshots, not for any particular hypervisor. Should this matter? |
||
|
|
||
| public static final ConfigKey<Boolean> VmStorageSnapshotKvm = new ConfigKey<>(Boolean.class, "kvm.vmstoragesnapshot.enabled", "Snapshots", "true", "For live snapshot of virtual machine instance on KVM hypervisor without memory. Requires qemu version 1.6+ (on NFS or Local file system) and qemu-guest-agent installed on guest VM", true, ConfigKey.Scope.Global, null); | ||
|
|
||
| ConfigKey<Boolean> KVMSnapshotEnabled = new ConfigKey<>(Boolean.class, "kvm.snapshot.enabled", "Snapshots", "true", "Whether volume snapshot is enabled on running instances " + | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can reuse the same builder, for one or multiple values (with state check op.IN).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get your comment; two different fields are being checked (id and type)