Skip to content

Commit

Permalink
Don't exit tablet server on reloading invalid ACL
Browse files Browse the repository at this point in the history
This fixes potentially bringing down a tablet with an innocuous SIGHUP.

It also logs the fact it's reading the ACL file, to fix not getting any
feedback on SIGHUP.

#17139

Signed-off-by: Wiebe Cazemier <wiebe@ytec.nl>
  • Loading branch information
wiebeytec committed Jan 9, 2025
1 parent 6ac8998 commit 62e220f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions go/vt/tableacl/tableacl.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ func (tacl *tableACL) init(configFile string, aclCB func()) error {
}
data, err := os.ReadFile(configFile)
if err != nil {
log.Infof("unable to read tableACL config file: %v Error: %v", configFile, err)
log.Errorf("unable to read tableACL config file: %v Error: %v", configFile, err)
return err
}
config := &tableaclpb.Config{}
if err := config.UnmarshalVT(data); err != nil {
// try to parse tableacl as json file
if jsonErr := json2.UnmarshalPB(data, config); jsonErr != nil {
log.Infof("unable to parse tableACL config file as a protobuf or json file. protobuf err: %v json err: %v", err, jsonErr)
log.Errorf("unable to parse tableACL config file as a protobuf or json file. protobuf err: %v json err: %v", err, jsonErr)
return fmt.Errorf("unable to unmarshal Table ACL data: %s", data)
}
}
Expand Down
5 changes: 3 additions & 2 deletions go/vt/vttablet/tabletserver/tabletserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,9 @@ func (tsv *TabletServer) InitACL(tableACLConfigFile string, enforceTableACLConfi
sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGHUP)
go func() {
for range sigChan {
tsv.initACL(tableACLConfigFile, enforceTableACLConfig)
for sig := range sigChan {
log.Infof("Signal '%v' received, reloading ACL", sig)
tsv.initACL(tableACLConfigFile, false)
}
}()

Expand Down

0 comments on commit 62e220f

Please sign in to comment.