Skip to content

Azure: Create blob container if not found. #9595

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

appkins
Copy link

@appkins appkins commented Jun 1, 2023

What this PR does / why we need it:
This PR aligns with the fallback behavior in Thanos object store for creating azure blob containers when they do not exist. Loki depends on the containers to function and already configures the necessary credentials for creating a container. It follows that Loki should create any required containers to prevent running in a failed state.

This behavior matches the code for Thanos here:
https://github.com/thanos-io/objstore/blob/main/providers/azure/azure.go#L167

ctx := context.Background()
	_, err = containerClient.GetProperties(ctx, &container.GetPropertiesOptions{})
	if err != nil {
		if !bloberror.HasCode(err, bloberror.ContainerNotFound) {
			return nil, err
		}
		_, err := containerClient.Create(ctx, nil)
		if err != nil {
			return nil, errors.Wrapf(err, "error creating Azure blob container: %s", conf.ContainerName)
		}
		level.Info(logger).Log("msg", "Azure blob container successfully created", "address", conf.ContainerName)
	}

I tried to match the behavior as closely as possible while using the existing azblob implementation in Loki (vs the azure sdk library in Thanos object store).

Which issue(s) this PR fixes:
Fixes #9467

Special notes for your reviewer:

Re-opened due to changing the default branch. Continuation of #9466

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md
@appkins appkins requested a review from a team as a code owner June 1, 2023 13:12
@appkins appkins force-pushed the azure-container branch from 8679fdc to 68382df Compare June 1, 2023 13:31
@CCOLLOT
Copy link
Contributor

CCOLLOT commented Feb 7, 2024

This is still an issue. Should someone take over this PR ? How can we make progress? I'm happy to contribute if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 participants