Reading and understanding the code, and observing gaps in implementation.

What it does

Written below in detail

How we built it

Identified things that could be implemented after understanding the existing code base. Listed the features that would benefit the application, and added the features along with the test cases, to ensure stability.

Challenges we ran into

Understanding the codebase was a tad hard in the beginning. The variables within the code were tightly coupled, making it harder to reuse the methods, change them or write test cases.

Accomplishments that we're proud of

Was able to implement multiple feature enhancements, while also making the code cleaner and maintaining stability.

What we learned

Over the course of this project we were able to learn and understand additional CERN projects as well. understood few concepts regarding networking as well.

What's next for Golbd Changes

Some features like metric collection can be further enhanced to include more metrics. Also more opportunity to make the code more robust and clean. Great project overall. Would love to contribute more.


Retry mechanism:

This is used to attempt retries in case of failure.


type Retry struct { signal chan int // provides the retry signal done chan bool // marks the end of retry tick chan bool currentCount int maxCount int // maximum count of retries permitted retryStarted bool maxDuration time.Duration // max duration for which retries are allowed retryDuration time.Duration prevRetryDuration time.Duration logger logger.Logger } Max duration can be set via SetMaxDuration(maxDuration time.Duration) error Max retry count can be set via SetMaxCount(maxCount int) error The retry back off time keeps incrementing based on fibonacci sequence. The maximum number of retries that are allowed will be either till the max count is reached or the max duration is reached. The lesser of the two is considered. Any function that needs to be part of the retry mechanism (mostly network IO related), can be set by passing to the retry executor Execute(executor func() error) error. Implementation is present in lbcluster/lbcluster_dns.go:78


Logging Refractor:

This includes general refractor of logging, and also adds snapshot support to logging as well.


Contains a Factory method to create logger now. NewLoggerFactory(logFilePath string) (Logger, error). Any log based errors are handled during factory initialization type Logger interface { EnableDebugMode() EnableWriteToSTd() StartSnapshot(d time.Duration) GetLogFilePath() string Info(s string) Warning(s string) Debug(s string) Error(s string) } The above interface used as the logger type everywhere. The methods can be used instead of mutating the variables directly. Log based Snapshots : logs can now be made into snapshots by providing a cycle time. Once the cycle time expires a new snapshot is created. StartSnapshot(d time.Duration) log snapshots will be created in the following format: sample.0.log, sample.1.log


Metric Collection:

Added feature to collect metrics for DNS updates. This can be used for telemetry purposes.

Default Port: 8081

Contains GET API \metric to fetch all the metrics related to the server for that day. Server can be started by NewMetricServer(metricDirectoryPath string) error. Implemented in lbd.go:189( but disabled by default) New record can be written by WriteRecord(property Property) error. implemented in lbcluster/lbcluster_dns.go:86 type Property struct { RoundTripStartTime time.Time json:"start_time" csv:"start_time" rw:"r" RoundTripEndTime time.Time json:"end_time" csv:"end_time" rw:"r" RoundTripDuration time.Duration json:"round_trip_duration" } above are the current supported metrics. This functionality can be extended to add more.


Concurrency Addition

Concurrency has been added to two following methods. EvaluateHosts(hostsToCheck map[string]lbhost.Host) in lbcluster/lbcluster.go:294 SNMPDiscovery() in lbhost/lbhost.go:93


General Refractors

Refractors are done with following few things in mind.

Avoid direct use of variables to change state or read state. Getter and setter methods used instead. Avoid passing too many params or redundant params. Params such as logger and others which are common are added to the underlying struct instead. Remove redundant code Appropriate test cases have been added to all the above mentioned changes

Built With

Share this project: