Snapshot lookup by zone ignores the zone in its fallback (stray semicolon)

Offen Anfängerfreundlich
#14,770 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
78/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
java
Bereich
backend

Rechercherichtung

Der Fehler liegt in SnapshotDataFactoryImpl.getSnapshot(snapshotId, role, zoneId, retrieveAnySnapshotFromVolume), erreicht über getSnapshotWithRoleAndZone. Beginne bei der Fallback-Schleife, wo ein überflüssiges ; nach dem if bei storeMgr.getStoreZoneId(...) die Zonenprüfung wirkungslos macht, und bei dem Vergleich long == Long in beiden Schleifen. Fertig ist es, wenn der Fallback nur eine Kopie in der angeforderten Zone zurückgibt, sonst null, und der Vergleich null-sicher ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

problem

SnapshotDataFactoryImpl.getSnapshot(snapshotId, role, zoneId, retrieveAnySnapshotFromVolume) (used by getSnapshotWithRoleAndZone) has a stray ; in its fallback loop:

if (zoneId == storeMgr.getStoreZoneId(ref.getDataStoreId(), ref.getRole())); {
    snapshotStore = ref;
    break;
}
Effect
fallback loop the if is a no-op, so the first copy of the snapshot from any zone is returned
both loops long == Long unboxes; if getStoreZoneId returns null (it does when the primary pool lookup throws) this is an NPE

Came in with #7873. Present on 4.22 and main.

versions

4.19 onward, 4.22, main.

The steps to reproduce the bug
  1. Have a snapshot whose only copy is in zone A.
  2. Call anything that looks it up with getSnapshotWithRoleAndZone(id, role, zoneB).
  3. The zone A copy is returned instead of null.
What to do about it?

Remove the ; and compare null-safely in both loops.

Vorherrschende Sprache
Java
Sterne
3.1k
Forks
1.4k
Ø Merge
6 T. 18 Std.
Gemergte PRs (30 T.)
11

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus apache/cloudstack

Alle Issues in apache/cloudstack

Ähnliche Issues

Weitere Issues zu Java

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.