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

Add remote configuration repository #2688

Merged
merged 6 commits into from
Mar 17, 2023
Merged

Conversation

lloeki
Copy link
Contributor

@lloeki lloeki commented Mar 13, 2023

What does this PR do?

Add configuration repository, using PORO from #2687

Motivation

Additional Notes

This is an initial basic implementation. It is notably missing:

  • storing digests for each bit of content
  • reporting a summary of which paths have been updated and their corresponding data for taking action on the newly received configuration
  • error tracking and reporting
  • a content caching mechanism and cache state reporting

These will be added progressively.

How to test the change?

  require 'datadog/core/remote/configuration/path'
  require 'datadog/core/remote/configuration/target'
  require 'datadog/core/remote/configuration/content'

  path = Datadog::Core::Remote::Configuration::Path.parse('datadog/42/PRODUCT/foo/config')
  content = Datadog::Core::Remote::Configuration::Content.parse({path: 'datadog/42/PRODUCT/foo/config', content: StringIO.new('Lorem ipsum')})
  target = Datadog::Core::Remote::Configuration::Target.parse({'length' => 11, 'hashes' => {'sha256' => 'a9a66978f378456c818fb8a3e7c6ad3d2c83e62724ccbdea7b36253fb8df5edd'}})

  path2 = Datadog::Core::Remote::Configuration::Path.parse('datadog/42/PRODUCT/bar/config')
  content2 = Datadog::Core::Remote::Configuration::Content.parse({path: 'datadog/42/PRODUCT/bar/config', content: StringIO.new('Lorem ipsum')})
  target2 = Datadog::Core::Remote::Configuration::Target.parse({'length' => 11, 'hashes' => {'sha256' => 'a9a66978f378456c818fb8a3e7c6ad3d2c83e62724ccbdea7b36253fb8df5edd'}})

  content3 = Datadog::Core::Remote::Configuration::Content.parse({path: 'datadog/42/PRODUCT/foo/config', content: StringIO.new('dolor sit amet')})
  target3 = Datadog::Core::Remote::Configuration::Target.parse({'length' => 11, 'hashes' => {'sha256' => 'aa8311d08b68a5fdda55ad0947fff3c5a4b2397f5f766e9c9a79f4a5486c633c'}})

  require 'datadog/core/remote/configuration/repository'

  txn = Datadog::Core::Remote::Configuration::Repository::Transaction.new
  txn.delete(path)
  txn.operations

  txn = Datadog::Core::Remote::Configuration::Repository::Transaction.new
  txn.insert(path, target, content)
  txn.operations

  txn = Datadog::Core::Remote::Configuration::Repository::Transaction.new
  txn.update(path, target, content)
  txn.operations

  txn = Datadog::Core::Remote::Configuration::Repository::Transaction.new
  txn.set(opaque_backend_state: 'OPAQUE_DATA')
  txn.operations

  txn = Datadog::Core::Remote::Configuration::Repository::Transaction.new
  txn.set(targets_version: 42)
  txn.operations

  repository = Datadog::Core::Remote::Configuration::Repository.new
  repository.contents
  repository.root_version
  repository.targets_version

  repository.transaction do |repo, txn|
    txn.insert(path, target, content)
    txn.set(opaque_backend_state: 'OPAQUE_DATA', targets_version: target_map.version)
  end

  repository.contents
  repository.root_version
  repository.targets_version
  repository[path]

  repository.transaction do |repo, txn|
    txn.insert(path2, target2, content2)
  end

  repository[path2]
  repository.contents

  repository.transaction do |repo, txn|
    txn.insert(path, target, content)
  end

  repository.contents

  repository.transaction do |repo, txn|
    txn.update(path, target3, content3)
  end

  repository[path]

  repository.transaction do |repo, txn|
    txn.delete(path)
  end

  repository.contents
  repository[path]

  repository.transaction do |repo, txn|
    txn.update(path, target, content)
  end

  repository[path]

@github-actions github-actions bot added the core Involves Datadog core libraries label Mar 13, 2023
@lloeki
Copy link
Contributor Author

lloeki commented Mar 13, 2023

Pending:

  • specs
  • RBS typing

@lloeki
Copy link
Contributor Author

lloeki commented Mar 16, 2023

Rebased using git rebase --onto origin/add-remote-config-poro 37eb3b095 add-remote-config-repository

Base automatically changed from add-remote-config-poro to master March 16, 2023 12:46
This is an initial basic implementation. It is notably missing:

- storing digests for each bit of content
- reporting a summary of which paths have been updated and their
  corresponding data for taking action on the newly received
  configuration
- error tracking and reporting
- a content caching mechanism and cache state reporting

These will be added progressively.
@lloeki lloeki force-pushed the add-remote-config-repository branch from 414a626 to 5371edf Compare March 16, 2023 12:49
@lloeki
Copy link
Contributor Author

lloeki commented Mar 16, 2023

Rebased using git rebase --onto master 414a626^ add-remote-config-repository

@GustavoCaso GustavoCaso marked this pull request as ready for review March 16, 2023 15:54
@GustavoCaso GustavoCaso requested a review from a team March 16, 2023 15:54
Copy link
Contributor Author

@lloeki lloeki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the specs and types! I have a suggestion concerning Base.

lib/datadog/core/remote/configuration/repository.rb Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

Codecov Report

Merging #2688 (bf7e2b2) into master (3ae66fb) will decrease coverage by 0.07%.
The diff coverage is 95.36%.

@@            Coverage Diff             @@
##           master    #2688      +/-   ##
==========================================
- Coverage   98.09%   98.03%   -0.07%     
==========================================
  Files        1168     1197      +29     
  Lines       64254    65714    +1460     
  Branches     2857     2926      +69     
==========================================
+ Hits        63033    64423    +1390     
- Misses       1221     1291      +70     
Impacted Files Coverage Δ
lib/datadog/core/transport/http/builder.rb 79.01% <79.01%> (ø)
lib/datadog/core/transport/http.rb 79.66% <79.66%> (ø)
lib/datadog/core/transport/http/config.rb 84.55% <84.55%> (ø)
lib/datadog/core/transport/http/client.rb 87.50% <87.50%> (ø)
lib/datadog/core/transport/http/negotiation.rb 90.32% <90.32%> (ø)
spec/datadog/core/transport/integration_spec.rb 91.89% <91.89%> (ø)
lib/datadog/core/transport/http/api/instance.rb 93.75% <93.75%> (ø)
lib/datadog/core/transport/config.rb 96.00% <96.00%> (ø)
spec/datadog/tracing/contrib/roda/patcher_spec.rb 96.26% <96.26%> (ø)
lib/datadog/core/remote/configuration/target.rb 98.41% <98.41%> (ø)
... and 22 more

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@GustavoCaso GustavoCaso merged commit a692552 into master Mar 17, 2023
@GustavoCaso GustavoCaso deleted the add-remote-config-repository branch March 17, 2023 07:59
@github-actions github-actions bot added this to the 1.11.0 milestone Mar 17, 2023
@lloeki lloeki modified the milestones: 1.11.0, 1.11.0.beta1 Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Involves Datadog core libraries
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants