Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Size based retention #7927

Open
wants to merge 74 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
30fe91a
Droping the first lines of code... Just seeing how it could be
Abuelodelanada Sep 9, 2022
664977f
Constant added and if... changed
Abuelodelanada Sep 14, 2022
c1a6b10
DiskStatus struct and DiskUsage function added
Abuelodelanada Sep 15, 2022
3542372
First lines of DeleteChunksBasedOnBlockSize
Abuelodelanada Sep 15, 2022
2647d1f
Missing "(" and ")"
Abuelodelanada Sep 15, 2022
6842ff5
First unit test written in golang
Abuelodelanada Sep 16, 2022
c5c74f2
Implement the deletion process
Abuelodelanada Sep 21, 2022
ae6dd9f
Refactor bytesToDelete function
Abuelodelanada Sep 22, 2022
0cc8d44
Move DiskStatus struct to utils
Abuelodelanada Sep 22, 2022
b44fe34
Move DiskStatus to a better place (?)
Abuelodelanada Sep 23, 2022
85a72ec
Add FIXME
Abuelodelanada Sep 23, 2022
abf6f37
bucketBlockSizeRetentionPercentaje -> bucketBlockSizeRetentionInterval
Abuelodelanada Sep 23, 2022
4b8e50d
Improve FIXME comment
Abuelodelanada Sep 23, 2022
7b85a62
Some refactor and encasuplation
Abuelodelanada Sep 23, 2022
1dad70c
Adding SizeBasedRetentionPercentage to common.go
Abuelodelanada Sep 27, 2022
3001053
There are still a lot of thinks to fix, but it is "working"
Abuelodelanada Oct 5, 2022
b73bdf0
Fix TODO comment
Abuelodelanada Oct 5, 2022
ee75bc0
Check if we are using boltdb as storage index
Abuelodelanada Oct 5, 2022
8dc931d
Fix comment to help us solve the issue
Abuelodelanada Oct 6, 2022
b0d5a42
NewCompactor modified. Now receives fsConfig
Abuelodelanada Oct 7, 2022
46688f9
Refactor DeleteChunksBasedOnBlockSize, remove from FSObjectClient, ad…
Abuelodelanada Oct 11, 2022
be4cfb3
missing code in merge
Abuelodelanada Dec 12, 2022
2f75e1b
fixing import in test
Abuelodelanada Dec 12, 2022
810d2b0
Merge branch 'main' into size_based_retention
Abuelodelanada Dec 14, 2022
538ba3a
remove duplicated CompactorRing
Abuelodelanada Jan 10, 2023
003cf1f
removed not used imports
Abuelodelanada Jan 10, 2023
89fc6ce
add missing arg to NewCompactor
Abuelodelanada Jan 10, 2023
261ee83
fixing tests
Abuelodelanada Jan 10, 2023
a3aaea3
linting common.go
Abuelodelanada Jan 10, 2023
22d7c8b
update documentation
Abuelodelanada Jan 10, 2023
ecb1776
replace deprecated io/ioutil with os
Abuelodelanada Jan 10, 2023
e368e75
more linting fixes
Abuelodelanada Jan 10, 2023
42370b6
replace another deprecated io/ioutil with os
Abuelodelanada Jan 10, 2023
ea68bd8
os.ReadDir behaves differently than ioutils.ReadDir
Abuelodelanada Jan 11, 2023
641c03e
Fix lang convention error -> err
Abuelodelanada Jan 18, 2023
d26d03e
Merge branch 'main' into size_based_retention
Abuelodelanada Jan 23, 2023
04f32df
WIP
MasslessParticle Feb 21, 2023
ce96f19
Merge remote-tracking branch 'canonical/size_based_retention' into tp…
MasslessParticle Feb 21, 2023
99a06e3
WIP
MasslessParticle Feb 21, 2023
5879265
Merge branch 'main' into size_based_retention
rbarry82 Mar 29, 2023
38f5e66
Merge remote-tracking branch 'upstream/tpatterson/space-compaction' i…
rbarry82 Mar 29, 2023
1c6cf85
Finish up renaming after merge to continue
rbarry82 Mar 29, 2023
1827d50
Merge branch 'main' into size_based_retention
rbarry82 Mar 29, 2023
b39ad06
Re-merge
rbarry82 Mar 29, 2023
7bff238
fix ineffectual assignment to err
Abuelodelanada Mar 29, 2023
1ed4fea
refactor functions
Abuelodelanada Mar 31, 2023
32f6492
Go through indexes to get chunkrefs
rbarry82 Apr 4, 2023
9916f09
Write marker entries for chunks
rbarry82 Apr 5, 2023
734ae82
Finish retention
rbarry82 Apr 8, 2023
e40ecb0
Merge pull request #3 from canonical/use-compacted-index
rbarry82 Apr 10, 2023
c0e7746
Extract/refactor
rbarry82 Apr 11, 2023
c06984c
Catch empty indexes and let them be cleaned up
rbarry82 Apr 12, 2023
eeb151f
Don't mark twice
rbarry82 Apr 12, 2023
a844dde
adding and improving log
Abuelodelanada Apr 12, 2023
7c716a1
Merge branch 'main' into size_based_retention
Abuelodelanada Apr 13, 2023
716fcd1
Bubble up a reasonable error from ChunkIterator
rbarry82 Apr 13, 2023
794b501
change log level
Abuelodelanada Apr 14, 2023
d538b7d
remove functions that were re-refactored
Abuelodelanada Apr 14, 2023
6c2e2e9
Merge branch 'main' into size_based_retention
Abuelodelanada May 5, 2023
2d5c863
Merge branch 'main' into size_based_retention
Abuelodelanada Jun 13, 2023
2073945
Merge branch 'main' into size_based_retention
Abuelodelanada Jun 26, 2023
ba5c932
remove commented code
Abuelodelanada Jun 26, 2023
dd77bd7
remove turning off index compaction
Abuelodelanada Jun 26, 2023
a05a5d8
remove nesting, add guards
Abuelodelanada Jun 26, 2023
69f78be
Merge branch 'grafana:main' into size_based_retention
Abuelodelanada Jun 27, 2023
1fbc41b
fix NewCompactor func signature
Abuelodelanada Jun 28, 2023
4ac5034
remove not used function
Abuelodelanada Jul 4, 2023
53156e0
fix NewCompactor() call
Abuelodelanada Jul 4, 2023
af0b78c
make MarkerMetrics public
Abuelodelanada Jul 4, 2023
bedd990
Refactor NewMarker. SizeBasedRetentionCleanerService added
Abuelodelanada Jul 4, 2023
dcf45cc
compactor refactored
Abuelodelanada Jul 4, 2023
797fea8
Fix Test_Retention
Abuelodelanada Jul 4, 2023
83cc6ec
make NewMarkerMetrics public
Abuelodelanada Jul 4, 2023
b5abb85
filling c.indexStorageClient
Abuelodelanada Jul 4, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/sources/configuration/_index.md
Expand Up @@ -2103,6 +2103,8 @@ The `compactor` block configures the compactor component, which compacts index s
# CLI flag: -boltdb.shipper.compactor.retention-delete-worker-count
[retention_delete_worker_count: <int> | default = 150]

[retention_disk_space_percentage: <int>]

# The maximum amount of time to spend running retention and deletion on any
# given table in the index.
# CLI flag: -boltdb.shipper.compactor.retention-table-timeout
Expand Down Expand Up @@ -2225,6 +2227,11 @@ compactor_ring:
# CLI flag: -boltdb.shipper.compactor.ring.instance-availability-zone
[instance_availability_zone: <string> | default = ""]

# Run the compactor one time to cleanup and compact index files only (no
# retention applied)
# CLI flag: -boltdb.shipper.compactor.run-once
[_: <boolean> | default = false]

# Enable using a IPv6 instance address.
# CLI flag: -boltdb.shipper.compactor.ring.instance-enable-ipv6
[instance_enable_ipv6: <boolean> | default = false]
Expand Down Expand Up @@ -3096,6 +3103,10 @@ storage:
# CLI flag: -common.storage.filesystem.rules-directory
[rules_directory: <string> | default = ""]

# Size based retention percentage
# CLI flag: -common.storage..size-based-retention-percentage
[size_based_retention_percentage: <int> | default = 80]

hedging:
# If set to a non-zero value a second request will be issued at the provided
# duration. Default is 0 (disabled)
Expand Down
6 changes: 4 additions & 2 deletions pkg/loki/common/common.go
Expand Up @@ -91,11 +91,13 @@ func (s *Storage) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
}

type FilesystemConfig struct {
ChunksDirectory string `yaml:"chunks_directory"`
RulesDirectory string `yaml:"rules_directory"`
ChunksDirectory string `yaml:"chunks_directory"`
RulesDirectory string `yaml:"rules_directory"`
SizeBasedRetentionPercentage int `yaml:"size_based_retention_percentage"`
}

func (cfg *FilesystemConfig) RegisterFlagsWithPrefix(prefix string, f *flag.FlagSet) {
f.StringVar(&cfg.ChunksDirectory, prefix+"filesystem.chunk-directory", "", "Directory to store chunks in.")
f.StringVar(&cfg.RulesDirectory, prefix+"filesystem.rules-directory", "", "Directory to store rules in.")
f.IntVar(&cfg.SizeBasedRetentionPercentage, prefix+".size-based-retention-percentage", 80, "Size based retention percentage")
}
2 changes: 2 additions & 0 deletions pkg/loki/config_wrapper.go
Expand Up @@ -459,6 +459,8 @@ func applyStorageConfig(cfg, defaults *ConfigWrapper) error {
r.Ruler.StoreConfig.Type = "local"
r.Ruler.StoreConfig.Local = local.Config{Directory: r.Common.Storage.FSConfig.RulesDirectory}
r.StorageConfig.FSConfig.Directory = r.Common.Storage.FSConfig.ChunksDirectory
r.CompactorConfig.RetentionDiskSpacePercentage = r.Common.Storage.FSConfig.SizeBasedRetentionPercentage
r.CompactorConfig.SharedStoreType = config.StorageTypeFileSystem
}
}

Expand Down
3 changes: 2 additions & 1 deletion pkg/loki/modules.go
Expand Up @@ -1137,7 +1137,8 @@ func (t *Loki) initCompactor() (services.Service, error) {
level.Info(util_log.Logger).Log("msg", "-boltdb.shipper.compactor.shared-store not specified, initializing compactor to operator on the following object stores", "stores", strings.Join(stores, ", "))
}

t.compactor, err = compactor.NewCompactor(t.Cfg.CompactorConfig, objectClients, t.Cfg.SchemaConfig, t.Overrides, prometheus.DefaultRegisterer)
t.compactor, err = compactor.NewCompactor(t.Cfg.CompactorConfig, objectClients, t.Cfg.SchemaConfig, t.Overrides, prometheus.DefaultRegisterer, t.Cfg.StorageConfig.FSConfig)

if err != nil {
return nil, err
}
Expand Down