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

Can't manage private projects with the harbor_project resource #350

Closed
pidreher opened this issue Jul 20, 2023 · 4 comments · Fixed by #376
Closed

Can't manage private projects with the harbor_project resource #350

pidreher opened this issue Jul 20, 2023 · 4 comments · Fixed by #376
Labels
question Further information is requested

Comments

@pidreher
Copy link

pidreher commented Jul 20, 2023

Describe the bug
When creating a project with "public = true" I receive an "Error: Resource not found /projects/123"
The project is actually created in harbor. I assume it fails when trying to get the info of the just-created project.

When I set the project to "public = true" it works just fine.

Same behavior when trying to import an existing harbor_project into the tf state:
It works if public and fails if private.

To Reproduce
Create project with "public = false" (default).

or

Import project which is already private.

Expected behavior
I would expect this to not fail.

Additional context
Example log:

harbor_project.main: Creating...
2023-07-20T15:44:15.536+0200 [INFO] Starting apply for harbor_project.main
2023-07-20T15:44:15.536+0200 [DEBUG] harbor_project.main: applying the planned Create change
2023-07-20T15:44:15.537+0200 [INFO] provider.terraform-provider-harbor_v3.9.4: 2023/07/20 15:44:15 [DEBUG] []: timestamp=2023-07-20T15:44:15.537+0200
2023-07-20T15:44:15.781+0200 [ERROR] provider.terraform-provider-harbor_v3.9.4: Response contains error diagnostic: tf_proto_version=5.3 tf_rpc=ApplyResourceChange @module=sdk.proto diagnostic_severity=ERROR diagnostic_detail= diagnostic_summary="Resource not found /projects/1136" tf_provider_addr=provider tf_req_id=88f28883-acf6-3564-5cbd-59f82c9dc3ed tf_resource_type=harbor_project @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/diag/diagnostics.go:55 timestamp=2023-07-20T15:44:15.781+0200
2023-07-20T15:44:15.784+0200 [DEBUG] State storage *statemgr.Filesystem declined to persist a state snapshot
2023-07-20T15:44:15.784+0200 [ERROR] vertex "harbor_project.main" error: Resource not found /projects/1136

│ Error: Resource not found /projects/1136

│ with harbor_project.main,
│ on main.tf line 38, in resource "harbor_project" "main":
│ 38: resource "harbor_project" "main" {

not sure if this is an issue for the terraform provider or the main harbor project. I didn't try to reproduce it manually through the API.

  • Provider Version [3.9.4]
  • Terraform Version [1.5.3]
  • Harbor Version [v2.8.2]
@flbla flbla added the question Further information is requested label Jul 21, 2023
@flbla
Copy link
Contributor

flbla commented Jul 21, 2023

Hello,
it looks like a lack of permissions with the account you use to create the project.
if you don't use an "admin" account it's probably like this issue : #328

@pidreher
Copy link
Author

Hi,
seems so. I just finished digging around a bit.
Actually a 401 unauthorized is returned from the API for those requests. Should the terraform error message be more descriptive of this? "Resource not found" is a bit vague.

@flbla
Copy link
Contributor

flbla commented Jul 21, 2023

indeed, we can improve it

@pidreher
Copy link
Author

should this simply handle the 401 error (which imho is the wrong error, it should be 403) or should it also hint towards this problem?

flbla added a commit that referenced this issue Sep 29, 2023
flbla added a commit that referenced this issue Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants