Skip to content

Commit

Permalink
fix: [OS-371] Nsi provisioning hotfix (#491)
Browse files Browse the repository at this point in the history
* NSI provisioning fix; remove RANCID

* Further provisioning fix

* update pom
  • Loading branch information
haniotak authored Oct 29, 2024
1 parent 4036282 commit 95b153d
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 550 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
# OSCARS Release Notes
### 1.2.15
> Oct 2024
- NSI modify hotfix
- remove RANCID code


### 1.2.14
> Oct 2024
- NSI modify fix
Expand Down
3 changes: 0 additions & 3 deletions backend/config/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ pss.config-timeout-sec=180
pss.server-type=stub
pss.sync-from-after-legacy-dismantle=false

spring.ssl.bundle.jks.pss.truststore.location=classpath:config/oscars.jks
spring.ssl.bundle.jks.pss.truststore.password=changeit

pce.engine=yenk
#pce.engine=allpaths
pce.timeout=5
Expand Down
2 changes: 1 addition & 1 deletion backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<groupId>net.es.oscars</groupId>
<artifactId>backend</artifactId>
<name>backend</name>
<version>1.2.14</version>
<version>1.2.15</version>

<description>OSCARS backend</description>
<properties>
Expand Down
3 changes: 2 additions & 1 deletion backend/src/main/java/net/es/oscars/nsi/beans/NsiModify.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Builder
public class NsiModify {
public String nsiConnectionId;
public Instant revertTime;
public Instant timeout;
public Spec initial;
private Spec modified;

Expand All @@ -19,5 +19,6 @@ public static class Spec {
Instant beginning;
Instant ending;
int bandwidth;
int dataplaneVersion;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void commit(String nsiConnectionId) {
public List<NsiModify> timedOut() {
List<NsiModify> result = new ArrayList<>();
for (NsiModify modify : inFlightModifies.values()) {
if (modify.getRevertTime().isAfter(Instant.now())) {
if (modify.getTimeout().isBefore(Instant.now())) {
result.add(modify);
}
}
Expand Down
49 changes: 39 additions & 10 deletions backend/src/main/java/net/es/oscars/nsi/svc/NsiService.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ public void reserve(CommonHeaderType header, ReserveType rt, NsiMapping mapping)
log.info("ending reserve");
});
}
public void modify(CommonHeaderType header, ReserveType rt, NsiMapping mapping) {

public void modify(CommonHeaderType header, ReserveType rt, NsiMapping mapping, int newVersion) {
Executors.newCachedThreadPool().submit(() -> {
log.info("starting modify task");
DevelUtils.dumpDebug("modifyRT", rt);
Expand All @@ -197,6 +198,7 @@ public void modify(CommonHeaderType header, ReserveType rt, NsiMapping mapping)

Instant initialBeginning = c.getReserved().getSchedule().getBeginning();
Instant initialEnding = c.getReserved().getSchedule().getEnding();
int initialDataplaneVersion = mapping.getDataplaneVersion();

int initialBandwidth = 0;
for (VlanFixture f : c.getReserved().getCmp().getFixtures()) {
Expand Down Expand Up @@ -235,8 +237,8 @@ public void modify(CommonHeaderType header, ReserveType rt, NsiMapping mapping)
newEnding = xet.toGregorianCalendar().toInstant();
}

// we increment the dataplane version
mapping.setDataplaneVersion(mapping.getDataplaneVersion() + 1);
// we update the dataplane version
mapping.setDataplaneVersion(newVersion);
nsiRepo.save(mapping);

Validity v = connSvc.modifyNsi(c, newBandwidth, newBeginning, newEnding);
Expand Down Expand Up @@ -268,13 +270,15 @@ public void modify(CommonHeaderType header, ReserveType rt, NsiMapping mapping)
.bandwidth(initialBandwidth)
.beginning(initialBeginning)
.ending(initialEnding)
.dataplaneVersion(initialDataplaneVersion)
.build())
.modified(NsiModify.Spec.builder()
.bandwidth(newBandwidth)
.beginning(newBeginning)
.ending(newEnding)
.dataplaneVersion(newVersion)
.build())
.revertTime(timeout)
.timeout(timeout)
.nsiConnectionId(mapping.getNsiConnectionId())
.build();

Expand Down Expand Up @@ -319,21 +323,31 @@ public void modify(CommonHeaderType header, ReserveType rt, NsiMapping mapping)
public void commit(CommonHeaderType header, NsiMapping mapping) {

Executors.newCachedThreadPool().submit(() -> {
log.info("starting commit task");
log.info("starting commit for "+mapping.getNsiConnectionId());
try {
nsiStateEngine.commit(NsiEvent.COMMIT_START, mapping);
Connection c = nsiConnectionAccess.getOscarsConnection(mapping);

// The commit could be either a commit for the initial commit flow or it can
// be for an in-flight modify.

//
if (nsiRequestManager.getInFlightModify(mapping.getNsiConnectionId()) == null) {
log.info("commit for initial reserve");
if (!c.getPhase().equals(Phase.HELD)) {
throw new NsiException("Invalid connection phase", NsiErrors.TRANS_ERROR);
}
connSvc.commit(c);

} else {
// tell the request manager that this committed OK
log.info("committing modify " + mapping.getNsiConnectionId());

NsiModify modify = nsiRequestManager.getInFlightModify(mapping.getNsiConnectionId());
mapping.setDataplaneVersion(modify.getModified().getDataplaneVersion());
nsiRepo.save(mapping);
log.info("new dataplane version " + mapping.getDataplaneVersion());

nsiRequestManager.commit(mapping.getNsiConnectionId());
}

Expand All @@ -346,7 +360,7 @@ public void commit(CommonHeaderType header, NsiMapping mapping) {
} catch (WebServiceException | ServiceException ex) {
log.error("commit confirmed callback failed", ex);
}
} catch ( PCEException | NsiException ex) {
} catch (PCEException | NsiException ex) {
log.error("failed commit");
log.error(ex.getMessage(), ex);
try {
Expand Down Expand Up @@ -509,7 +523,22 @@ public void terminate(CommonHeaderType header, NsiMapping mapping) {

public void rollbackModify(NsiMapping mapping) {
log.info("modify timed out for " + mapping.getNsiConnectionId() + " " + mapping.getOscarsConnectionId());
this.resvTimedOut(mapping);
NsiModify modify = nsiRequestManager.getInFlightModify(mapping.getNsiConnectionId());

Connection c = connSvc.findConnection(mapping.getOscarsConnectionId());


try {
log.info("rolling back modify " + mapping.getNsiConnectionId() + " " + mapping.getOscarsConnectionId());
connSvc.modifyNsi(c, modify.getInitial().getBandwidth(), modify.getInitial().getBeginning(), modify.getInitial().getEnding());
} catch (ModifyException ex) {
log.error("Internal error: " + ex.getMessage(), ex);
} finally {
mapping.setDataplaneVersion(modify.getInitial().getDataplaneVersion());
nsiRepo.save(mapping);
this.resvTimedOut(mapping);
}

}

// currently unused
Expand Down Expand Up @@ -947,7 +976,7 @@ public List<Pipe> pipesFor(Interval interval, Integer mbps,
include.add(0, junctions.get(0).getDevice());
}
// last element of ero should be the last device.
if (!include.get(include.size()-1).equals(junctions.get(1).getDevice())) {
if (!include.get(include.size() - 1).equals(junctions.get(1).getDevice())) {
include.add(junctions.get(1).getDevice());
}

Expand Down Expand Up @@ -1542,12 +1571,13 @@ public ScheduleType oscarsToNsiSchedule(Schedule sch) throws NsiException {
return st;

}

public Long getModifyCapacity(ReserveType rt) throws NsiException {
ReservationRequestCriteriaType crit = rt.getCriteria();
Long result = null;
for (Object obj : crit.getAny()) {
if (result == null) {
if (obj instanceof @SuppressWarnings("rawtypes") JAXBElement jaxb) {
if (obj instanceof @SuppressWarnings("rawtypes")JAXBElement jaxb) {
if (jaxb.getDeclaredType() == Long.class) {
result = ((Long) jaxb.getValue());
if (jaxb.getName().toString().equals("{http://schemas.ogf.org/nsi/2013/12/services/point2point}capacity")) {
Expand Down Expand Up @@ -1595,7 +1625,6 @@ public P2PServiceBaseType getP2PService(ReserveType rt) throws NsiException {
/* db funcs */



public NsiMapping getMapping(String nsiConnectionId) throws NsiException {
if (nsiConnectionId == null || nsiConnectionId.isEmpty()) {
throw new NsiException("null or blank connection id! " + nsiConnectionId, NsiErrors.MISSING_PARAM_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,14 @@ public void reserve(NsiEvent event, NsiMapping mapping) throws NsiException {


public void provision(NsiEvent event, NsiMapping mapping) throws NsiException {
// allowed transitions
// null state -> provisioning via PROV_START
// provisioned -> provisioning via PROV_START

// provisioning -> provisioned via PROV_CF

if (event.equals(NsiEvent.PROV_START)) {
if (!mapping.getProvisionState().equals(ProvisionStateEnumType.RELEASED)) {
if (!mapping.getProvisionState().equals(ProvisionStateEnumType.RELEASED) && !mapping.getProvisionState().equals(ProvisionStateEnumType.PROVISIONED)) {
throw new NsiException("Invalid prov state " + mapping.getProvisionState(), NsiErrors.TRANS_ERROR);
}
mapping.setProvisionState(ProvisionStateEnumType.PROVISIONING);
Expand Down
25 changes: 1 addition & 24 deletions backend/src/main/java/net/es/oscars/sb/SouthboundQueuer.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.es.oscars.sb.ent.RouterCommands;
import net.es.oscars.sb.nso.NsoAdapter;
import net.es.oscars.sb.beans.QueueName;
import net.es.oscars.sb.rancid.RancidAdapter;
import net.es.oscars.resv.db.ConnectionRepository;
import net.es.oscars.resv.ent.Connection;
import net.es.oscars.resv.enums.DeploymentState;
Expand All @@ -29,8 +28,6 @@ public class SouthboundQueuer {
@Autowired
private NsoAdapter nsoAdapter;

@Autowired
private RancidAdapter rancidAdapter;

@Autowired
private ConnectionRepository cr;
Expand Down Expand Up @@ -78,16 +75,7 @@ public void process() {
cr.save(conn);

log.info(wt.getConnectionId() + " " + wt.getCommandType() + " dst: " + conn.getDeploymentState());

if (isLegacy(conn)) {
if (wt.getCommandType().equals(CommandType.DISMANTLE)) {
this.completeTask(rancidAdapter.processTask(conn, wt.getCommandType(), wt.getIntent()));
} else {
log.warn("not performing non-dismantle task for legacy connection " + conn.getConnectionId());
}
} else {
this.completeTask(nsoAdapter.processTask(conn, wt.getCommandType(), wt.getIntent()));
}
this.completeTask(nsoAdapter.processTask(conn, wt.getCommandType(), wt.getIntent()));
});
}
waiting.clear();
Expand Down Expand Up @@ -127,17 +115,6 @@ public void completeTask(SouthboundTaskResult result) {
}
}

// a connection is legacy if it has any old-style dismantle commands
public boolean isLegacy(Connection conn) {
for (VlanJunction j : conn.getArchived().getCmp().getJunctions()) {
RouterCommands existing = rancidAdapter.existing(conn.getConnectionId(), j.getDeviceUrn(), CommandType.DISMANTLE);
if (existing != null) {
return !existing.getTemplateVersion().equals("NSO 1.1");
}
}
return false;
}

public void clear(QueueName name) {
switch (name) {
case DONE -> this.done.clear();
Expand Down
Loading

0 comments on commit 95b153d

Please sign in to comment.