diff --git a/pkg/scalers/cassandra_scaler.go b/pkg/scalers/cassandra_scaler.go index 361dbfc44d2..dd5db28355e 100644 --- a/pkg/scalers/cassandra_scaler.go +++ b/pkg/scalers/cassandra_scaler.go @@ -313,6 +313,23 @@ func (s *cassandraScaler) GetQueryResult(ctx context.Context) (int64, error) { // Close closes the Cassandra session connection. func (s *cassandraScaler) Close(_ context.Context) error { + // clean up any temporary files + if strings.TrimSpace(s.metadata.cert) != "" { + if err := os.Remove(s.metadata.cert); err != nil { + return err + } + } + if strings.TrimSpace(s.metadata.key) != "" { + if err := os.Remove(s.metadata.key); err != nil { + return err + } + } + if strings.TrimSpace(s.metadata.ca) != "" { + if err := os.Remove(s.metadata.ca); err != nil { + return err + } + } + if s.session != nil { s.session.Close() }