Skip to content

test/doc changes on 90 2 #1296

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

Merged
merged 5 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion docs/testing/archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ description: Browse the archive for legacy Elastic products and documentation. A

This is a test modification on 9.0 branch

These are other modifications
These are other modifications

Another set of modifications
44 changes: 32 additions & 12 deletions src/infra/docs-lambda-index-publisher/LinkIndexProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information

using System.Net;
using Amazon.Lambda.Core;
using Amazon.S3;
using Amazon.S3.Model;
Expand Down Expand Up @@ -36,27 +37,40 @@ private async Task<LinkReferenceRegistry> GetLinkIndex()
return _linkIndex;
}

public async Task UpdateLinkIndexEntry(LinkRegistryEntry linkRegistryEntry)
public async Task UpdateLinkIndexEntry(LinkRegistryEntry newEntry)
{
_linkIndex ??= await GetLinkIndex();
if (_linkIndex.Repositories.TryGetValue(linkRegistryEntry.Repository, out var existingEntry))
var repository = newEntry.Repository;
var branch = newEntry.Branch;
// repository already exists in links.json
if (_linkIndex.Repositories.TryGetValue(repository, out var existingRepositoryEntry))
{
var newEntryIsNewer = DateTime.Compare(linkRegistryEntry.UpdatedAt, existingEntry[linkRegistryEntry.Branch].UpdatedAt) > 0;
if (newEntryIsNewer)
// The branch already exists in the repository entry
if (existingRepositoryEntry.TryGetValue(branch, out var existingBranchEntry))
{
existingEntry[linkRegistryEntry.Branch] = linkRegistryEntry;
logger.LogInformation("Updated existing entry for {repository}@{branch}", linkRegistryEntry.Repository, linkRegistryEntry.Branch);
if (newEntry.UpdatedAt > existingBranchEntry.UpdatedAt)
{
existingRepositoryEntry[branch] = newEntry;
logger.LogInformation("Updated existing entry for {repository}@{branch}", repository, branch);
}
else
logger.LogInformation("Skipping update for {repository}@{branch} because the existing entry is newer or equal", repository, branch);
}
// branch does not exist in the repository entry
else
logger.LogInformation("Skipping update for {repository}@{branch} because the existing entry is newer", linkRegistryEntry.Repository, linkRegistryEntry.Branch);
{
existingRepositoryEntry[branch] = newEntry;
logger.LogInformation("Added new entry '{repository}@{branch}' to existing entry for '{repository}'", repository, branch, repository);
}
}
// onboarding new repository
else
{
_linkIndex.Repositories.Add(linkRegistryEntry.Repository, new Dictionary<string, LinkRegistryEntry>
_linkIndex.Repositories.Add(repository, new Dictionary<string, LinkRegistryEntry>
{
{ linkRegistryEntry.Branch, linkRegistryEntry }
{ branch, newEntry }
});
logger.LogInformation("Added new entry for {repository}@{branch}", linkRegistryEntry.Repository, linkRegistryEntry.Branch);
logger.LogInformation("Added new entry for {repository}@{branch}", repository, branch);
}
}

Expand All @@ -74,7 +88,13 @@ public async Task Save()
ContentType = "application/json",
IfMatch = _etag // Only update if the ETag matches. Meaning the object has not been changed in the meantime.
};
_ = await s3Client.PutObjectAsync(putObjectRequest);
logger.LogInformation("Successfully saved link index to s3://{bucketName}/{key}", bucketName, key);
var putResponse = await s3Client.PutObjectAsync(putObjectRequest);
if (putResponse.HttpStatusCode == HttpStatusCode.OK)
logger.LogInformation("Successfully saved link index to s3://{bucketName}/{key}", bucketName, key);
else
{
logger.LogError("Unable to save index to s3://{bucketName}/{key}", bucketName, key);
throw new Exception($"Unable to save index to s3://{bucketName}/{key}");
}
}
}
Loading