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

Return aws error early if not: workgroup not found #70

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

Conversation

veqryn
Copy link

@veqryn veqryn commented Nov 12, 2024

This PR fixes the source of many hours of debugging by not hiding the original error and instead returning it.

Right now, even if your workgroup already exists, this driver will try to create it.
For example, if your aws permissions are not correct, the attempt to get the workgroup will fail. The driver will then attempt to create the workgroup, and return related to creating the workgroup if that fails too.
Instead, we should only create the workgroup if it does not exist. Right now, on the v1 aws driver, that is a 400 code error with the text WorkGroup is not found.

Reproduce-able setup:
Just make sure the workgroup does already exist, but your aws permissions are incorrect.

	athenaCfg := athenadrv.NewNoOpsConfig()
	athenaCfg.SetResultPollIntervalSeconds(athenadrv.PoolInterval)
	athenaCfg.SetWGRemoteCreationAllowed(true)
	athenaCfg.SetDB(athenaDatabase)

	err := athenaCfg.SetRegion(awsRegion)
	if err != nil {
		return nil, fmt.Errorf("unable to set athena region: %w", err)
	}

	err = athenaCfg.SetOutputBucket(fmt.Sprintf("s3://%s/%s", athenaResultsBucket, athenaResultsPath))
	if err != nil {
		return nil, fmt.Errorf("unable to set athena output bucket: %w", err)
	}

	err = athenaCfg.SetWorkGroup(athenadrv.NewDefaultWG(athenaWorkgroup, &athenav1.WorkGroupConfiguration{
		EnforceWorkGroupConfiguration:   aws.Bool(false),
		PublishCloudWatchMetricsEnabled: aws.Bool(true),
	}, nil))
	if err != nil {
		return nil, fmt.Errorf("unable to set athena workgroup: %w", err)
	}

	athenaDB, err := sql.Open(athenadrv.DriverName, athenaCfg.Stringify())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant