-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP added changes for alerting and calling reconciler through control…
…loop Signed-off-by: nicklesimba <[email protected]>
- Loading branch information
1 parent
8ef0d45
commit 9176123
Showing
3 changed files
with
85 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,48 @@ | ||
// package main | ||
package reconciler | ||
|
||
import ( | ||
"context" | ||
"flag" | ||
"os" | ||
"time" | ||
|
||
"github.com/k8snetworkplumbingwg/whereabouts/pkg/logging" | ||
"github.com/k8snetworkplumbingwg/whereabouts/pkg/reconciler" | ||
) | ||
|
||
const defaultReconcilerTimeout = 30 | ||
|
||
func main() { | ||
kubeConfigFile := flag.String("kubeconfig", "", "the path to the Kubernetes configuration file") | ||
logLevel := flag.String("log-level", "error", "the logging level for the `ip-reconciler` app. Valid values are: \"debug\", \"verbose\", \"error\", and \"panic\".") | ||
reconcilerTimeout := flag.Int("timeout", defaultReconcilerTimeout, "the value for a request timeout in seconds.") | ||
flag.Parse() | ||
const ( | ||
defaultReconcilerTimeout = 30 | ||
) | ||
|
||
logging.SetLogLevel(*logLevel) | ||
// TODO: get ip_test.go working with this - currently idk if it does... | ||
func InvokeIPReconciler(returnErr chan error) { | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(defaultReconcilerTimeout*time.Second)) | ||
defer cancel() | ||
|
||
var err error | ||
var ipReconcileLoop *reconciler.ReconcileLooper | ||
if kubeConfigFile == nil { | ||
ipReconcileLoop, err = reconciler.NewReconcileLooper(context.Background(), *reconcilerTimeout) | ||
} else { | ||
ipReconcileLoop, err = reconciler.NewReconcileLooperWithKubeconfig(context.Background(), *kubeConfigFile, *reconcilerTimeout) | ||
} | ||
ipReconcileLoop, err := NewReconcileLooper(ctx, defaultReconcilerTimeout) | ||
if err != nil { | ||
_ = logging.Errorf("failed to create the reconcile looper: %v", err) | ||
os.Exit(couldNotStartOrphanedIPMonitor) | ||
returnErr <- err | ||
return | ||
} | ||
|
||
cleanedUpIps, err := ipReconcileLoop.ReconcileIPPools(context.Background()) | ||
cleanedUpIps, err := ipReconcileLoop.ReconcileIPPools(ctx) | ||
if err != nil { | ||
_ = logging.Errorf("failed to clean up IP for allocations: %v", err) | ||
os.Exit(failedToReconcileIPPools) | ||
returnErr <- err | ||
return | ||
} | ||
|
||
if len(cleanedUpIps) > 0 { | ||
logging.Debugf("successfully cleanup IPs: %+v", cleanedUpIps) | ||
} else { | ||
logging.Debugf("no IP addresses to cleanup") | ||
} | ||
|
||
if err := ipReconcileLoop.ReconcileOverlappingIPAddresses(context.Background()); err != nil { | ||
os.Exit(failedToReconcileClusterWideIPs) | ||
if err := ipReconcileLoop.ReconcileOverlappingIPAddresses(ctx); err != nil { | ||
returnErr <- err | ||
return | ||
} | ||
|
||
logging.Verbosef("no errors with ip reconciler...returning in a sec") | ||
returnErr <- err | ||
return | ||
} |