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

[NOTE] API "POST /policies/replication" not work as expect #31

Open
moooofly opened this issue Nov 8, 2018 · 1 comment
Open

[NOTE] API "POST /policies/replication" not work as expect #31

moooofly opened this issue Nov 8, 2018 · 1 comment
Assignees
Labels
bug Something isn't working note markdown some conclusions v1.6.0-66709daa

Comments

@moooofly
Copy link
Owner

moooofly commented Nov 8, 2018

by swagger file

  • create a policy

image

image

the content of policyinfo used

{
  "name": "sync-fifth",
  "description": "fifth",
  "trigger": {
    "kind": "Scheduled",
    "schedule_param": {
      "type": "Weekly",
      "weekday": 1,
      "offtime": 0
    }
  },
  "replicate_existing_image_now": true,
  "replicate_deletion": false,
  "filters": [],
  "projects": [
    {
      "project_id": 6,
      "owner_id": 1,
      "name": "temp_5",
      "creation_time": "2018-11-02T06:58:11Z",
      "update_time": "2018-11-02T06:58:11Z",
      "deleted": false,
      "owner_name": "",
      "togglable": true,
      "current_user_role_id": 1,
      "repo_count": 1,
      "metadata": {
        "public": "true"
      }
    }
  ],
  "targets": [
    {
      "id": 1,
      "endpoint": "http://11.11.11.22",
      "name": "fake endpoint",
      "username": "admin",
      "password": "",
      "type": 0,
      "insecure": true,
      "creation_time": "2018-11-07T14:42:31.876842Z",
      "update_time": "2018-11-07T14:42:31.876842Z"
    }
  ]
}
  • get it back

image

image

but can not find it in Harbor UI (NOTE: this is my mistake, you can find them by "Next Page" button)

image

by harborctl

for test purpose, I have called "POST /policies/replication" API several times from swagger UI.

You will find multiple policies with almost same values except for the value of "id" (label ID).

[#935#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$./harborctl policy replication list -n sync-fifth -j 6
==> GET https://localhost/api/policies/replication?name=sync-fifth&project_id=6&page=1&page_size=10
<==
<== Rsp Status: 200 OK
<== Rsp Body: [
  {
    "id": 8,
    "name": "sync-fifth",
    "description": "fifth",
    "filters": null,
    "replicate_deletion": false,
    "trigger": {
      "kind": "Scheduled",
      "schedule_param": {
        "type": "Weekly",
        "weekday": 1,
        "offtime": 0
      }
    },
    "projects": [
      {
        "project_id": 6,
        "owner_id": 1,
        "name": "temp_5",
        "creation_time": "2018-11-02T06:58:11Z",
        "update_time": "2018-11-02T06:58:11Z",
        "deleted": false,
        "owner_name": "",
        "togglable": false,
        "current_user_role_id": 0,
        "repo_count": 0,
        "metadata": {
          "public": "true"
        }
      }
    ],
    "targets": [
      {
        "id": 1,
        "endpoint": "http://11.11.11.22",
        "name": "fake endpoint",
        "username": "admin",
        "password": "",
        "type": 0,
        "insecure": true,
        "creation_time": "2018-11-07T14:42:31.876842Z",
        "update_time": "2018-11-07T14:42:31.876842Z"
      }
    ],
    "creation_time": "2018-11-08T05:48:33Z",
    "update_time": "2018-11-08T05:48:33Z",
    "replicate_existing_image_now": false,
    "error_job_count": 1
  },
  {
    "id": 9,
    "name": "sync-fifth",
    "description": "fifth",
    "filters": null,
    "replicate_deletion": false,
    "trigger": {
      "kind": "Scheduled",
      "schedule_param": {
        "type": "Weekly",
        "weekday": 1,
        "offtime": 0
      }
    },
    "projects": [
      {
        "project_id": 6,
        "owner_id": 1,
        "name": "temp_5",
        "creation_time": "2018-11-02T06:58:11Z",
        "update_time": "2018-11-02T06:58:11Z",
        "deleted": false,
        "owner_name": "",
        "togglable": false,
        "current_user_role_id": 0,
        "repo_count": 0,
        "metadata": {
          "public": "true"
        }
      }
    ],
    "targets": [
      {
        "id": 1,
        "endpoint": "http://11.11.11.22",
        "name": "fake endpoint",
        "username": "admin",
        "password": "",
        "type": 0,
        "insecure": true,
        "creation_time": "2018-11-07T14:42:31.876842Z",
        "update_time": "2018-11-07T14:42:31.876842Z"
      }
    ],
    "creation_time": "2018-11-08T05:48:39Z",
    "update_time": "2018-11-08T05:48:39Z",
    "replicate_existing_image_now": false,
    "error_job_count": 1
  },
  {
    "id": 10,
    "name": "sync-fifth",
    "description": "fifth",
    "filters": null,
    "replicate_deletion": false,
    "trigger": {
      "kind": "Scheduled",
      "schedule_param": {
        "type": "Weekly",
        "weekday": 1,
        "offtime": 0
      }
    },
    "projects": [
      {
        "project_id": 6,
        "owner_id": 1,
        "name": "temp_5",
        "creation_time": "2018-11-02T06:58:11Z",
        "update_time": "2018-11-02T06:58:11Z",
        "deleted": false,
        "owner_name": "",
        "togglable": false,
        "current_user_role_id": 0,
        "repo_count": 0,
        "metadata": {
          "public": "true"
        }
      }
    ],
    "targets": [
      {
        "id": 1,
        "endpoint": "http://11.11.11.22",
        "name": "fake endpoint",
        "username": "admin",
        "password": "",
        "type": 0,
        "insecure": true,
        "creation_time": "2018-11-07T14:42:31.876842Z",
        "update_time": "2018-11-07T14:42:31.876842Z"
      }
    ],
    "creation_time": "2018-11-08T05:49:05Z",
    "update_time": "2018-11-08T05:49:05Z",
    "replicate_existing_image_now": false,
    "error_job_count": 1
  },
  {
    "id": 11,
    "name": "sync-fifth",
    "description": "fifth",
    "filters": null,
    "replicate_deletion": false,
    "trigger": {
      "kind": "Scheduled",
      "schedule_param": {
        "type": "Weekly",
        "weekday": 1,
        "offtime": 0
      }
    },
    "projects": [
      {
        "project_id": 6,
        "owner_id": 1,
        "name": "temp_5",
        "creation_time": "2018-11-02T06:58:11Z",
        "update_time": "2018-11-02T06:58:11Z",
        "deleted": false,
        "owner_name": "",
        "togglable": false,
        "current_user_role_id": 0,
        "repo_count": 0,
        "metadata": {
          "public": "true"
        }
      }
    ],
    "targets": [
      {
        "id": 1,
        "endpoint": "http://11.11.11.22",
        "name": "fake endpoint",
        "username": "admin",
        "password": "",
        "type": 0,
        "insecure": true,
        "creation_time": "2018-11-07T14:42:31.876842Z",
        "update_time": "2018-11-07T14:42:31.876842Z"
      }
    ],
    "creation_time": "2018-11-08T05:49:23Z",
    "update_time": "2018-11-08T05:49:23Z",
    "replicate_existing_image_now": false,
    "error_job_count": 1
  },
  {
    "id": 12,
    "name": "sync-fifth",
    "description": "fifth",
    "filters": null,
    "replicate_deletion": false,
    "trigger": {
      "kind": "Scheduled",
      "schedule_param": {
        "type": "Weekly",
        "weekday": 1,
        "offtime": 0
      }
    },
    "projects": [
      {
        "project_id": 6,
        "owner_id": 1,
        "name": "temp_5",
        "creation_time": "2018-11-02T06:58:11Z",
        "update_time": "2018-11-02T06:58:11Z",
        "deleted": false,
        "owner_name": "",
        "togglable": false,
        "current_user_role_id": 0,
        "repo_count": 0,
        "metadata": {
          "public": "true"
        }
      }
    ],
    "targets": [
      {
        "id": 1,
        "endpoint": "http://11.11.11.22",
        "name": "fake endpoint",
        "username": "admin",
        "password": "",
        "type": 0,
        "insecure": true,
        "creation_time": "2018-11-07T14:42:31.876842Z",
        "update_time": "2018-11-07T14:42:31.876842Z"
      }
    ],
    "creation_time": "2018-11-08T05:49:23Z",
    "update_time": "2018-11-08T05:49:23Z",
    "replicate_existing_image_now": false,
    "error_job_count": 1
  },
  {
    "id": 13,
    "name": "sync-fifth",
    "description": "fifth",
    "filters": null,
    "replicate_deletion": false,
    "trigger": {
      "kind": "Scheduled",
      "schedule_param": {
        "type": "Weekly",
        "weekday": 1,
        "offtime": 0
      }
    },
    "projects": [
      {
        "project_id": 6,
        "owner_id": 1,
        "name": "temp_5",
        "creation_time": "2018-11-02T06:58:11Z",
        "update_time": "2018-11-02T06:58:11Z",
        "deleted": false,
        "owner_name": "",
        "togglable": false,
        "current_user_role_id": 0,
        "repo_count": 0,
        "metadata": {
          "public": "true"
        }
      }
    ],
    "targets": [
      {
        "id": 1,
        "endpoint": "http://11.11.11.22",
        "name": "fake endpoint",
        "username": "admin",
        "password": "",
        "type": 0,
        "insecure": true,
        "creation_time": "2018-11-07T14:42:31.876842Z",
        "update_time": "2018-11-07T14:42:31.876842Z"
      }
    ],
    "creation_time": "2018-11-08T05:49:26Z",
    "update_time": "2018-11-08T05:49:26Z",
    "replicate_existing_image_now": false,
    "error_job_count": 1
  },
  {
    "id": 14,
    "name": "sync-fifth",
    "description": "fifth",
    "filters": null,
    "replicate_deletion": false,
    "trigger": {
      "kind": "Scheduled",
      "schedule_param": {
        "type": "Weekly",
        "weekday": 1,
        "offtime": 0
      }
    },
    "projects": [
      {
        "project_id": 6,
        "owner_id": 1,
        "name": "temp_5",
        "creation_time": "2018-11-02T06:58:11Z",
        "update_time": "2018-11-02T06:58:11Z",
        "deleted": false,
        "owner_name": "",
        "togglable": false,
        "current_user_role_id": 0,
        "repo_count": 0,
        "metadata": {
          "public": "true"
        }
      }
    ],
    "targets": [
      {
        "id": 1,
        "endpoint": "http://11.11.11.22",
        "name": "fake endpoint",
        "username": "admin",
        "password": "",
        "type": 0,
        "insecure": true,
        "creation_time": "2018-11-07T14:42:31.876842Z",
        "update_time": "2018-11-07T14:42:31.876842Z"
      }
    ],
    "creation_time": "2018-11-08T05:50:52Z",
    "update_time": "2018-11-08T05:50:52Z",
    "replicate_existing_image_now": false,
    "error_job_count": 1
  },
  {
    "id": 15,
    "name": "sync-fifth",
    "description": "fifth",
    "filters": null,
    "replicate_deletion": false,
    "trigger": {
      "kind": "Scheduled",
      "schedule_param": {
        "type": "Weekly",
        "weekday": 1,
        "offtime": 0
      }
    },
    "projects": [
      {
        "project_id": 6,
        "owner_id": 1,
        "name": "temp_5",
        "creation_time": "2018-11-02T06:58:11Z",
        "update_time": "2018-11-02T06:58:11Z",
        "deleted": false,
        "owner_name": "",
        "togglable": false,
        "current_user_role_id": 0,
        "repo_count": 0,
        "metadata": {
          "public": "true"
        }
      }
    ],
    "targets": [
      {
        "id": 1,
        "endpoint": "http://11.11.11.22",
        "name": "fake endpoint",
        "username": "admin",
        "password": "",
        "type": 0,
        "insecure": true,
        "creation_time": "2018-11-07T14:42:31.876842Z",
        "update_time": "2018-11-07T14:42:31.876842Z"
      }
    ],
    "creation_time": "2018-11-08T05:50:53Z",
    "update_time": "2018-11-08T05:50:53Z",
    "replicate_existing_image_now": false,
    "error_job_count": 1
  },
  {
    "id": 16,
    "name": "sync-fifth",
    "description": "fifth",
    "filters": null,
    "replicate_deletion": false,
    "trigger": {
      "kind": "Scheduled",
      "schedule_param": {
        "type": "Weekly",
        "weekday": 1,
        "offtime": 0
      }
    },
    "projects": [
      {
        "project_id": 6,
        "owner_id": 1,
        "name": "temp_5",
        "creation_time": "2018-11-02T06:58:11Z",
        "update_time": "2018-11-02T06:58:11Z",
        "deleted": false,
        "owner_name": "",
        "togglable": false,
        "current_user_role_id": 0,
        "repo_count": 0,
        "metadata": {
          "public": "true"
        }
      }
    ],
    "targets": [
      {
        "id": 1,
        "endpoint": "http://11.11.11.22",
        "name": "fake endpoint",
        "username": "admin",
        "password": "",
        "type": 0,
        "insecure": true,
        "creation_time": "2018-11-07T14:42:31.876842Z",
        "update_time": "2018-11-07T14:42:31.876842Z"
      }
    ],
    "creation_time": "2018-11-08T05:54:43Z",
    "update_time": "2018-11-08T05:54:43Z",
    "replicate_existing_image_now": false,
    "error_job_count": 1
  }
]
[#936#root@ubuntu-1604 /go/src/github.com/moooofly/harborctl]$
@moooofly moooofly added bug Something isn't working note markdown some conclusions v1.6.0-66709daa labels Nov 8, 2018
@moooofly moooofly self-assigned this Nov 8, 2018
@moooofly
Copy link
Owner Author

moooofly commented Nov 8, 2018

have a try with the content below (setting "id")

{
  "id": 100,           // -- set this in order to specify the label ID
  "name": "sync-fifth",
  "description": "fifth",
  "trigger": {
    "kind": "Scheduled",
    "schedule_param": {
      "type": "Weekly",
      "weekday": 1,
      "offtime": 0
    }
  },
  "replicate_existing_image_now": true,
  "replicate_deletion": false,
  "filters": [],
  "projects": [
    {
      "project_id": 6,
      "owner_id": 1,
      "name": "temp_5",
      "creation_time": "2018-11-02T06:58:11Z",
      "update_time": "2018-11-02T06:58:11Z",
      "deleted": false,
      "owner_name": "",
      "togglable": true,
      "current_user_role_id": 1,
      "repo_count": 1,
      "metadata": {
        "public": "true"
      }
    }
  ],
  "targets": [
    {
      "id": 1,
      "endpoint": "http://11.11.11.22",
      "name": "fake endpoint",
      "username": "admin",
      "password": "",
      "type": 0,
      "insecure": true,
      "creation_time": "2018-11-07T14:42:31.876842Z",
      "update_time": "2018-11-07T14:42:31.876842Z"
    }
  ]
}

and you will get

...
  {
    "id": 17,       // not 100, but 17
    "name": "sync-fifth",
    "description": "fifth",
    "filters": null,
    "replicate_deletion": false,
    "trigger": {
      "kind": "Scheduled",
      "schedule_param": {
        "type": "Weekly",
        "weekday": 1,
        "offtime": 0
      }
    },
    "projects": [
      {
        "project_id": 6,
        "owner_id": 1,
        "name": "temp_5",
        "creation_time": "2018-11-02T06:58:11Z",
        "update_time": "2018-11-02T06:58:11Z",
        "deleted": false,
        "owner_name": "",
        "togglable": false,
        "current_user_role_id": 0,
        "repo_count": 0,
        "metadata": {
          "public": "true"
        }
      }
    ],
    "targets": [
      {
        "id": 1,
        "endpoint": "http://11.11.11.22",
        "name": "fake endpoint",
        "username": "admin",
        "password": "",
        "type": 0,
        "insecure": true,
        "creation_time": "2018-11-07T14:42:31.876842Z",
        "update_time": "2018-11-07T14:42:31.876842Z"
      }
    ],
    "creation_time": "2018-11-08T06:05:49Z",
    "update_time": "2018-11-08T06:05:49Z",
    "replicate_existing_image_now": false,
    "error_job_count": 1
  }
]

The result shows that it has no way to set label ID manually, and the value of label ID is generated by Harbor service one by one.

So, "409 | Policy name already used or policy already exists with the same project and target." will never be triggered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working note markdown some conclusions v1.6.0-66709daa
Projects
None yet
Development

No branches or pull requests

1 participant