go.ligato.io/vpp-agent/v3@v3.5.0/examples/kvscheduler/mock_plugins/scenario/failure_fixed_by_retry.go (about) 1 // Copyright (c) 2019 Cisco and/or its affiliates. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at: 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package scenario 16 17 import ( 18 "log" 19 20 "go.ligato.io/vpp-agent/v3/client" 21 mocksb "go.ligato.io/vpp-agent/v3/examples/kvscheduler/mock_plugins/ifplugin/mockcalls" 22 ) 23 24 // FailureFixedWithRetry presents a scenario, in which interface fails to get 25 // created at a first attempt, but an automatic retry, triggered in the background 26 // after a delay, will succeed to create the interface and all the objects that 27 // were waiting for it. 28 func FailureFixedWithRetry() { 29 c := client.LocalClient 30 listKnownModels(c) 31 32 mocksb.SimulateFailedTapCreation = true 33 printMessage( 34 "Resync config", 35 " - TAP interfaces tap1 to be configured inside a bridge-domain", 36 " - FIB entry defined to forward traffic for a certain", 37 " MAC address via tap1", 38 " - the TAP interface fails to get created (simulated in the mock SB)", 39 " -> the binding between the interface and the BD will remain pending", 40 " -> FIB will remain pending", 41 ) 42 err := c.ResyncConfig( 43 tap1, bd2, fib3, 44 ) 45 if err != nil { 46 log.Println(err) 47 } 48 informAboutGraphURL(0, true, false) 49 50 printMessage( 51 "Automatic Retry (triggered in the background)", 52 " - the repeated attempt to add tap1 will succeed", 53 " -> once configured, the interface is also added into the BD", 54 " and the pending FIB entry is created, both within the same", 55 " transaction", 56 ) 57 // retry is scheduler to run 1 second after the failed transaction and 58 // since printMessage() waits 2 seconds, the interface should be fixed by now 59 informAboutGraphURL(1, false, true) 60 }